OLD | NEW |
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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 package org.adblockplus.libadblockplus.android.webviewapp; | 18 package org.adblockplus.libadblockplus.android.webviewapp; |
19 | 19 |
20 import android.content.Context; | 20 import android.content.Context; |
21 | 21 |
22 import org.adblockplus.libadblockplus.android.AdblockEngine; | 22 import org.adblockplus.libadblockplus.android.AdblockEngine; |
23 import org.adblockplus.libadblockplus.android.AndroidWebRequestResourceWrapper; | 23 import org.adblockplus.libadblockplus.android.AndroidWebRequestResourceWrapper; |
| 24 import org.adblockplus.libadblockplus.android.SingleInstanceEngineProvider; |
24 import org.adblockplus.libadblockplus.android.settings.AdblockHelper; | 25 import org.adblockplus.libadblockplus.android.settings.AdblockHelper; |
25 | 26 |
26 import java.util.HashMap; | 27 import java.util.HashMap; |
27 import java.util.Map; | 28 import java.util.Map; |
28 | 29 |
29 public class Application extends android.app.Application | 30 public class Application extends android.app.Application |
30 { | 31 { |
| 32 private final SingleInstanceEngineProvider.EngineCreatedListener engineCreated
Listener = |
| 33 new SingleInstanceEngineProvider.EngineCreatedListener() |
| 34 { |
| 35 @Override |
| 36 public void onAdblockEngineCreated(AdblockEngine engine) |
| 37 { |
| 38 // put your Adblock FilterEngine init here |
| 39 } |
| 40 }; |
| 41 |
| 42 private final SingleInstanceEngineProvider.EngineDisposedListener engineDispos
edListener = |
| 43 new SingleInstanceEngineProvider.EngineDisposedListener() |
| 44 { |
| 45 @Override |
| 46 public void onAdblockEngineDisposed() |
| 47 { |
| 48 // put your Adblock FilterEngine deinit here |
| 49 } |
| 50 }; |
| 51 |
31 @Override | 52 @Override |
32 public void onCreate() | 53 public void onCreate() |
33 { | 54 { |
34 super.onCreate(); | 55 super.onCreate(); |
35 | 56 |
36 // init Adblock | 57 // init Adblock |
37 String basePath = getDir(AdblockEngine.BASE_PATH_DIRECTORY, Context.MODE_PRI
VATE).getAbsolutePath(); | 58 String basePath = getDir(AdblockEngine.BASE_PATH_DIRECTORY, Context.MODE_PRI
VATE).getAbsolutePath(); |
38 | 59 |
39 // provide preloaded subscriptions | 60 // provide preloaded subscriptions |
40 Map<String, Integer> map = new HashMap<String, Integer>(); | 61 Map<String, Integer> map = new HashMap<String, Integer>(); |
41 map.put(AndroidWebRequestResourceWrapper.EASYLIST, R.raw.easylist); | 62 map.put(AndroidWebRequestResourceWrapper.EASYLIST, R.raw.easylist); |
42 map.put(AndroidWebRequestResourceWrapper.EASYLIST_CHINESE, R.raw.easylist); | 63 map.put(AndroidWebRequestResourceWrapper.EASYLIST_CHINESE, R.raw.easylist); |
43 map.put(AndroidWebRequestResourceWrapper.ACCEPTABLE_ADS, R.raw.exceptionrule
s); | 64 map.put(AndroidWebRequestResourceWrapper.ACCEPTABLE_ADS, R.raw.exceptionrule
s); |
44 | 65 |
45 AdblockHelper | 66 AdblockHelper |
46 .get() | 67 .get() |
47 .init(this, basePath, true, AdblockHelper.PREFERENCE_NAME) | 68 .init(this, basePath, true, AdblockHelper.PREFERENCE_NAME) |
48 .preloadSubscriptions(AdblockHelper.PRELOAD_PREFERENCE_NAME, map); | 69 .preloadSubscriptions(AdblockHelper.PRELOAD_PREFERENCE_NAME, map) |
| 70 .addEngineCreatedListener(engineCreatedListener) |
| 71 .addEngineDisposedListener(engineDisposedListener); |
49 } | 72 } |
50 } | 73 } |
OLD | NEW |