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

Unified Diff: libadblockplus-android-webviewapp/src/org/adblockplus/libadblockplus/android/webviewapp/Application.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-webviewapp/src/org/adblockplus/libadblockplus/android/webviewapp/Application.java
diff --git a/libadblockplus-android-webviewapp/src/org/adblockplus/libadblockplus/android/webviewapp/Application.java b/libadblockplus-android-webviewapp/src/org/adblockplus/libadblockplus/android/webviewapp/Application.java
index ed901ced299ec1db5f3789bc893b98eb3948172a..67aa3ca2a4d44ed686a6a42abc55f2dd9dd69fd2 100644
--- a/libadblockplus-android-webviewapp/src/org/adblockplus/libadblockplus/android/webviewapp/Application.java
+++ b/libadblockplus-android-webviewapp/src/org/adblockplus/libadblockplus/android/webviewapp/Application.java
@@ -54,20 +54,24 @@ public class Application extends android.app.Application
{
super.onCreate();
- // init Adblock
- String basePath = getDir(AdblockEngine.BASE_PATH_DIRECTORY, Context.MODE_PRIVATE).getAbsolutePath();
+ // it's not initialized here but we check it just to show API usage
+ if (!AdblockHelper.get().isInit())
+ {
+ // init Adblock
+ String basePath = getDir(AdblockEngine.BASE_PATH_DIRECTORY, Context.MODE_PRIVATE).getAbsolutePath();
jens 2018/02/07 09:36:25 basePath can be final
anton 2018/02/07 09:52:55 agree, but it's unrelated to the task.
jens 2018/02/07 10:03:23 Acknowledged.
- // provide preloaded subscriptions
- Map<String, Integer> map = new HashMap<String, Integer>();
- map.put(AndroidWebRequestResourceWrapper.EASYLIST, R.raw.easylist);
- map.put(AndroidWebRequestResourceWrapper.EASYLIST_CHINESE, R.raw.easylist);
- map.put(AndroidWebRequestResourceWrapper.ACCEPTABLE_ADS, R.raw.exceptionrules);
+ // provide preloaded subscriptions
+ Map<String, Integer> map = new HashMap<String, Integer>();
jens 2018/02/07 09:36:25 I would use a more descriptive name like 'subscrip
anton 2018/02/07 09:52:55 agree too, but it's unrelated to the task too.
jens 2018/02/07 10:03:23 Acknowledged.
+ map.put(AndroidWebRequestResourceWrapper.EASYLIST, R.raw.easylist);
+ map.put(AndroidWebRequestResourceWrapper.EASYLIST_CHINESE, R.raw.easylist);
+ map.put(AndroidWebRequestResourceWrapper.ACCEPTABLE_ADS, R.raw.exceptionrules);
- AdblockHelper
- .get()
- .init(this, basePath, true, AdblockHelper.PREFERENCE_NAME)
- .preloadSubscriptions(AdblockHelper.PRELOAD_PREFERENCE_NAME, map)
- .addEngineCreatedListener(engineCreatedListener)
- .addEngineDisposedListener(engineDisposedListener);
+ AdblockHelper
+ .get()
+ .init(this, basePath, true, AdblockHelper.PREFERENCE_NAME)
+ .preloadSubscriptions(AdblockHelper.PRELOAD_PREFERENCE_NAME, map)
+ .addEngineCreatedListener(engineCreatedListener)
+ .addEngineDisposedListener(engineDisposedListener);
+ }
}
}

Powered by Google App Engine
This is Rietveld