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

The following examples show how to use com.socks.jiandan.callback.LoadFinishCallBack. 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: JianDanRxJava   Source File: JDApi.java    License: Apache License 2.0 6 votes vote down vote up
public static Observable<ArrayList<Comment4FreshNews>> getCommentator4FreshNews(final String thread_key, LoadFinishCallBack callBack) {

        return Observable.create(new Observable.OnSubscribe<ArrayList<Comment4FreshNews>>() {

            @Override
            public void call(Subscriber<? super ArrayList<Comment4FreshNews>> subscriber) {
                String url = Comment4FreshNews.getUrlComments(thread_key);
                try {
                    subscriber.onNext(new FreshNewsCommentParser(callBack).parse(OkHttpProxy.get()
                            .url(url)
                            .execute()));
                    subscriber.onCompleted();
                } catch (IOException e) {
                    subscriber.onError(e);
                }
            }
        }).compose(applySchedulers());
    }
 
Example 2
Source Project: JianDanRxJava   Source File: JDApi.java    License: Apache License 2.0 6 votes vote down vote up
public static Observable<ArrayList<Commentator>> getCommentator(final String thread_key, LoadFinishCallBack callBack) {

        return Observable.create(new Observable.OnSubscribe<ArrayList<Commentator>>() {

            @Override
            public void call(Subscriber<? super ArrayList<Commentator>> subscriber) {
                String url = Commentator.getUrlCommentList(thread_key);
                try {
                    subscriber.onNext(new CommentListParser(callBack).parse(OkHttpProxy.get()
                            .url(url)
                            .execute()));
                    subscriber.onCompleted();
                } catch (IOException e) {
                    subscriber.onError(e);
                }
            }
        }).compose(applySchedulers());
    }
 
Example 3
Source Project: JianDan_OkHttpWithVolley   Source File: FileUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 保存图片
 *
 * @param activity
 * @param picUrl
 */
public static void savePicture(Activity activity, String picUrl, LoadFinishCallBack loadFinishCallBack) {

    boolean isSmallPic = false;
    String[] urls = picUrl.split("\\.");
    File cacheFile = ImageLoader.getInstance().getDiskCache().get(picUrl);

    //如果是GIF格式,优先保存GIF动态图,如果不存在,则保存缩略图
    if (!cacheFile.exists()) {
        String cacheUrl = picUrl.replace("mw600", "small").replace("mw1200", "small")
                .replace("large", "small");
        cacheFile = ImageLoader.getInstance().getDiskCache().get(cacheUrl);
        isSmallPic = true;
    }

    File picDir = new File(CacheUtil.getSaveDirPath());

    if (!picDir.exists()) {
        picDir.mkdir();
    }

    final File newFile = new File(picDir, CacheUtil.getSavePicName(cacheFile, urls));

    if (FileUtil.copyTo(cacheFile, newFile)) {
        Bundle bundle = new Bundle();
        bundle.putBoolean(BaseActivity.DATA_IS_SIAMLL_PIC, isSmallPic);
        bundle.putString(BaseActivity.DATA_FILE_PATH, newFile.getAbsolutePath());
        loadFinishCallBack.loadFinish(bundle);
    } else {
        ShowToast.Short(ConstantString.SAVE_FAILED);
    }

}
 
Example 4
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 5
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 6
public Request4CommentList(String url, Response
        .Listener<ArrayList<Commentator>> listener,
                           Response.ErrorListener errorListener, LoadFinishCallBack callBack) {
    super(Method.GET, url, errorListener);
    this.listener = listener;
    this.callBack = callBack;
}
 
Example 7
Source Project: JianDan   Source File: FileUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 保存图片
 *
 * @param activity
 * @param picUrl
 */
