Java Code Examples for com.socks.jiandan.callback.LoadResultCallBack

The following examples show how to use com.socks.jiandan.callback.LoadResultCallBack. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: JianDan_OkHttpWithVolley   Source File: PictureAdapter.java    License: Apache License 2.0 6 votes vote down vote up
private void loadData() {

        RequestManager.addRequest(new Request4Picture(Picture.getRequestUrl(mType, page),
                new Response.Listener<ArrayList<Picture>>
                        () {
                    @Override
                    public void onResponse(ArrayList<Picture> response) {
                        getCommentCounts(response);
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                mLoadResultCallBack.onError(LoadResultCallBack.ERROR_NET, error.getMessage());
                mLoadFinisCallBack.loadFinish(null);
            }
        }), mActivity);
    }
 
Example 2
Source Project: JianDan   Source File: PictureAdapter.java    License: Apache License 2.0 6 votes vote down vote up
private void loadData() {

        RequestManager.addRequest(new Request4Picture(Picture.getRequestUrl(mType, page),
                new Response.Listener<ArrayList<Picture>>
                        () {
                    @Override
                    public void onResponse(ArrayList<Picture> response) {
                        getCommentCounts(response);
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                mLoadResultCallBack.onError(LoadResultCallBack.ERROR_NET, error.getMessage());
                mLoadFinisCallBack.loadFinish(null);
            }
        }), mActivity);
    }
 
Example 3
Source Project: JianDanRxJava   Source File: JokeAdapter.java    License: Apache License 2.0 6 votes vote down vote up
private void loadCache() {
    Subscription subscription = Observable
            .create((Observable.OnSubscribe<ArrayList<Joke>>)
                    subscriber -> {
                        subscriber.onNext(JokeCache.getInstance(mActivity).getCacheByPage(page));
                        subscriber.onCompleted();
                    })
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .doOnNext(jokes -> {
                if (page == 1) {
                    mJokes.clear();
                    ToastHelper.Short(ConstantString.LOAD_NO_NETWORK);
                }
            })
            .subscribe(jokes -> {
                mJokes.addAll(jokes);
                notifyDataSetChanged();
                mLoadFinisCallBack.loadFinish(null);
                mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
            });
    mActivity.addSubscription(subscription);
}
 
Example 4
Source Project: JianDanRxJava   Source File: PictureAdapter.java    License: Apache License 2.0 6 votes vote down vote up
private void loadData() {
    Subscription subscription = JDApi.getPictures(mType, page)
            .flatMap(Observable::from)
            .filter(picture -> picture.getPics() != null)
            .toList()
            .observeOn(Schedulers.io())
            .doOnNext(pictures -> {
                if (page == 1) {
                    PictureAdapter.this.mPictures.clear();
                    PictureCache.getInstance(mActivity).clearAllCache();
                }
            })
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(this::getCommentCounts, e -> {
                mLoadResultCallBack.onError(LoadResultCallBack.ERROR_NET);
                mLoadFinisCallBack.loadFinish(null);
            });
    mActivity.addSubscription(subscription);
}
 
Example 5
Source Project: JianDanRxJava   Source File: PictureAdapter.java    License: Apache License 2.0 6 votes vote down vote up
private void loadCache() {
    Subscription subscription = Observable.create((Observable.OnSubscribe<ArrayList<Picture>>) subscriber -> {
        subscriber.onNext(PictureCache.getInstance(mActivity).getCacheByPage(page));
        subscriber.onCompleted();
    }).compose(JDApi.applySchedulers())
            .doOnNext(pictures -> {
                if (page == 1) {
                    mPictures.clear();
                    ToastHelper.Short(ConstantString.LOAD_NO_NETWORK);
                }
            })
            .subscribe(pictures -> {
                mPictures.addAll(pictures);
                notifyDataSetChanged();
                mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
                mLoadFinisCallBack.loadFinish(null);
            });
    mActivity.addSubscription(subscription);
}
 
