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

Side by Side 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.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 { 47 {
48 // put your Adblock FilterEngine deinit here 48 // put your Adblock FilterEngine deinit here
49 } 49 }
50 }; 50 };
51 51
52 @Override 52 @Override
53 public void onCreate() 53 public void onCreate()
54 { 54 {
55 super.onCreate(); 55 super.onCreate();
56 56
57 // init Adblock 57 // it's not initialized here but we check it just to show API usage
58 String basePath = getDir(AdblockEngine.BASE_PATH_DIRECTORY, Context.MODE_PRI VATE).getAbsolutePath(); 58 if (!AdblockHelper.get().isInit())
59 {
60 // init Adblock
61 String basePath = getDir(AdblockEngine.BASE_PATH_DIRECTORY, Context.MODE_P RIVATE).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.
59 62
60 // provide preloaded subscriptions 63 // provide preloaded subscriptions
61 Map<String, Integer> map = new HashMap<String, Integer>(); 64 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.
62 map.put(AndroidWebRequestResourceWrapper.EASYLIST, R.raw.easylist); 65 map.put(AndroidWebRequestResourceWrapper.EASYLIST, R.raw.easylist);
63 map.put(AndroidWebRequestResourceWrapper.EASYLIST_CHINESE, R.raw.easylist); 66 map.put(AndroidWebRequestResourceWrapper.EASYLIST_CHINESE, R.raw.easylist) ;
64 map.put(AndroidWebRequestResourceWrapper.ACCEPTABLE_ADS, R.raw.exceptionrule s); 67 map.put(AndroidWebRequestResourceWrapper.ACCEPTABLE_ADS, R.raw.exceptionru les);
65 68
66 AdblockHelper 69 AdblockHelper
67 .get() 70 .get()
68 .init(this, basePath, true, AdblockHelper.PREFERENCE_NAME) 71 .init(this, basePath, true, AdblockHelper.PREFERENCE_NAME)
69 .preloadSubscriptions(AdblockHelper.PRELOAD_PREFERENCE_NAME, map) 72 .preloadSubscriptions(AdblockHelper.PRELOAD_PREFERENCE_NAME, map)
70 .addEngineCreatedListener(engineCreatedListener) 73 .addEngineCreatedListener(engineCreatedListener)
71 .addEngineDisposedListener(engineDisposedListener); 74 .addEngineDisposedListener(engineDisposedListener);
75 }
72 } 76 }
73 } 77 }
OLDNEW

Powered by Google App Engine
This is Rietveld