mirror of
https://github.com/leanote/leanote-android.git
synced 2025-10-15 14:51:04 +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() {
|
||||
if (!NetworkUtils.isNetworkAvailable(MainActivity.this)) {
|
||||
if (!NetworkUtils.isNetworkAvailable()) {
|
||||
ToastUtils.showNetworkUnavailable(MainActivity.this);
|
||||
mSwipeRefresh.setRefreshing(false);
|
||||
return;
|
||||
|
@@ -166,7 +166,7 @@ public class NotePreviewActivity extends BaseActivity implements EditorFragment.
|
||||
|
||||
@OnClick(R.id.tv_revert)
|
||||
void revert() {
|
||||
if (!NetworkUtils.isNetworkAvailable(this)) {
|
||||
if (!NetworkUtils.isNetworkAvailable()) {
|
||||
ToastUtils.showNetworkUnavailable(this);
|
||||
return;
|
||||
}
|
||||
|
@@ -22,13 +22,13 @@ public class NetworkUtils {
|
||||
return cm.getActiveNetworkInfo();
|
||||
}
|
||||
|
||||
public static boolean isNetworkAvailable(Context context) {
|
||||
NetworkInfo info = getActiveNetworkInfo(context);
|
||||
public static boolean isNetworkAvailable() {
|
||||
NetworkInfo info = getActiveNetworkInfo(Leamonax.getContext());
|
||||
return (info != null && info.isConnected());
|
||||
}
|
||||
|
||||
public static void checkNetwork() throws NetworkUnavailableException {
|
||||
if (!isNetworkAvailable(Leamonax.getContext())) {
|
||||
if (!isNetworkAvailable()) {
|
||||
throw new NetworkUnavailableException();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user