Example 6
Source Project: JianDanRxJava   Source File: PictureAdapter.java    License: Apache License 2.0 6 votes vote down vote up
private void getCommentCounts(final List<Picture> pictures) {

        StringBuilder sb = new StringBuilder();
        for (Picture joke : pictures) {
            sb.append("comment-").append(joke.getComment_ID()).append(",");
        }

        JDApi.getCommentNumber(sb.toString())
                .doOnCompleted(() -> PictureCache.getInstance(mActivity).addResultCache(GsonHelper.toString(mPictures), page))
                .subscribe(commentNumbers -> {
                    mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
                    mLoadFinisCallBack.loadFinish(null);

                    for (int i = 0; i < pictures.size(); i++) {
                        pictures.get(i).setComment_counts(commentNumbers.get(i).comments + "");
                    }

                    PictureAdapter.this.mPictures.addAll(pictures);
                    notifyDataSetChanged();
                }, e -> {
                    ToastHelper.Short(ConstantString.LOAD_FAILED);
                    mLoadFinisCallBack.loadFinish(null);
                    mLoadResultCallBack.onError(LoadResultCallBack.ERROR_NET);
                });
    }
 
Example 7
Source Project: JianDanRxJava   Source File: FreshNewsAdapter.java    License: Apache License 2.0 6 votes vote down vote up
private void loadDate() {
    Subscription subscription = JDApi.getFreshNews(page)
            .observeOn(Schedulers.io())
            .doOnNext(freshNewses -> {
                if (page == 1) {
                    mFreshNews.clear();
                    FreshNewsCache.getInstance(mActivity).clearAllCache();
                }
                FreshNewsCache.getInstance(mActivity).addResultCache(GsonHelper.toString(freshNewses),
                        page);
            })
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(freshNewses -> {
                mFreshNews.addAll(freshNewses);
                notifyDataSetChanged();
                mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
                mLoadFinisCallBack.loadFinish(null);
            }, e -> {
                mLoadResultCallBack.onError(LoadResultCallBack.ERROR_NET);
                mLoadFinisCallBack.loadFinish(null);
            });
    mActivity.addSubscription(subscription);
}
 
Example 8
Source Project: JianDanRxJava   Source File: FreshNewsAdapter.java    License: Apache License 2.0 6 votes vote down vote up
private void loadFromCache() {
    Observable.create(new Observable.OnSubscribe<ArrayList<FreshNews>>() {
        @Override
        public void call(Subscriber<? super ArrayList<FreshNews>> subscriber) {
            subscriber.onNext(FreshNewsCache.getInstance(mActivity).getCacheByPage(page));
            subscriber.onCompleted();
        }
    }).compose(JDApi.applySchedulers())
            .doOnNext(freshNewses -> {
                if (page == 1) {
                    mFreshNews.clear();
                    ToastHelper.Short(ConstantString.LOAD_NO_NETWORK);
                }
            })
            .subscribe(freshNewses -> {
                mFreshNews.addAll(freshNewses);
                notifyDataSetChanged();
                mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
                mLoadFinisCallBack.loadFinish(null);
            });
}
 
Example 9
Source Project: JianDanRxJava   Source File: VideoAdapter.java    License: Apache License 2.0 6 votes vote down vote up
private void loadCache() {
    Subscription subscription = Observable.create((Observable.OnSubscribe<ArrayList<Video>>) subscriber -> {
        subscriber.onNext(VideoCache.getInstance(mActivity).getCacheByPage(page));
        subscriber.onCompleted();
    }).compose(JDApi.applySchedulers())
            .doOnNext(videos -> {
                if (page == 1) {
                    mVideos.clear();
                    ToastHelper.Short(ConstantString.LOAD_NO_NETWORK);
                }
            })
            .subscribe(videos -> {
                mVideos.addAll(videos);
                notifyDataSetChanged();
                mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
                mLoadFinisCallBack.loadFinish(null);
            });
    mActivity.addSubscription(subscription);
}
 
