Practical usage of ContentLoadingProgressBar

后端 未结 4 1518
死守一世寂寞
死守一世寂寞 2021-02-01 01:34

I was going through developer site of android and I found a class named ContentLoadingProgressBar. By seeing this class I come up with some questions in my mind

4条回答
  •  执念已碎
    2021-02-01 01:37

    One note of using ContentLoadingProgressBar for recyclerview items. I have a scenario in which an arbitrary RV item can download something on clicked and shows indeterminate progress until completion. It appears to be impossible to use the benefits of CLPB in such case because of maintaining internal delays in CLPB when show()/hide() it: reused views may have inconsisted progress state (progress disappears or become infinite depending on reused holder view state). Thus i was forced to return to old good setVisibility:

    public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position)
                   ...
            if (item.isLoading()) {
            //holder.progressBar.show();
            holder.progressBar.setVisibility(View.VISIBLE);
        } else {
            //holder.progressBar.hide();
            holder.progressBar.setVisibility(View.INVISIBLE);
        }
    

提交回复
热议问题