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.FilterEngine; |
22 import org.adblockplus.libadblockplus.android.AdblockEngine; | 23 import org.adblockplus.libadblockplus.android.AdblockEngine; |
23 import org.adblockplus.libadblockplus.android.AndroidWebRequestResourceWrapper; | 24 import org.adblockplus.libadblockplus.android.AndroidWebRequestResourceWrapper; |
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 Runnable onAdblockEngineCreated = new Runnable() |
| 33 { |
| 34 @Override |
| 35 public void run() |
| 36 { |
| 37 FilterEngine engine = AdblockHelper.get().getProvider().getEngine().getFil
terEngine(); |
| 38 // put your Adblock FilterEngine init here |
| 39 } |
| 40 }; |
| 41 |
| 42 private final Runnable onAdblockEngineDisposed = new Runnable() |
| 43 { |
| 44 @Override |
| 45 public void run() |
| 46 { |
| 47 // put your Adblock FilterEngine deinit here |
| 48 } |
| 49 }; |
| 50 |
31 @Override | 51 @Override |
32 public void onCreate() | 52 public void onCreate() |
33 { | 53 { |
34 super.onCreate(); | 54 super.onCreate(); |
35 | 55 |
36 // init Adblock | 56 // init Adblock |
37 String basePath = getDir(AdblockEngine.BASE_PATH_DIRECTORY, Context.MODE_PRI
VATE).getAbsolutePath(); | 57 String basePath = getDir(AdblockEngine.BASE_PATH_DIRECTORY, Context.MODE_PRI
VATE).getAbsolutePath(); |
38 | 58 |
39 // provide preloaded subscriptions | 59 // provide preloaded subscriptions |
40 Map<String, Integer> map = new HashMap<String, Integer>(); | 60 Map<String, Integer> map = new HashMap<String, Integer>(); |
41 map.put(AndroidWebRequestResourceWrapper.EASYLIST, R.raw.easylist); | 61 map.put(AndroidWebRequestResourceWrapper.EASYLIST, R.raw.easylist); |
42 map.put(AndroidWebRequestResourceWrapper.EASYLIST_CHINESE, R.raw.easylist); | 62 map.put(AndroidWebRequestResourceWrapper.EASYLIST_CHINESE, R.raw.easylist); |
43 map.put(AndroidWebRequestResourceWrapper.ACCEPTABLE_ADS, R.raw.exceptionrule
s); | 63 map.put(AndroidWebRequestResourceWrapper.ACCEPTABLE_ADS, R.raw.exceptionrule
s); |
44 | 64 |
45 AdblockHelper | 65 AdblockHelper |
46 .get() | 66 .get() |
47 .init(this, basePath, true, AdblockHelper.PREFERENCE_NAME) | 67 .init(this, basePath, true, AdblockHelper.PREFERENCE_NAME) |
48 .preloadSubscriptions(AdblockHelper.PRELOAD_PREFERENCE_NAME, map); | 68 .preloadSubscriptions(AdblockHelper.PRELOAD_PREFERENCE_NAME, map) |
| 69 .addEngineCreatedCallback(onAdblockEngineCreated) |
| 70 .addEngineDisposedCallback(onAdblockEngineDisposed); |
49 } | 71 } |
50 } | 72 } |
OLD | NEW |