Java Code Examples for com.socks.jiandan.utils.NetWorkUtil#isNetWorkConnected()
The following examples show how to use
com.socks.jiandan.utils.NetWorkUtil#isNetWorkConnected() .
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: MainActivity.java From JianDan with Apache License 2.0 | 6 votes |
@Override protected void initData() { netStateReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals( ConnectivityManager.CONNECTIVITY_ACTION)) { if (NetWorkUtil.isNetWorkConnected(MainActivity.this)) { EventBus.getDefault().post(new NetWorkEvent(NetWorkEvent.AVAILABLE)); } else { EventBus.getDefault().post(new NetWorkEvent(NetWorkEvent.UNAVAILABLE)); } } } }; registerReceiver(netStateReceiver, new IntentFilter( ConnectivityManager.CONNECTIVITY_ACTION)); }
Example 2
Source File: MainActivity.java From JianDan_OkHttp with Apache License 2.0 | 6 votes |
@Override protected void initData() { netStateReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals( ConnectivityManager.CONNECTIVITY_ACTION)) { if (NetWorkUtil.isNetWorkConnected(MainActivity.this)) { EventBus.getDefault().post(new NetWorkEvent(NetWorkEvent.AVAILABLE)); } else { EventBus.getDefault().post(new NetWorkEvent(NetWorkEvent.UNAVAILABLE)); } } } }; registerReceiver(netStateReceiver, new IntentFilter( ConnectivityManager.CONNECTIVITY_ACTION)); }
Example 3
Source File: MainActivity.java From JianDan_OkHttpWithVolley with Apache License 2.0 | 6 votes |
@Override protected void initData() { netStateReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals( ConnectivityManager.CONNECTIVITY_ACTION)) { if (NetWorkUtil.isNetWorkConnected(MainActivity.this)) { EventBus.getDefault().post(new NetWorkEvent(NetWorkEvent.AVAILABLE)); } else { EventBus.getDefault().post(new NetWorkEvent(NetWorkEvent.UNAVAILABLE)); } } } }; registerReceiver(netStateReceiver, new IntentFilter( ConnectivityManager.CONNECTIVITY_ACTION)); }
Example 4
Source File: VideoAdapter.java From JianDan_OkHttpWithVolley with Apache License 2.0 | 5 votes |
private void loadDataByNetworkType() { if (NetWorkUtil.isNetWorkConnected(mActivity)) { loadData(); } else { loadCache(); } }
Example 5
Source File: JokeAdapter.java From JianDan with Apache License 2.0 | 5 votes |
private void loadDataByNetworkType() { if (NetWorkUtil.isNetWorkConnected(mActivity)) { loadData(); } else { loadCache(); } }
Example 6
Source File: PictureAdapter.java From JianDan with Apache License 2.0 | 5 votes |
private void loadDataByNetworkType() { if (NetWorkUtil.isNetWorkConnected(mActivity)) { loadData(); } else { loadCache(); } }
Example 7
Source File: VideoAdapter.java From JianDan with Apache License 2.0 | 5 votes |
private void loadDataByNetworkType() { if (NetWorkUtil.isNetWorkConnected(mActivity)) { loadData(); } else { loadCache(); } }
Example 8
Source File: JokeAdapter.java From JianDan_OkHttpWithVolley with Apache License 2.0 | 5 votes |
private void loadDataByNetworkType() { if (NetWorkUtil.isNetWorkConnected(mActivity)) { loadData(); } else { loadCache(); } }
Example 9
Source File: NetStateReceiver.java From JianDanRxJava with Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals( ConnectivityManager.CONNECTIVITY_ACTION)) { if (NetWorkUtil.isNetWorkConnected(context)) { RxNetWorkEvent.send(new NetWorkEvent(NetWorkEvent.AVAILABLE)); } else { RxNetWorkEvent.send(new NetWorkEvent(NetWorkEvent.UNAVAILABLE)); } } }
Example 10
Source File: JokeAdapter.java From JianDanRxJava with Apache License 2.0 | 5 votes |
private void loadDataByNetworkType() { if (NetWorkUtil.isNetWorkConnected(mActivity)) { loadData(); } else { loadCache(); } }
Example 11
Source File: PictureAdapter.java From JianDanRxJava with Apache License 2.0 | 5 votes |
private void loadDataByNetworkType() { if (NetWorkUtil.isNetWorkConnected(mActivity)) { loadData(); } else { loadCache(); } }
Example 12
Source File: FreshNewsAdapter.java From JianDanRxJava with Apache License 2.0 | 5 votes |
private void loadDataByNetworkType() { if (NetWorkUtil.isNetWorkConnected(mActivity)) { loadDate(); } else { loadFromCache(); } }
Example 13
Source File: VideoAdapter.java From JianDanRxJava with Apache License 2.0 | 5 votes |
private void loadDataByNetworkType() { if (NetWorkUtil.isNetWorkConnected(mActivity)) { loadData(); } else { loadCache(); } }
Example 14
Source File: JokeAdapter.java From JianDan_OkHttp with Apache License 2.0 | 5 votes |
private void loadDataByNetworkType() { if (NetWorkUtil.isNetWorkConnected(mActivity)) { loadData(); } else { loadCache(); } }
Example 15
Source File: PictureAdapter.java From JianDan_OkHttp with Apache License 2.0 | 5 votes |
private void loadDataByNetworkType() { if (NetWorkUtil.isNetWorkConnected(mActivity)) { loadData(); } else { loadCache(); } }
Example 16
Source File: VideoAdapter.java From JianDan_OkHttp with Apache License 2.0 | 5 votes |
private void loadDataByNetworkType() { if (NetWorkUtil.isNetWorkConnected(mActivity)) { loadData(); } else { loadCache(); } }
Example 17
Source File: PictureAdapter.java From JianDan_OkHttpWithVolley with Apache License 2.0 | 5 votes |
private void loadDataByNetworkType() { if (NetWorkUtil.isNetWorkConnected(mActivity)) { loadData(); } else { loadCache(); } }
Example 18
Source File: FreshNewsAdapter.java From JianDan_OkHttpWithVolley with Apache License 2.0 | 4 votes |
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(); } }
Example 19
Source File: FreshNewsAdapter.java From JianDan with Apache License 2.0 | 4 votes |
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(); } }