CymChad / CymChad/BaseRecyclerViewAdapterHelper

SmartRefreshLayout 配合下拉加载更多时候报错

Open
#3,320 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Kotlin
Stars
24.6k
Forks
5.2k
PR merge metrics
No merged PRs in 30d

Description

SmartRefreshLayout refreshLayout; //下拉刷新,上拉加载

learnLoader.getArticleVideoData(pageNo, 20, 5).subscribe(new RequestCallback<ArticleVideoData.Data>() {
@Override
public void onSuccess(ArticleVideoData.Data articleVideoData) {
if (pageNo == 1) {
adapter.setNewData(Arrays.asList(articleVideoData.rows));
refreshLayout.setEnableLoadMore(true);
} else {
adapter.addData(Arrays.asList(articleVideoData.rows));
}
pageCount = articleVideoData.pageCount;
if (refreshLayout != null) {
if (pageNo == 1) {
refreshLayout.finishRefresh();
} else {
refreshLayout.finishLoadMore();
}
}
pageNo++;
}

        @Override
        public void onFail(Throwable e) {
            if (refreshLayout != null) {
                refreshLayout.finishLoadMore();
            }
        }
    }); 

io.reactivex.exceptions.UndeliverableException: The exception could not be delivered to the consumer because it has already canceled/disposed the flow or the exception has nowhere to go to begin with. Further reading: https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#error-handling | java.lang.UnsupportedOperationException
at io.reactivex.plugins.RxJavaPlugins.onError(RxJavaPlugins.java:367)
at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:121)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6815)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
Caused by: java.lang.UnsupportedOperationException
at java.util.AbstractList.add(AbstractList.java:148)
at java.util.AbstractList.add(AbstractList.java:108)
at java.util.AbstractCollection.addAll(AbstractCollection.java:344)
at com.chad.library.adapter.base.BaseQuickAdapter.addData(BaseQuickAdapter.java:559)
at com.typartybuilding.activity.lean.XrxyAct$3.onSuccess(XrxyAct.java:106)
at com.typartybuilding.activity.lean.XrxyAct$3.onSuccess(XrxyAct.java:99)
at com.typartybuilding.network.https.RequestCallback.onNext(RequestCallback.java:21)
at io.reactivex.internal.operators.observable.ObservableMap$MapObserver.onNext(ObservableMap.java:62)
at io.reactivex.observers.SerializedObserver.onNext(SerializedObserver.java:111)
at io.reactivex.internal.operators.observable.ObservableDebounceTimed$DebounceTimedObserver.emit(ObservableDebounceTimed.java:143)
at io.reactivex.internal.operators.observable.ObservableDebounceTimed$DebounceEmitter.run(ObservableDebounceTimed.java:168)
at io.reactivex.internal.operators.observable.ObservableDebounceTimed$DebounceTimedObserver.onComplete(ObservableDebounceTimed.java:124)
at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.checkTerminated(ObservableObserveOn.java:287)
at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal(ObservableObserveOn.java:172)
at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run(ObservableObserveOn.java:255)
at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:119)
at android.os.Handler.handleCallback(Handler.java:873) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:201) 
at android.app.ActivityThread.main(ActivityThread.java:6815) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873) 
java.lang.UnsupportedOperationException

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at BaseQuickAdapter.addData, then compare it with the XrxyAct.onSuccess call shown in the stack trace. Reproduce the error while loading more after setNewData receives Arrays.asList; the work is done when loading more completes without UnsupportedOperationException.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.