Progress bar animation in recyclerview item android - progress bar animation in recyclerview item
扔个三星炸死你
扔个三星炸死你 2017-06-08 11:02:32
0
1
1093

Write ademo I want the progress bar in item in recyclerview to have an animation effect

I wrote it by continuously setting setProgress(), but in the actual process, the animation will play on the incorrect item
Even if I judge If item is reused, there is nothing you can do if you cancel it. .


SparseIntArray sparseIntArray = new SparseIntArray();
ArrayMap<Integer, Disposable> arrayMap = new ArrayMap<>();

binding.recyclerView.setAdapter(new BaseRecyclerViewAdapter<Integer>(strings) {
    @Override
    public int getLayoutId(int viewType) {
        return R.layout.recycler_item;//item布局 其中有一个横向的进度条空间
    }

    @Override
    protected void convert(VH holder, Integer i, int position) {
  
        int after = sparseIntArray.get(position);        //查看item是否第一次使用
        Disposable disposable1 = arrayMap.get(position);
        if (disposable1 != null) {
            PtrCLog.d("RecyclerViewActivity", "convert: " + "取消订阅");
            disposable1.dispose();
        }

        if (after == i) {
            PtrCLog.d("RecyclerViewActivity", "convert: " + "相同后直接设置");
            holder.setProgress(R.id.progress_bar_financing_item, i);
        } else {
            sparseIntArray.put(position, i);//存
            int castProgress = (i);      //当前得到的
            PtrCLog.d("LoanListAdapter", "progress: " + castProgress);
            PtrCLog.d("LoanListAdapter", "初次生效当前坐标为: " + position + "-----" + "存储的进度为" + castProgress);
            Disposable disposable = Observable
                    .intervalRange(0, castProgress + 1, 0, 30, TimeUnit.MILLISECONDS)
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(aLong -> {
                                PtrCLog.d("LoanListAdapter", "convert: " + position + "----" + aLong + "");
                                PtrCLog.d("RecyclerViewActivity", "convert: after" + (after == i));
                                holder.setProgress(R.id.progress_bar_financing_item, Integer.parseInt(aLong + ""));
                            }, throwable -> {
                            }
                            , () -> {
                            });
            arrayMap.put(position, disposable);
        }
    }
});
    
扔个三星炸死你
扔个三星炸死你

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!