public static void savePicture(Activity activity, String picUrl, LoadFinishCallBack loadFinishCallBack) {

    boolean isSmallPic = false;
    String[] urls = picUrl.split("\\.");
    File cacheFile = ImageLoader.getInstance().getDiskCache().get(picUrl);

    //如果是GIF格式,优先保存GIF动态图,如果不存在,则保存缩略图
    if (!cacheFile.exists()) {
        String cacheUrl = picUrl.replace("mw600", "small").replace("mw1200", "small")
                .replace("large", "small");
        cacheFile = ImageLoader.getInstance().getDiskCache().get(cacheUrl);
        isSmallPic = true;
    }

    File picDir = new File(CacheUtil.getSaveDirPath());

    if (!picDir.exists()) {
        picDir.mkdir();
    }

    final File newFile = new File(picDir, CacheUtil.getSavePicName(cacheFile, urls));

    if (FileUtil.copyTo(cacheFile, newFile)) {
        Bundle bundle = new Bundle();
        bundle.putBoolean(BaseActivity.DATA_IS_SIAMLL_PIC, isSmallPic);
        bundle.putString(BaseActivity.DATA_FILE_PATH, newFile.getAbsolutePath());
        loadFinishCallBack.loadFinish(bundle);
    } else {
        ShowToast.Short(ConstantString.SAVE_FAILED);
    }

}
 
Example 8
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 9
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 10
Source Project: JianDan   Source File: Request4CommentList.java    License: Apache License 2.0 5 votes vote down vote up
public Request4CommentList(String url, Response
        .Listener<ArrayList<Commentator>> listener,
                           Response.ErrorListener errorListener, LoadFinishCallBack callBack) {
    super(Method.GET, url, errorListener);
    this.listener = listener;
    this.callBack = callBack;
}
 
Example 11
Source Project: JianDanRxJava   Source File: FileUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static void savePicture(String picUrl, LoadFinishCallBack<Bundle> loadFinishCallBack) {

        boolean isSmallPic = false;
        String[] urls = picUrl.split("\\.");
        File cacheFile = ImageLoader.getInstance().getDiskCache().get(picUrl);

        //如果是GIF格式,优先保存GIF动态图,如果不存在,则保存缩略图
        if (!cacheFile.exists()) {
            String cacheUrl = picUrl.replace("mw600", "small").replace("mw1200", "small")
                    .replace("large", "small");
            cacheFile = ImageLoader.getInstance().getDiskCache().get(cacheUrl);
            isSmallPic = true;
        }

        File picDir = new File(CacheUtil.getSaveDirPath());

        if (!picDir.exists()) {

            if (picDir.mkdir()) {
                final File newFile = new File(picDir, CacheUtil.getSavePicName(cacheFile, urls));
                if (FileUtil.copyTo(cacheFile, newFile)) {
                    Bundle bundle = new Bundle();
                    bundle.putBoolean(BaseActivity.DATA_IS_SMALL_PIC, isSmallPic);
                    bundle.putString(BaseActivity.DATA_FILE_PATH, newFile.getAbsolutePath());
                    loadFinishCallBack.loadFinish(bundle);
                } else {
                    ToastHelper.Short(ConstantString.SAVE_FAILED);
                }
            }
        }
    }
 
Example 12
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 13
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 14
Source Project: JianDan_OkHttp   Source File: FileUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 保存图片
 *
 * @param activity
 * @param picUrl
 */
public static void savePicture(Activity activity, String picUrl, LoadFinishCallBack loadFinishCallBack) {

    boolean isSmallPic = false;
    String[] urls = picUrl.split("\\.");
    File cacheFile = ImageLoader.getInstance().getDiskCache().get(picUrl);

    //如果是GIF格式,优先保存GIF动态图,如果不存在,则保存缩略图
    if (!cacheFile.exists()) {
        String cacheUrl = picUrl.replace("mw600", "small").replace("mw1200", "small")
                .replace("large", "small");
        cacheFile = ImageLoader.getInstance().getDiskCache().get(cacheUrl);
        isSmallPic = true;
    }

    File picDir = new File(CacheUtil.getSaveDirPath());

    if (!picDir.exists()) {
        picDir.mkdir();
    }

    final File newFile = new File(picDir, CacheUtil.getSavePicName(cacheFile, urls));

    if (FileUtil.copyTo(cacheFile, newFile)) {
        Bundle bundle = new Bundle();
        bundle.putBoolean(BaseActivity.DATA_IS_SIAMLL_PIC, isSmallPic);
        bundle.putString(BaseActivity.DATA_FILE_PATH, newFile.getAbsolutePath());
        loadFinishCallBack.loadFinish(bundle);
    } else {
        ShowToast.Short(ConstantString.SAVE_FAILED);
    }

}
 
