Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: libadblockplus-android-settings/src/org/adblockplus/libadblockplus/android/settings/AdblockHelper.java

Issue 29691555: Issue 6364 - Exclude double initialization of AdblockHelper (Closed)
Patch Set: Created Feb. 7, 2018, 9:28 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: libadblockplus-android-settings/src/org/adblockplus/libadblockplus/android/settings/AdblockHelper.java
diff --git a/libadblockplus-android-settings/src/org/adblockplus/libadblockplus/android/settings/AdblockHelper.java b/libadblockplus-android-settings/src/org/adblockplus/libadblockplus/android/settings/AdblockHelper.java
index 476d150bb22538d44542130d2e3eadb487170e83..7ecd94c3a8726efb9a6b82332d23c932b49560d2 100644
--- a/libadblockplus-android-settings/src/org/adblockplus/libadblockplus/android/settings/AdblockHelper.java
+++ b/libadblockplus-android-settings/src/org/adblockplus/libadblockplus/android/settings/AdblockHelper.java
@@ -45,6 +45,7 @@ public class AdblockHelper
public static final String PRELOAD_PREFERENCE_NAME = "ADBLOCK_PRELOAD";
private static AdblockHelper _instance;
+ private boolean isInitialized;
private SingleInstanceEngineProvider provider;
private AdblockSettingsStorage storage;
@@ -141,11 +142,25 @@ public class AdblockHelper
public SingleInstanceEngineProvider init(Context context, String basePath,
boolean developmentBuild, String preferenceName)
{
+ if (isInitialized)
+ {
+ new IllegalStateException("Usage exception: already initialized. Check `isInit()`");
+ }
+
initProvider(context, basePath, developmentBuild);
initStorage(context, preferenceName);
+ isInitialized = true;
return provider;
}
+ /**
+ * Check if it is already initialized
+ * @return
+ */
+ public boolean isInit() {
jens 2018/02/07 09:36:25 for consistency I would probably call this method
anton 2018/02/07 09:52:55 initialize method is called `init()` to i've names
jens 2018/02/07 10:03:23 Okay, I don't insist to change it. But it's kind
+ return isInitialized;
+ }
+
private void initProvider(Context context, String basePath, boolean developmentBuild)
{
provider = new SingleInstanceEngineProvider(context, basePath, developmentBuild);

Powered by Google App Engine
This is Rietveld