Example 10
Source Project: JianDanRxJava   Source File: CommentAdapter.java    License: Apache License 2.0 6 votes vote down vote up
public void loadData() {
    Subscription subscriptions = JDApi.getCommentator(mThread_key, obj -> thread_id = (String) obj)
            .subscribe(commentators1 -> {
                if (commentators1.size() == 0) {
                    mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_NONE, null);
                } else {
                    mCommentators.clear();
                    Commentator.generateCommentator(commentators1, mCommentators);
                    notifyDataSetChanged();
                    mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
                }
            }, e -> {
                mLoadResultCallBack.onError(LoadResultCallBack.ERROR_NET);
            });
    mActivity.addSubscription(subscriptions);
}
 
Example 11
Source Project: JianDan_OkHttpWithVolley   Source File: JokeAdapter.java    License: Apache License 2.0 5 votes vote down vote up
private void loadCache() {
    mLoadFinisCallBack.loadFinish(null);
    mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
    JokeCache jokeCacheUtil = JokeCache.getInstance(mActivity);
    if (page == 1) {
        mJokes.clear();
        ShowToast.Short(ConstantString.LOAD_NO_NETWORK);
    }
    mJokes.addAll(jokeCacheUtil.getCacheByPage(page));
    notifyDataSetChanged();
}
 
Example 12
Source Project: JianDan_OkHttpWithVolley   Source File: PictureAdapter.java    License: Apache License 2.0 5 votes vote down vote up
public PictureAdapter(Activity activity, LoadResultCallBack loadResultCallBack, LoadFinishCallBack loadFinisCallBack, Picture.PictureType type) {
    mActivity = activity;
    mType = type;
    mLoadFinisCallBack = loadFinisCallBack;
    mLoadResultCallBack = loadResultCallBack;
    pictures = new ArrayList<>();
    isWifiConnected = NetWorkUtil.isWifiConnected(mActivity);
}
 
Example 13
Source Project: JianDan_OkHttpWithVolley   Source File: PictureAdapter.java    License: Apache License 2.0 5 votes vote down vote up
private void loadCache() {

        mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
        mLoadFinisCallBack.loadFinish(null);
        PictureCache pictureCacheUtil = PictureCache.getInstance(mActivity);
        if (page == 1) {
            pictures.clear();
            ShowToast.Short(ConstantString.LOAD_NO_NETWORK);
        }
        pictures.addAll(pictureCacheUtil.getCacheByPage(page));
        notifyDataSetChanged();

    }
 
Example 14
Source Project: JianDan_OkHttpWithVolley   Source File: PictureAdapter.java    License: Apache License 2.0 5 votes vote down vote up
private void getCommentCounts(final ArrayList<Picture> pictures) {

        StringBuilder sb = new StringBuilder();
        for (Picture joke : pictures) {
            sb.append("comment-" + joke.getComment_ID() + ",");
        }

        RequestManager.addRequest(new Request4CommentCounts(CommentNumber.getCommentCountsURL(sb.toString()), new Response
                .Listener<ArrayList<CommentNumber>>() {

            @Override
            public void onResponse(ArrayList<CommentNumber> response) {

                mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
                mLoadFinisCallBack.loadFinish(null);

                for (int i = 0; i < pictures.size(); i++) {
                    pictures.get(i).setComment_counts(response.get(i).getComments() + "");
                }
                if (page == 1) {
                    PictureAdapter.this.pictures.clear();
                    PictureCache.getInstance(mActivity).clearAllCache();
                }
                PictureAdapter.this.pictures.addAll(pictures);
                notifyDataSetChanged();
                //加载完毕后缓存
                PictureCache.getInstance(mActivity).addResultCache(JSONParser.toString
                        (pictures), page);
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                ShowToast.Short(ConstantString.LOAD_FAILED);
                mLoadFinisCallBack.loadFinish(null);
                mLoadResultCallBack.onError(LoadResultCallBack.ERROR_NET, error.getMessage());
            }
        }
        ), mActivity);
    }
 
