Java Code Examples for com.socks.jiandan.utils.ShowToast#Short

The following examples show how to use com.socks.jiandan.utils.ShowToast#Short . 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: PictureFragment.java    From JianDan with Apache License 2.0 6 votes vote down vote up
public void onEventMainThread(NetWorkEvent event) {

        if (event.getType() == NetWorkEvent.AVAILABLE) {
            if (NetWorkUtil.isWifiConnected(getActivity())) {
                mAdapter.setIsWifi(true);
                if (!isFirstChange && (System.currentTimeMillis() - lastShowTime) > 3000) {
                    ShowToast.Short("已切换为WIFI模式,自动加载GIF图片");
                    lastShowTime = System.currentTimeMillis();
                }
            } else {
                mAdapter.setIsWifi(false);
                if (!isFirstChange && (System.currentTimeMillis() - lastShowTime) > 3000) {
                    ShowToast.Short("已切换为省流量模式,只加载GIF缩略图");
                    lastShowTime = System.currentTimeMillis();
                }
            }
            isFirstChange = false;
        }
    }
 
Example 2
Source File: PictureFragment.java    From JianDan_OkHttp with Apache License 2.0 6 votes vote down vote up
public void onEventMainThread(NetWorkEvent event) {

        if (event.getType() == NetWorkEvent.AVAILABLE) {
            if (NetWorkUtil.isWifiConnected(getActivity())) {
                mAdapter.setIsWifi(true);
                if (!isFirstChange && (System.currentTimeMillis() - lastShowTime) > 3000) {
                    ShowToast.Short("已切换为WIFI模式,自动加载GIF图片");
                    lastShowTime = System.currentTimeMillis();
                }
            } else {
                mAdapter.setIsWifi(false);
                if (!isFirstChange && (System.currentTimeMillis() - lastShowTime) > 3000) {
                    ShowToast.Short("已切换为省流量模式,只加载GIF缩略图");
                    lastShowTime = System.currentTimeMillis();
                }
            }
            isFirstChange = false;
        }
    }
 
Example 3
Source File: PushCommentActivity.java    From JianDan_OkHttpWithVolley 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 4
Source File: JokeFragment.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(LOAD_FAILED);
    if (mSwipeRefreshLayout.isRefreshing()) {
        mSwipeRefreshLayout.setRefreshing(false);
    }
}
 
Example 5
Source File: VideoFragment.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 6
Source File: PictureAdapter.java    From JianDan 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 7
Source File: JokeFragment.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(LOAD_FAILED);
    if (mSwipeRefreshLayout.isRefreshing()) {
        mSwipeRefreshLayout.setRefreshing(false);
    }
}
 
Example 8
Source File: TestClass.java    From JianDan_OkHttpWithVolley with Apache License 2.0 5 votes vote down vote up
protected Response.ErrorListener errorListener() {
	return new Response.ErrorListener() {
		@Override
		public void onErrorResponse(VolleyError error) {
			ShowToast.Short(error.getMessage());
		}
	};
}
 
Example 9
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 10
Source File: CommentListActivity.java    From JianDan_OkHttpWithVolley with 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 11
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 12
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 13
Source File: FreshNewsFragment.java    From JianDan_OkHttpWithVolley 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 14
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 15
Source File: JokeFragment.java    From JianDan_OkHttpWithVolley with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(int code, String msg) {
    loading.stop();
    ShowToast.Short(LOAD_FAILED);
    if (mSwipeRefreshLayout.isRefreshing()) {
        mSwipeRefreshLayout.setRefreshing(false);
    }
}
 
Example 16
Source File: VideoAdapter.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);
        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 File: TestClass.java    From JianDan_OkHttp with Apache License 2.0 5 votes vote down vote up
protected Response.ErrorListener errorListener() {
	return new Response.ErrorListener() {
		@Override
		public void onErrorResponse(VolleyError error) {
			ShowToast.Short(error.getMessage());
		}
	};
}
 
Example 18
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();

    }
 
Example 19
Source File: CommentListActivity.java    From JianDan_OkHttp with Apache License 2.0 4 votes vote down vote up
@Override
public void onError(int code, String msg) {
    mSwipeRefreshLayout.setRefreshing(false);
   loading.stop();
    ShowToast.Short(LOAD_FAILED);
}
 
Example 20
Source File: FreshNewsAdapter.java    From JianDan with Apache License 2.0 4 votes vote down vote up
private void loadDataByNetworkType() {

        if (NetWorkUtil.isNetWorkConnected(mActivity)) {
            RequestManager.addRequest(new Request4FreshNews(FreshNews.getUrlFreshNews(page),
                    new Response.Listener<ArrayList<FreshNews>>() {
                        @Override
                        public void onResponse(ArrayList<FreshNews> response) {

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

                            if (page == 1) {
                                mFreshNews.clear();
                                FreshNewsCache.getInstance(mActivity).clearAllCache();
                            }

                            mFreshNews.addAll(response);
                            notifyDataSetChanged();

                            FreshNewsCache.getInstance(mActivity).addResultCache(JSONParser.toString(response),
                                    page);
                        }
                    }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    mLoadResultCallBack.onError(LoadResultCallBack.ERROR_NET, error.getMessage());
                    mLoadFinisCallBack.loadFinish(null);
                }
            }), mActivity);
        } else {
            mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
            mLoadFinisCallBack.loadFinish(null);

            if (page == 1) {
                mFreshNews.clear();
                ShowToast.Short(ConstantString.LOAD_NO_NETWORK);
            }

            mFreshNews.addAll(FreshNewsCache.getInstance(mActivity).getCacheByPage(page));
            notifyDataSetChanged();
        }

    }