code refactor: remove the required context valuable

This commit is contained in:
houxg
2017-02-13 16:46:33 +08:00
parent 3cd583dd60
commit bf20d03d53
3 changed files with 5 additions and 5 deletions

View File

@@ -104,7 +104,7 @@ public class MainActivity extends BaseActivity implements Navigation.Callback {
} }
private void syncNotes() { private void syncNotes() {
if (!NetworkUtils.isNetworkAvailable(MainActivity.this)) { if (!NetworkUtils.isNetworkAvailable()) {
ToastUtils.showNetworkUnavailable(MainActivity.this); ToastUtils.showNetworkUnavailable(MainActivity.this);
mSwipeRefresh.setRefreshing(false); mSwipeRefresh.setRefreshing(false);
return; return;

View File

@@ -166,7 +166,7 @@ public class NotePreviewActivity extends BaseActivity implements EditorFragment.
@OnClick(R.id.tv_revert) @OnClick(R.id.tv_revert)
void revert() { void revert() {
if (!NetworkUtils.isNetworkAvailable(this)) { if (!NetworkUtils.isNetworkAvailable()) {
ToastUtils.showNetworkUnavailable(this); ToastUtils.showNetworkUnavailable(this);
return; return;
} }

View File

@@ -22,13 +22,13 @@ public class NetworkUtils {
return cm.getActiveNetworkInfo(); return cm.getActiveNetworkInfo();
} }
public static boolean isNetworkAvailable(Context context) { public static boolean isNetworkAvailable() {
NetworkInfo info = getActiveNetworkInfo(context); NetworkInfo info = getActiveNetworkInfo(Leamonax.getContext());
return (info != null && info.isConnected()); return (info != null && info.isConnected());
} }
public static void checkNetwork() throws NetworkUnavailableException { public static void checkNetwork() throws NetworkUnavailableException {
if (!isNetworkAvailable(Leamonax.getContext())) { if (!isNetworkAvailable()) {
throw new NetworkUnavailableException(); throw new NetworkUnavailableException();
} }
} }