Example 15
Source Project: JianDan_OkHttpWithVolley   Source File: FreshNewsAdapter.java    License: Apache License 2.0 5 votes vote down vote up
public FreshNewsAdapter(Activity activity, LoadFinishCallBack loadFinisCallBack, LoadResultCallBack loadResultCallBack, boolean isLargeMode) {
    this.mActivity = activity;
    this.isLargeMode = isLargeMode;
    this.mLoadFinisCallBack = loadFinisCallBack;
    this.mLoadResultCallBack = loadResultCallBack;
    mFreshNews = new ArrayList<>();

    int loadingResource = isLargeMode ? R.drawable.ic_loading_large : R.drawable.ic_loading_small;
    options = ImageLoadProxy.getOptions4PictureList(loadingResource);
}
 
Example 16
Source Project: JianDan_OkHttpWithVolley   Source File: VideoAdapter.java    License: Apache License 2.0 5 votes vote down vote up
private void loadCache() {

        mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
        mLoadFinisCallBack.loadFinish(null);
        VideoCache videoCacheUtil = VideoCache.getInstance(mActivity);
        if (page == 1) {
            mVideos.clear();
            ShowToast.Short(ConstantString.LOAD_NO_NETWORK);
        }
        mVideos.addAll(videoCacheUtil.getCacheByPage(page));
        notifyDataSetChanged();

    }
 
Example 17
Source Project: JianDan_OkHttpWithVolley   Source File: CommentAdapter.java    License: Apache License 2.0 5 votes vote down vote up
public CommentAdapter(Activity activity, String thread_key, boolean isFromFreshNews, LoadResultCallBack loadResultCallBack) {
    mActivity = activity;
    this.thread_key = thread_key;
    this.isFromFreshNews = isFromFreshNews;
    mLoadResultCallBack = loadResultCallBack;
    if (isFromFreshNews) {
        commentators4FreshNews = new ArrayList<>();
    } else {
        commentators = new ArrayList<>();
    }
}
 
Example 18
@Override
public void onSuccess(int result, Object object) {
    if (result == LoadResultCallBack.SUCCESS_NONE) {
        ShowToast.Short(NO_COMMENTS);
    }
    loading.stop();
    mSwipeRefreshLayout.setRefreshing(false);
}
 
Example 19
Source Project: JianDan   Source File: JokeAdapter.java    License: Apache License 2.0 5 votes vote down vote up
private void loadCache() {
    mLoadFinisCallBack.loadFinish(null);
    mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
    JokeCache jokeCacheUtil = JokeCache.getInstance(mActivity);
    if (page == 1) {
        mJokes.clear();
        ShowToast.Short(ConstantString.LOAD_NO_NETWORK);
    }
    mJokes.addAll(jokeCacheUtil.getCacheByPage(page));
    notifyDataSetChanged();
}
 
Example 20
Source Project: JianDan   Source File: PictureAdapter.java    License: Apache License 2.0 5 votes vote down vote up
public PictureAdapter(Activity activity, LoadResultCallBack loadResultCallBack, LoadFinishCallBack loadFinisCallBack, Picture.PictureType type) {
    mActivity = activity;
    mType = type;
    mLoadFinisCallBack = loadFinisCallBack;
    mLoadResultCallBack = loadResultCallBack;
    pictures = new ArrayList<>();
    isWifiConnected = NetWorkUtil.isWifiConnected(mActivity);
}
 
Example 21
Source Project: JianDan   Source File: PictureAdapter.java    License: Apache License 2.0 5 votes vote down vote up
private void loadCache() {

        mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
        mLoadFinisCallBack.loadFinish(null);
        PictureCache pictureCacheUtil = PictureCache.getInstance(mActivity);
        if (page == 1) {
            pictures.clear();
            ShowToast.Short(ConstantString.LOAD_NO_NETWORK);
        }
        pictures.addAll(pictureCacheUtil.getCacheByPage(page));
        notifyDataSetChanged();

    }
 
