How to stop blinking on recycler view with architecture components paging library

后端 未结 5 1179
囚心锁ツ
囚心锁ツ 2021-02-05 08:02

I have a chat-like activity where I am using a RecyclerView with a PagedListAdaper to load a bunch of messages. I\'m using a PositionalDataSource to load the data. The loading i

5条回答
  •  情深已故
    2021-02-05 08:49

    you should use sync in loadInitial and loadAfter, ie:

    mLoadState.postValue(NetworkState.Loading);
    try {
        mLoadState.postValue(NetworkState.DONE);
        ResultMessage> info = call.execute().body();
        if (info != null && info.isSuccess()) {
            List list = info.getData();
            callback.onResult(list, null, FIRST_PAGE + 1);
        }
    } catch (IOException e) {
        mLoadState.postValue(NetworkState.ERROR);
        mRetry.postValue(() -> loadInitial(params, callback));
        Log.d(TAG, "fail!");
    }
    

提交回复
热议问题