mirror of
https://github.com/leanote/leanote-android.git
synced 2025-10-16 15:28:38 +00:00
code refactor: remove the required context valuable
This commit is contained in:
@@ -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;
|
||||||
|
@@ -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;
|
||||||
}
|
}
|
||||||
|
@@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user