Example 22
Source Project: JianDan   Source File: PictureAdapter.java    License: Apache License 2.0 5 votes vote down vote up
private void getCommentCounts(final ArrayList<Picture> pictures) {

        StringBuilder sb = new StringBuilder();
        for (Picture joke : pictures) {
            sb.append("comment-" + joke.getComment_ID() + ",");
        }

        RequestManager.addRequest(new Request4CommentCounts(CommentNumber.getCommentCountsURL(sb.toString()), new Response
                .Listener<ArrayList<CommentNumber>>() {

            @Override
            public void onResponse(ArrayList<CommentNumber> response) {

                mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
                mLoadFinisCallBack.loadFinish(null);

                for (int i = 0; i < pictures.size(); i++) {
                    pictures.get(i).setComment_counts(response.get(i).getComments() + "");
                }
                if (page == 1) {
                    PictureAdapter.this.pictures.clear();
                    PictureCache.getInstance(mActivity).clearAllCache();
                }
                PictureAdapter.this.pictures.addAll(pictures);
                notifyDataSetChanged();
                //加载完毕后缓存
                PictureCache.getInstance(mActivity).addResultCache(JSONParser.toString
                        (pictures), page);
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                ShowToast.Short(ConstantString.LOAD_FAILED);
                mLoadFinisCallBack.loadFinish(null);
                mLoadResultCallBack.onError(LoadResultCallBack.ERROR_NET, error.getMessage());
            }
        }
        ), mActivity);
    }
 
Example 23
Source Project: JianDan   Source File: FreshNewsAdapter.java    License: Apache License 2.0 5 votes vote down vote up
public FreshNewsAdapter(Activity activity, LoadFinishCallBack loadFinisCallBack, LoadResultCallBack loadResultCallBack, boolean isLargeMode) {
    this.mActivity = activity;
    this.isLargeMode = isLargeMode;
    this.mLoadFinisCallBack = loadFinisCallBack;
    this.mLoadResultCallBack = loadResultCallBack;
    mFreshNews = new ArrayList<>();

    int loadingResource = isLargeMode ? R.drawable.ic_loading_large : R.drawable.ic_loading_small;
    options = ImageLoadProxy.getOptions4PictureList(loadingResource);
}
 
Example 24
Source Project: JianDan   Source File: VideoAdapter.java    License: Apache License 2.0 5 votes vote down vote up
private void loadCache() {

        mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
        mLoadFinisCallBack.loadFinish(null);
        VideoCache videoCacheUtil = VideoCache.getInstance(mActivity);
        if (page == 1) {
            mVideos.clear();
            ShowToast.Short(ConstantString.LOAD_NO_NETWORK);
        }
        mVideos.addAll(videoCacheUtil.getCacheByPage(page));
        notifyDataSetChanged();

    }
 
Example 25
Source Project: JianDan   Source File: CommentAdapter.java    License: Apache License 2.0 5 votes vote down vote up
public CommentAdapter(Activity activity, String thread_key, boolean isFromFreshNews, LoadResultCallBack loadResultCallBack) {
    mActivity = activity;
    this.thread_key = thread_key;
    this.isFromFreshNews = isFromFreshNews;
    mLoadResultCallBack = loadResultCallBack;
    if (isFromFreshNews) {
        commentators4FreshNews = new ArrayList<>();
    } else {
        commentators = new ArrayList<>();
    }
}
 
Example 26
Source Project: JianDan   Source File: CommentListActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onSuccess(int result, Object object) {
    if (result == LoadResultCallBack.SUCCESS_NONE) {
        ShowToast.Short(NO_COMMENTS);
    }
    loading.stop();
    mSwipeRefreshLayout.setRefreshing(false);
}
 
