HotBitmapGG / MoeQuest

The meizi of a material design style welfare App.
Apache License 2.0
253 stars 76 forks source link

RecyclerView刷新bug #3

Closed SheepYang1993 closed 8 years ago

SheepYang1993 commented 8 years ago

下拉刷新后立即上滑会报错

HotBitmapGG commented 8 years ago

ok,这个我一会看一下

HotBitmapGG commented 8 years ago

这个问题解决了,RecyclerView Bug:IndexOutOfBoundsException: Inconsistency detected. Invalid item position,解决方法参考了 @drakeet 大神的解决方法,用一个标志位去判断,正在刷新数据的话就拦截掉RecycleView的touch事件,目前还没找到更好的解决方案了。 https://drakeet.me/recyclerview-bug-indexoutofboundsexception-inconsistency-detected-invalid-item-position-solution

private void setRecycleScrollBug() {

    mRecyclerView.setOnTouchListener(new View.OnTouchListener()
    {

        @Override
        public boolean onTouch(View v, MotionEvent event)
        {

            if (mIsRefreshing)
            {
                return true;
            } else
            {
                return false;
            }
        }
    });
}