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

The following examples show how to use com.socks.jiandan.utils.ShowToast. 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: PictureFragment.java    License: 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 Project: JianDan   Source File: PictureFragment.java    License: 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 Project: JianDan_OkHttp   Source File: PictureFragment.java    License: 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 4
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 5
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 6
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 7
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 8
Source Project: JianDan_OkHttpWithVolley   Source File: JokeFragment.java    License: 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 9
Source Project: JianDan_OkHttpWithVolley   Source File: VideoFragment.java    License: 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 10
@Override
public void onError(int code, String msg) {
    loading.stop();
    ShowToast.Short(ConstantString.LOAD_FAILED);
    if (mSwipeRefreshLayout.isRefreshing()) {
        mSwipeRefreshLayout.setRefreshing(false);
    }
}
 
Example 11
@OnClick({R.id.img_back, R.id.img_share, R.id.tv_unlike, R.id.tv_like, R.id.img_comment, R.id.img_download})
@Override
public void onClick(View v) {

    switch (v.getId()) {
        case R.id.img_back:
            finish();
            break;
        case R.id.img_share:
            ShareUtil.sharePicture(this, img_urls[0]);
            break;
        case R.id.tv_like:
            ShowToast.Short("别点了,这玩意不能用");
            break;
        case R.id.tv_unlike:
            ShowToast.Short("别点了,这玩意不能用");
            break;
        case R.id.img_comment:
            Intent intent = new Intent(this, CommentListActivity.class);
            intent.putExtra(DATA_THREAD_KEY, threadKey);
            startActivity(intent);
            break;
        case R.id.img_download:
            FileUtil.savePicture(this, img_urls[0], this);
            break;
    }
}
 
Example 12
@JavascriptInterface
public void img_loaded_error() {
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            ShowToast.Short(ConstantString.LOAD_FAILED);
        }
    });
}
 
Example 13
Source Project: JianDan_OkHttpWithVolley   Source File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK
            && event.getAction() == KeyEvent.ACTION_DOWN) {
        if ((System.currentTimeMillis() - exitTime) > 2000) {
            ShowToast.Short("再按一次退出程序");
            exitTime = System.currentTimeMillis();
        } else {
            finish();
        }
        return true;
    }

    return super.onKeyDown(keyCode, event);
}
 
Example 14
@Override
public void onResponse(Boolean response) {
    dialog.dismiss();
    if (response) {
        setResult(RESULT_OK);
        finish();
    } else {
        ShowToast.Short(ConstantString.COMMENT_FAILED);
    }
}
 
Example 15
@Override
public void onSuccess(int result, Object object) {
    if (result == LoadResultCallBack.SUCCESS_NONE) {
        ShowToast.Short(NO_COMMENTS);
    }
    loading.stop();
    mSwipeRefreshLayout.setRefreshing(false);
}
 
Example 16
Source Project: JianDan_OkHttpWithVolley   Source File: TestClass.java    License: 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 17
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 18
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 19
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 20
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 21
Source Project: JianDan   Source File: JokeFragment.java    License: 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 22
Source Project: JianDan   Source File: VideoFragment.java    License: 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 23
Source Project: JianDan   Source File: FreshNewsFragment.java    License: 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 Project: JianDan   Source File: ImageDetailActivity.java    License: Apache License 2.0 5 votes vote down vote up
@OnClick({R.id.img_back, R.id.img_share, R.id.tv_unlike, R.id.tv_like, R.id.img_comment, R.id.img_download})
@Override
public void onClick(View v) {

    switch (v.getId()) {
        case R.id.img_back:
            finish();
            break;
        case R.id.img_share:
            ShareUtil.sharePicture(this, img_urls[0]);
            break;
        case R.id.tv_like:
            ShowToast.Short("别点了,这玩意不能用");
            break;
        case R.id.tv_unlike:
            ShowToast.Short("别点了,这玩意不能用");
            break;
        case R.id.img_comment:
            Intent intent = new Intent(this, CommentListActivity.class);
            intent.putExtra(DATA_THREAD_KEY, threadKey);
            startActivity(intent);
            break;
        case R.id.img_download:
            FileUtil.savePicture(this, img_urls[0], this);
            break;
    }
}
 
Example 25
Source Project: JianDan   Source File: ImageDetailActivity.java    License: 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 Project: JianDan   Source File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK
            && event.getAction() == KeyEvent.ACTION_DOWN) {
        if ((System.currentTimeMillis() - exitTime) > 2000) {
            ShowToast.Short("再按一次退出程序");
            exitTime = System.currentTimeMillis();
        } else {
            finish();
        }
        return true;
    }

    return super.onKeyDown(keyCode, event);
}
 
Example 27
Source Project: JianDan   Source File: PushCommentActivity.java    License: 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 28
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 29
Source Project: JianDan   Source File: TestClass.java    License: 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 30
Source Project: JianDan_OkHttp   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();
}