com.socks.jiandan.base.ConstantString Java Examples

The following examples show how to use com.socks.jiandan.base.ConstantString. 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: ShareUtil.java    From JianDan_OkHttpWithVolley with Apache License 2.0 6 votes vote down vote up
public static void sharePicture(Activity activity, String url) {

        String[] urlSplits = url.split("\\.");

        File cacheFile = ImageLoader.getInstance().getDiskCache().get(url);

        //如果不存在,则使用缩略图进行分享
        if (!cacheFile.exists()) {
            String picUrl = url;
            picUrl = picUrl.replace("mw600", "small").replace("mw1200", "small").replace
                    ("large", "small");
            cacheFile = ImageLoader.getInstance().getDiskCache().get(picUrl);
        }

        File newFile = new File(CacheUtil.getSharePicName
                (cacheFile, urlSplits));

        if (FileUtil.copyTo(cacheFile, newFile)) {
            ShareUtil.sharePicture(activity, newFile.getAbsolutePath(),
                    "分享自煎蛋 " + url);
        } else {
            ShowToast.Short(ConstantString.LOAD_SHARE);
        }
    }
 
Example #2
Source File: ShareUtil.java    From JianDanRxJava with Apache License 2.0 6 votes vote down vote up
public static void sharePicture(Activity activity, String url) {

        String[] urlSplits = url.split("\\.");

        File cacheFile = ImageLoader.getInstance().getDiskCache().get(url);

        //如果不存在,则使用缩略图进行分享
        if (!cacheFile.exists()) {
            String picUrl = url;
            picUrl = picUrl.replace("mw600", "small").replace("mw1200", "small").replace
                    ("large", "small");
            cacheFile = ImageLoader.getInstance().getDiskCache().get(picUrl);
        }

        File newFile = new File(CacheUtil.getSharePicName
                (cacheFile, urlSplits));

        if (FileUtil.copyTo(cacheFile, newFile)) {
            ShareUtil.sharePicture(activity, newFile.getAbsolutePath(),
                    "分享自煎蛋 " + url);
        } else {
            ToastHelper.Short(ConstantString.LOAD_SHARE);
        }
    }
 
Example #3
Source File: JokeAdapter.java    From JianDanRxJava with 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 File: ShareUtil.java    From JianDan_OkHttp with Apache License 2.0 6 votes vote down vote up
public static void sharePicture(Activity activity, String url) {

        String[] urlSplits = url.split("\\.");

        File cacheFile = ImageLoader.getInstance().getDiskCache().get(url);

        //如果不存在,则使用缩略图进行分享
        if (!cacheFile.exists()) {
            String picUrl = url;
            picUrl = picUrl.replace("mw600", "small").replace("mw1200", "small").replace
                    ("large", "small");
            cacheFile = ImageLoader.getInstance().getDiskCache().get(picUrl);
        }

        File newFile = new File(CacheUtil.getSharePicName
                (cacheFile, urlSplits));

        if (FileUtil.copyTo(cacheFile, newFile)) {
            ShareUtil.sharePicture(activity, newFile.getAbsolutePath(),
                    "分享自煎蛋 " + url);
        } else {
            ShowToast.Short(ConstantString.LOAD_SHARE);
        }
    }
 
Example #5
Source File: PictureAdapter.java    From JianDanRxJava with 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 File: ShareUtil.java    From JianDan with Apache License 2.0 6 votes vote down vote up
public static void sharePicture(Activity activity, String url) {

        String[] urlSplits = url.split("\\.");

        File cacheFile = ImageLoader.getInstance().getDiskCache().get(url);

        //如果不存在,则使用缩略图进行分享
        if (!cacheFile.exists()) {
            String picUrl = url;
            picUrl = picUrl.replace("mw600", "small").replace("mw1200", "small").replace
                    ("large", "small");
            cacheFile = ImageLoader.getInstance().getDiskCache().get(picUrl);
        }

        File newFile = new File(CacheUtil.getSharePicName
                (cacheFile, urlSplits));

        if (FileUtil.copyTo(cacheFile, newFile)) {
            ShareUtil.sharePicture(activity, newFile.getAbsolutePath(),
                    "分享自煎蛋 " + url);
        } else {
            ShowToast.Short(ConstantString.LOAD_SHARE);
        }
    }
 
Example #7
Source File: PictureAdapter.java    From JianDanRxJava with 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 #8
Source File: FreshNewsAdapter.java    From JianDanRxJava with 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 File: VideoAdapter.java    From JianDanRxJava with 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 File: FreshNewsFragment.java    From JianDanRxJava with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(int code) {
    loading.stop();
    ToastHelper.Short(ConstantString.LOAD_FAILED);
    if (mSwipeRefreshLayout.isRefreshing()) {
        mSwipeRefreshLayout.setRefreshing(false);
    }
}
 
Example #11
Source File: PushCommentActivity.java    From JianDan with Apache License 2.0 5 votes vote down vote up
@Override
public void onResponse(Boolean response) {
    dialog.dismiss();
    if (response) {
        setResult(RESULT_OK);
        finish();
    } else {
        ShowToast.Short(ConstantString.COMMENT_FAILED);
    }
}
 
Example #12
Source File: FileUtil.java    From JianDanRxJava with 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 #13
Source File: JDMediaScannerConnectionClient.java    From JianDanRxJava with Apache License 2.0 5 votes vote down vote up
@Override
public void onScanCompleted(String path, Uri uri) {
    Looper.prepare();
    if (isSmallPic) {
        ToastHelper.Short(ConstantString.SAVE_SMALL_SUCCESS + " \n相册" + File.separator + CacheUtil
                .FILE_SAVE + File.separator + newFile.getName());
    } else {
        ToastHelper.Short(ConstantString.SAVE_SUCCESS + " \n相册" + File.separator + CacheUtil
                .FILE_SAVE + File.separator + newFile.getName());
    }
    Looper.loop();
}
 