Example 27
Source Project: JianDanRxJava   Source File: JokeAdapter.java    License: Apache License 2.0 5 votes vote down vote up
private void getCommentCounts(final ArrayList<Joke> jokes) {

        StringBuilder sb = new StringBuilder();
        for (Joke joke : jokes) {
            sb.append("comment-" + joke.getComment_ID() + ",");
        }

        String url = sb.toString();
        if (url.endsWith(",")) {
            url = url.substring(0, url.length() - 1);
        }

        JDApi.getCommentNumber(url)
                .observeOn(Schedulers.io())
                .doOnNext(commentNumbers -> {
                    if (page == 1) {
                        mJokes.clear();
                        JokeCache.getInstance(mActivity).clearAllCache();
                    }
                    JokeCache.getInstance(mActivity).addResultCache(GsonHelper.toString(jokes), page);
                })
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(commentNumbers -> {
                    for (int i = 0; i < jokes.size(); i++) {
                        jokes.get(i).setComment_counts(commentNumbers.get(i).comments + "");
                    }
                    mJokes.addAll(jokes);
                    notifyDataSetChanged();
                    mLoadFinisCallBack.loadFinish(null);
                    mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
                }, e -> {
                    mLoadResultCallBack.onError(LoadResultCallBack.ERROR_NET);
                    mLoadFinisCallBack.loadFinish(null);
                    KLog.e(e);
                });
    }
 
Example 28
Source Project: JianDanRxJava   Source File: PictureAdapter.java    License: Apache License 2.0 5 votes vote down vote up
public PictureAdapter(BaseActivity activity, LoadResultCallBack loadResultCallBack, LoadFinishCallBack<Object> loadFinisCallBack, int type) {
    mActivity = activity;
    mType = type;
    mLoadFinisCallBack = loadFinisCallBack;
    mLoadResultCallBack = loadResultCallBack;
    mPictures = new ArrayList<>();
    isWifiConnected = NetWorkUtil.isWifiConnected(mActivity);
}
 
Example 29
Source Project: JianDanRxJava   Source File: FreshNewsAdapter.java    License: Apache License 2.0 5 votes vote down vote up
public FreshNewsAdapter(BaseActivity activity, LoadFinishCallBack<Object> loadFinisCallBack, LoadResultCallBack loadResultCallBack) {
    this.mActivity = activity;
    this.isLargeMode = SPHelper.getBoolean(SettingFragment.ENABLE_FRESH_BIG, true);
    this.mLoadFinisCallBack = loadFinisCallBack;
    this.mLoadResultCallBack = loadResultCallBack;
    mFreshNews = new ArrayList<>();

    int loadingResource = isLargeMode ? R.drawable.ic_loading_large : R.drawable.ic_loading_small;
    options = ImageLoadProxy.getOptions4PictureList(loadingResource);
}
 
Example 30
Source Project: JianDanRxJava   Source File: VideoAdapter.java    License: Apache License 2.0 5 votes vote down vote up
private void getCommentCounts(final ArrayList<Video> videos) {

        StringBuilder sb = new StringBuilder();
        for (Video video : videos) {
            sb.append("comment-" + video.getComment_ID() + ",");
        }

        Subscription subscription = JDApi.getCommentNumber(sb.toString())
                .observeOn(Schedulers.io())
                .doOnNext(commentNumbers -> {
                    if (page == 1) {
                        mVideos.clear();
                        VideoCache.getInstance(mActivity).clearAllCache();
                    }
                    VideoCache.getInstance(mActivity).addResultCache(GsonHelper.toString
                            (videos), page);
                })
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(commentNumbers -> {

                    for (int i = 0; i < videos.size(); i++) {
                        videos.get(i).setComment_count(commentNumbers.get(i).comments + "");
                    }

                    mVideos.addAll(videos);
                    notifyDataSetChanged();

                    if (mVideos.size() < 10) {
                        loadNextPage();
                    }
                    mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
                    mLoadFinisCallBack.loadFinish(null);
                }, e -> {
                    mLoadFinisCallBack.loadFinish(e);
                    mLoadResultCallBack.onError(LoadResultCallBack.ERROR_NET);
                });
        mActivity.addSubscription(subscription);
    }