Example 15
Source Project: JianDan_OkHttp   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 16
Source Project: JianDan_OkHttp   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 17
Source Project: JianDan_OkHttp   Source File: Request4CommentList.java    License: Apache License 2.0 5 votes vote down vote up
public Request4CommentList(String url, Response
        .Listener<ArrayList<Commentator>> listener,
                           Response.ErrorListener errorListener, LoadFinishCallBack callBack) {
    super(Method.GET, url, errorListener);
    this.listener = listener;
    this.callBack = callBack;
}
 
Example 18
Source Project: JianDan_OkHttpWithVolley   Source File: JokeAdapter.java    License: Apache License 2.0 4 votes vote down vote up
public JokeAdapter(Activity activity, LoadFinishCallBack loadFinisCallBack, LoadResultCallBack loadResultCallBack) {
    mActivity = activity;
    mLoadFinisCallBack = loadFinisCallBack;
    mLoadResultCallBack = loadResultCallBack;
    mJokes = new ArrayList<>();
}
 
Example 19
Source Project: JianDan_OkHttpWithVolley   Source File: PictureAdapter.java    License: Apache License 2.0 4 votes vote down vote up
public void setmSaveFileCallBack(LoadFinishCallBack mSaveFileCallBack) {
    this.mSaveFileCallBack = mSaveFileCallBack;
}
 
Example 20
Source Project: JianDan_OkHttpWithVolley   Source File: VideoAdapter.java    License: Apache License 2.0 4 votes vote down vote up
public VideoAdapter(Activity activity, LoadResultCallBack loadResultCallBack, LoadFinishCallBack loadFinisCallBack) {
    mActivity = activity;
    mLoadFinisCallBack = loadFinisCallBack;
    mLoadResultCallBack = loadResultCallBack;
    mVideos = new ArrayList<>();
}
 
Example 21
Source Project: JianDan_OkHttpWithVolley   Source File: CommentAdapter.java    License: Apache License 2.0 4 votes vote down vote up
public void loadData() {
    RequestManager.addRequest(new Request4CommentList(Commentator.getUrlCommentList(thread_key), new Response
            .Listener<ArrayList<Commentator>>() {
        @Override
        public void onResponse(ArrayList<Commentator> response) {

            if (response.size() == 0) {
                mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_NONE, null);
            } else {
                commentators.clear();

                ArrayList<Commentator> hotCommentator = new ArrayList<>();
                ArrayList<Commentator> normalComment = new ArrayList<>();

                //添加热门评论
                for (Commentator commentator : response) {
                    if (commentator.getTag().equals(Commentator.TAG_HOT)) {
                        hotCommentator.add(commentator);
                    } else {
                        normalComment.add(commentator);
                    }
                }

                //添加热门评论标签
                if (hotCommentator.size() != 0) {
                    Collections.sort(hotCommentator);
                    Commentator hotCommentFlag = new Commentator();
                    hotCommentFlag.setType(Commentator.TYPE_HOT);
                    hotCommentator.add(0, hotCommentFlag);
                    commentators.addAll(hotCommentator);
                }

                //添加最新评论及标签
                if (normalComment.size() != 0) {
                    Commentator newCommentFlag = new Commentator();
                    newCommentFlag.setType(Commentator.TYPE_NEW);
                    commentators.add(newCommentFlag);
                    Collections.sort(normalComment);
                    commentators.addAll(normalComment);
                }

                notifyDataSetChanged();
                mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
            }
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            mLoadResultCallBack.onError(LoadResultCallBack.ERROR_NET, error.getMessage());
        }
    }, new LoadFinishCallBack() {
        @Override
        public void loadFinish(Object obj) {
            thread_id = (String) obj;
        }
    }), mActivity);
}
 
Example 22
public Request4FreshNewsCommentList(String url, Response.Listener<ArrayList<Comment4FreshNews>> listener,
                                    Response.ErrorListener errorListener, LoadFinishCallBack callBack) {
    super(Method.GET, url, errorListener);
    mListener = listener;
    mCallBack = callBack;
}
 
Example 23
Source Project: JianDan   Source File: JokeAdapter.java    License: Apache License 2.0 4 votes vote down vote up
public JokeAdapter(Activity activity, LoadFinishCallBack loadFinisCallBack, LoadResultCallBack loadResultCallBack) {
    mActivity = activity;
    mLoadFinisCallBack = loadFinisCallBack;
    mLoadResultCallBack = loadResultCallBack;
    mJokes = new ArrayList<>();
}
 