Example #14
Source File: TextUtil.java    From JianDanRxJava with Apache License 2.0 5 votes vote down vote up
public static void copy(Activity activity, String copyText) {
    ClipboardManager clip = (ClipboardManager)
            activity.getSystemService(Context
                    .CLIPBOARD_SERVICE);
    clip.setPrimaryClip(ClipData.newPlainText
            (null, copyText));
    ToastHelper.Short(ConstantString.COPY_SUCCESS);
}
 
Example #15
Source File: VideoFragment.java    From JianDanRxJava with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(int code) {
    loading.stop();
    ToastHelper.Short(ConstantString.LOAD_FAILED);
    if (mSwipeRefreshLayout.isRefreshing()) {
        mSwipeRefreshLayout.setRefreshing(false);
    }
}
 
Example #16
Source File: ImageDetailActivity.java    From JianDan with Apache License 2.0 5 votes vote down vote up
@JavascriptInterface
public void img_loaded_error() {
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            ShowToast.Short(ConstantString.LOAD_FAILED);
        }
    });
}
 
Example #17
Source File: FileUtil.java    From JianDan_OkHttp with 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 #18
Source File: JDMediaScannerConnectionClient.java    From JianDan_OkHttp with Apache License 2.0 5 votes vote down vote up
@Override
public void onScanCompleted(String path, Uri uri) {
    Looper.prepare();
    if (isSmallPic) {
        ShowToast.Short(ConstantString.SAVE_SMALL_SUCCESS + " \n相册" + File.separator + CacheUtil
                .FILE_SAVE + File.separator + newFile.getName());
    } else {
        ShowToast.Short(ConstantString.SAVE_SUCCESS + " \n相册" + File.separator + CacheUtil
                .FILE_SAVE + File.separator + newFile.getName());
    }
    Looper.loop();
}
 
Example #19
Source File: TextUtil.java    From JianDan_OkHttp with Apache License 2.0 5 votes vote down vote up
public static void copy(Activity activity, String copyText) {
    ClipboardManager clip = (ClipboardManager)
            activity.getSystemService(Context
                    .CLIPBOARD_SERVICE);
    clip.setPrimaryClip(ClipData.newPlainText
            (null, copyText));
    ShowToast.Short(ConstantString.COPY_SUCCESS);
}
 
Example #20
Source File: JokeAdapter.java    From JianDan_OkHttp with 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 #21
Source File: PictureAdapter.java    From JianDan_OkHttp with 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 File: VideoAdapter.java    From JianDan_OkHttp with 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 #23
Source File: VideoFragment.java    From JianDan_OkHttp with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(int code, String msg) {
    loading.stop();
    ShowToast.Short(ConstantString.LOAD_FAILED);
    if (mSwipeRefreshLayout.isRefreshing()) {
        mSwipeRefreshLayout.setRefreshing(false);
    }
}
 
Example #24
Source File: FreshNewsFragment.java    From JianDan_OkHttp with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(int code, String msg) {
    loading.stop();
    ShowToast.Short(ConstantString.LOAD_FAILED);
    if (mSwipeRefreshLayout.isRefreshing()) {
        mSwipeRefreshLayout.setRefreshing(false);
    }
}
 
Example #25
Source File: ImageDetailActivity.java    From JianDan_OkHttp with Apache License 2.0 5 votes vote down vote up
@JavascriptInterface
public void img_loaded_error() {
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            ShowToast.Short(ConstantString.LOAD_FAILED);
        }
    });
}
 
Example #26
Source File: FreshNewsFragment.java    From JianDan with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(int code, String msg) {
    loading.stop();
    ShowToast.Short(ConstantString.LOAD_FAILED);
    if (mSwipeRefreshLayout.isRefreshing()) {
        mSwipeRefreshLayout.setRefreshing(false);
    }
}
 
Example #27
Source File: JDMediaScannerConnectionClient.java    From JianDan_OkHttpWithVolley with Apache License 2.0 5 votes vote down vote up
@Override
public void onScanCompleted(String path, Uri uri) {
    Looper.prepare();
    if (isSmallPic) {
        ShowToast.Short(ConstantString.SAVE_SMALL_SUCCESS + " \n相册" + File.separator + CacheUtil
                .FILE_SAVE + File.separator + newFile.getName());
    } else {
        ShowToast.Short(ConstantString.SAVE_SUCCESS + " \n相册" + File.separator + CacheUtil
                .FILE_SAVE + File.separator + newFile.getName());
    }
    Looper.loop();
}
 
Example #28
Source File: TextUtil.java    From JianDan_OkHttpWithVolley with Apache License 2.0 5 votes vote down vote up
public static void copy(Activity activity, String copyText) {
    ClipboardManager clip = (ClipboardManager)
            activity.getSystemService(Context
                    .CLIPBOARD_SERVICE);
    clip.setPrimaryClip(ClipData.newPlainText
            (null, copyText));
    ShowToast.Short(ConstantString.COPY_SUCCESS);
}
 
Example #29
Source File: JokeAdapter.java    From JianDan_OkHttpWithVolley with 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 #30
Source File: PictureAdapter.java    From JianDan_OkHttpWithVolley with 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();

    }