From 5af0f5f0c1cee793818b82a1dd36ac921b854f92 Mon Sep 17 00:00:00 2001 From: anthony restaino Date: Wed, 26 Apr 2017 22:12:21 -0400 Subject: [PATCH] Getting rid of BrowserApp.get method --- .../java/acr/browser/lightning/activity/BrowserActivity.java | 4 ++-- app/src/main/java/acr/browser/lightning/app/BrowserApp.java | 5 ----- .../main/java/acr/browser/lightning/utils/ProxyUtils.java | 3 +-- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java b/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java index 0400eca..66a32cc 100644 --- a/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java +++ b/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java @@ -1284,7 +1284,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements Log.d(TAG, "onPause"); mTabsManager.pauseAll(); try { - BrowserApp.get(this).unregisterReceiver(mNetworkReceiver); + getApplication().unregisterReceiver(mNetworkReceiver); } catch (IllegalArgumentException e) { Log.e(TAG, "Receiver was not registered", e); } @@ -1349,7 +1349,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements IntentFilter filter = new IntentFilter(); filter.addAction(NETWORK_BROADCAST_ACTION); - BrowserApp.get(this).registerReceiver(mNetworkReceiver, filter); + getApplication().registerReceiver(mNetworkReceiver, filter); mEventBus.register(mBusEventListener); diff --git a/app/src/main/java/acr/browser/lightning/app/BrowserApp.java b/app/src/main/java/acr/browser/lightning/app/BrowserApp.java index c09f688..8b66e75 100644 --- a/app/src/main/java/acr/browser/lightning/app/BrowserApp.java +++ b/app/src/main/java/acr/browser/lightning/app/BrowserApp.java @@ -93,11 +93,6 @@ public class BrowserApp extends Application { }); } - @NonNull - public static BrowserApp get(@NonNull Context context) { - return (BrowserApp) context.getApplicationContext(); - } - @NonNull public static AppComponent getAppComponent() { Preconditions.checkNonNull(sAppComponent); diff --git a/app/src/main/java/acr/browser/lightning/utils/ProxyUtils.java b/app/src/main/java/acr/browser/lightning/utils/ProxyUtils.java index 4bdc5f3..85acd54 100644 --- a/app/src/main/java/acr/browser/lightning/utils/ProxyUtils.java +++ b/app/src/main/java/acr/browser/lightning/utils/ProxyUtils.java @@ -202,9 +202,8 @@ public class ProxyUtils { Utils.showSnackbar(activity, R.string.install_orbot); } break; - case Constants.PROXY_I2P: - I2PAndroidHelper ih = new I2PAndroidHelper(BrowserApp.get(activity)); + I2PAndroidHelper ih = new I2PAndroidHelper(activity.getApplication()); if (!ih.isI2PAndroidInstalled()) { choice = Constants.NO_PROXY; ih.promptToInstall(activity);