Example 24
Source Project: JianDan   Source File: PictureAdapter.java    License: Apache License 2.0 4 votes vote down vote up
public void setmSaveFileCallBack(LoadFinishCallBack mSaveFileCallBack) {
    this.mSaveFileCallBack = mSaveFileCallBack;
}
 
Example 25
Source Project: JianDan   Source File: VideoAdapter.java    License: Apache License 2.0 4 votes vote down vote up
public VideoAdapter(Activity activity, LoadResultCallBack loadResultCallBack, LoadFinishCallBack loadFinisCallBack) {
    mActivity = activity;
    mLoadFinisCallBack = loadFinisCallBack;
    mLoadResultCallBack = loadResultCallBack;
    mVideos = new ArrayList<>();
}
 
Example 26
Source Project: JianDan   Source File: CommentAdapter.java    License: Apache License 2.0 4 votes vote down vote up
public void loadData() {
    RequestManager.addRequest(new Request4CommentList(Commentator.getUrlCommentList(thread_key), new Response
            .Listener<ArrayList<Commentator>>() {
        @Override
        public void onResponse(ArrayList<Commentator> response) {

            if (response.size() == 0) {
                mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_NONE, null);
            } else {
                commentators.clear();

                ArrayList<Commentator> hotCommentator = new ArrayList<>();
                ArrayList<Commentator> normalComment = new ArrayList<>();

                //添加热门评论
                for (Commentator commentator : response) {
                    if (commentator.getTag().equals(Commentator.TAG_HOT)) {
                        hotCommentator.add(commentator);
                    } else {
                        normalComment.add(commentator);
                    }
                }

                //添加热门评论标签
                if (hotCommentator.size() != 0) {
                    Collections.sort(hotCommentator);
                    Commentator hotCommentFlag = new Commentator();
                    hotCommentFlag.setType(Commentator.TYPE_HOT);
                    hotCommentator.add(0, hotCommentFlag);
                    commentators.addAll(hotCommentator);
                }

                //添加最新评论及标签
                if (normalComment.size() != 0) {
                    Commentator newCommentFlag = new Commentator();
                    newCommentFlag.setType(Commentator.TYPE_NEW);
                    commentators.add(newCommentFlag);
                    Collections.sort(normalComment);
                    commentators.addAll(normalComment);
                }

                notifyDataSetChanged();
                mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
            }
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            mLoadResultCallBack.onError(LoadResultCallBack.ERROR_NET, error.getMessage());
        }
    }, new LoadFinishCallBack() {
        @Override
        public void loadFinish(Object obj) {
            thread_id = (String) obj;
        }
    }), mActivity);
}
 
Example 27
Source Project: JianDan   Source File: Request4FreshNewsCommentList.java    License: Apache License 2.0 4 votes vote down vote up
public Request4FreshNewsCommentList(String url, Response.Listener<ArrayList<Comment4FreshNews>> listener,
                                    Response.ErrorListener errorListener, LoadFinishCallBack callBack) {
    super(Method.GET, url, errorListener);
    mListener = listener;
    mCallBack = callBack;
}
 
Example 28
Source Project: JianDanRxJava   Source File: JokeAdapter.java    License: Apache License 2.0 4 votes vote down vote up
public JokeAdapter(BaseActivity activity, LoadFinishCallBack<Object> loadFinisCallBack, LoadResultCallBack loadResultCallBack) {
    mActivity = activity;
    mLoadFinisCallBack = loadFinisCallBack;
    mLoadResultCallBack = loadResultCallBack;
    mJokes = new ArrayList<>();
}
 
Example 29
Source Project: JianDanRxJava   Source File: PictureAdapter.java    License: Apache License 2.0 4 votes vote down vote up
public void setSaveFileCallBack(LoadFinishCallBack mSaveFileCallBack) {
    this.mSaveFileCallBack = mSaveFileCallBack;
}
 
Example 30
Source Project: JianDanRxJava   Source File: VideoAdapter.java    License: Apache License 2.0 4 votes vote down vote up
public VideoAdapter(BaseActivity activity, LoadResultCallBack loadResultCallBack, LoadFinishCallBack<Object> loadFinisCallBack) {
    mActivity = activity;
    mLoadFinisCallBack = loadFinisCallBack;
    mLoadResultCallBack = loadResultCallBack;
    mVideos = new ArrayList<>();
}