com.socks.jiandan.callback.LoadResultCallBack Java Examples
The following examples show how to use
com.socks.jiandan.callback.LoadResultCallBack.
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 File: JokeAdapter.java From JianDanRxJava with Apache License 2.0 | 6 votes |
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 #2
Source File: PictureAdapter.java From JianDan_OkHttpWithVolley with Apache License 2.0 | 6 votes |
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 File: PictureAdapter.java From JianDanRxJava with Apache License 2.0 | 6 votes |
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 #4
Source File: PictureAdapter.java From JianDanRxJava with Apache License 2.0 | 6 votes |
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 #5
Source File: PictureAdapter.java From JianDan with Apache License 2.0 | 6 votes |
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 #6
Source File: PictureAdapter.java From JianDanRxJava with Apache License 2.0 | 6 votes |
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 File: CommentAdapter.java From JianDanRxJava with Apache License 2.0 | 6 votes |
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 #8
Source File: FreshNewsAdapter.java From JianDanRxJava with Apache License 2.0 | 6 votes |
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 #9
Source File: VideoAdapter.java From JianDanRxJava with Apache License 2.0 | 6 votes |
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 File: FreshNewsAdapter.java From JianDanRxJava with Apache License 2.0 | 6 votes |
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 #11
Source File: VideoAdapter.java From JianDanRxJava with Apache License 2.0 | 5 votes |
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); }
Example #12
Source File: CommentAdapter.java From JianDan with Apache License 2.0 | 5 votes |
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 #13
Source File: CommentListActivity.java From JianDan with Apache License 2.0 | 5 votes |
@Override public void onSuccess(int result, Object object) { if (result == LoadResultCallBack.SUCCESS_NONE) { ShowToast.Short(NO_COMMENTS); } loading.stop(); mSwipeRefreshLayout.setRefreshing(false); }
Example #14
Source File: JokeAdapter.java From JianDanRxJava with Apache License 2.0 | 5 votes |
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 #15
Source File: PictureAdapter.java From JianDanRxJava with Apache License 2.0 | 5 votes |
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 #16
Source File: FreshNewsAdapter.java From JianDanRxJava with Apache License 2.0 | 5 votes |
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 #17
Source File: JokeAdapter.java From JianDan_OkHttpWithVolley with Apache License 2.0 | 5 votes |
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 #18
Source File: CommentAdapter.java From JianDanRxJava with Apache License 2.0 | 5 votes |
public CommentAdapter(BaseActivity activity, String thread_key, boolean isFromFreshNews, LoadResultCallBack loadResultCallBack) { mActivity = activity; mThread_key = thread_key; mIsFromFreshNews = isFromFreshNews; mLoadResultCallBack = loadResultCallBack; if (mIsFromFreshNews) { mCommentators4FreshNews = new ArrayList<>(); } else { mCommentators = new ArrayList<>(); } }
Example #19
Source File: CommentAdapter.java From JianDanRxJava with Apache License 2.0 | 5 votes |
public void loadData4FreshNews() { Subscription subscriptions = JDApi.getCommentator4FreshNews(mThread_key, obj -> thread_id = (String) obj) .subscribe(comment4FreshNewses -> { if (comment4FreshNewses.size() == 0) { mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_NONE, null); } else { Comment4FreshNews.generateComment(comment4FreshNewses, mCommentators4FreshNews); notifyDataSetChanged(); mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null); } }, e -> { mLoadResultCallBack.onError(LoadResultCallBack.ERROR_NET); }); mActivity.addSubscription(subscriptions); }
Example #20
Source File: CommentListActivity.java From JianDanRxJava with Apache License 2.0 | 5 votes |
@Override public void onSuccess(int result, Object object) { if (result == LoadResultCallBack.SUCCESS_NONE) { ToastHelper.Short(NO_COMMENTS); } loading.stop(); mSwipeRefreshLayout.setRefreshing(false); }
Example #21
Source File: JokeAdapter.java From JianDan_OkHttp with Apache License 2.0 | 5 votes |
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 #22
Source File: PictureAdapter.java From JianDan_OkHttp with Apache License 2.0 | 5 votes |
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 #23
Source File: PictureAdapter.java From JianDan_OkHttp with Apache License 2.0 | 5 votes |
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 #24
Source File: FreshNewsAdapter.java From JianDan_OkHttp with Apache License 2.0 | 5 votes |
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 #25
Source File: VideoAdapter.java From JianDan_OkHttp with Apache License 2.0 | 5 votes |
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 #26
Source File: CommentAdapter.java From JianDan_OkHttp with Apache License 2.0 | 5 votes |
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 #27
Source File: CommentListActivity.java From JianDan_OkHttp with Apache License 2.0 | 5 votes |
@Override public void onSuccess(int result, Object object) { if (result == LoadResultCallBack.SUCCESS_NONE) { ShowToast.Short(NO_COMMENTS); } loading.stop(); mSwipeRefreshLayout.setRefreshing(false); }
Example #28
Source File: PictureAdapter.java From JianDan with Apache License 2.0 | 5 votes |
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 #29
Source File: VideoAdapter.java From JianDan_OkHttpWithVolley with Apache License 2.0 | 5 votes |
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 #30
Source File: CommentAdapter.java From JianDan_OkHttpWithVolley with Apache License 2.0 | 5 votes |
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<>(); } }