PullLoadMoreRecyclerView icon indicating copy to clipboard operation
PullLoadMoreRecyclerView copied to clipboard

在上拉加载的时候,无法手动关闭动画,并且有概率性的动画一直不消失

Open SJLBenjamin opened this issue 5 years ago • 2 comments

SJLBenjamin avatar Jul 11 '19 11:07 SJLBenjamin

上滑到最后没有数据时,底部加载不消失,看了下源码

public void loadMore() {
        if (mPullLoadMoreListener != null && hasMore) {
            mFooterView.animate()
                    .translationY(0)
                    .setDuration(300)
                    .setInterpolator(new AccelerateDecelerateInterpolator())
                    .setListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationStart(Animator animation) {
                            mFooterView.setVisibility(View.VISIBLE);
                        }
                    })
                    .start();
            invalidate();
            mPullLoadMoreListener.onLoadMore();

        }
    }

,在加载动画时,只设置了动画开始的回调,让加载View显示,loadMore之后貌似并没有做消失处理,也没有看到相关的能隐藏的方法

OYXS520 avatar Jul 04 '22 07:07 OYXS520

最终获取完所有数据后,通过反射调用该View,主动隐藏,代码如下

public void solveProblem(){
        binding.includeOpus.pullLoadMoreRecyclerView.setPullLoadMoreCompleted(); //解决隐藏后,会出现无法滑动的问题
        Class<? extends PullLoadMoreRecyclerView> aClass = binding.includeOpus.pullLoadMoreRecyclerView.getClass();
        try {
            Field mFooterView = aClass.getDeclaredField("mFooterView");
            mFooterView.setAccessible(true);
            View view = (View) mFooterView.get(binding.includeOpus.pullLoadMoreRecyclerView);
            if (view != null) {
                view.setVisibility(View.GONE);

            }
        } catch (NoSuchFieldException | IllegalAccessException e) {
            Log.e("test", "solveProblem: ", e);
        }
    }

OYXS520 avatar Jul 04 '22 08:07 OYXS520