| LEFT | RIGHT | 
|---|
| 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; |  | 
| 23 import org.adblockplus.libadblockplus.android.AdblockEngine; | 22 import org.adblockplus.libadblockplus.android.AdblockEngine; | 
| 24 import org.adblockplus.libadblockplus.android.AndroidWebRequestResourceWrapper; | 23 import org.adblockplus.libadblockplus.android.AndroidWebRequestResourceWrapper; | 
|  | 24 import org.adblockplus.libadblockplus.android.SingleInstanceEngineProvider; | 
| 25 import org.adblockplus.libadblockplus.android.settings.AdblockHelper; | 25 import org.adblockplus.libadblockplus.android.settings.AdblockHelper; | 
| 26 | 26 | 
| 27 import java.util.HashMap; | 27 import java.util.HashMap; | 
| 28 import java.util.Map; | 28 import java.util.Map; | 
| 29 | 29 | 
| 30 public class Application extends android.app.Application | 30 public class Application extends android.app.Application | 
| 31 { | 31 { | 
| 32   private final Runnable onAdblockEngineCreated = new Runnable() | 32   private final SingleInstanceEngineProvider.EngineCreatedListener engineCreated
    Listener = | 
|  | 33     new SingleInstanceEngineProvider.EngineCreatedListener() | 
| 33   { | 34   { | 
| 34     @Override | 35     @Override | 
| 35     public void run() | 36     public void onAdblockEngineCreated(AdblockEngine engine) | 
| 36     { | 37     { | 
| 37       FilterEngine engine = AdblockHelper.get().getProvider().getEngine().getFil
    terEngine(); |  | 
| 38       // put your Adblock FilterEngine init here | 38       // put your Adblock FilterEngine init here | 
| 39     } | 39     } | 
| 40   }; | 40   }; | 
| 41 | 41 | 
| 42   private final Runnable onAdblockEngineDisposed = new Runnable() | 42   private final SingleInstanceEngineProvider.EngineDisposedListener engineDispos
    edListener = | 
|  | 43     new SingleInstanceEngineProvider.EngineDisposedListener() | 
| 43   { | 44   { | 
| 44     @Override | 45     @Override | 
| 45     public void run() | 46     public void onAdblockEngineDisposed() | 
| 46     { | 47     { | 
| 47       // put your Adblock FilterEngine deinit here | 48       // put your Adblock FilterEngine deinit here | 
| 48     } | 49     } | 
| 49   }; | 50   }; | 
| 50 | 51 | 
| 51   @Override | 52   @Override | 
| 52   public void onCreate() | 53   public void onCreate() | 
| 53   { | 54   { | 
| 54     super.onCreate(); | 55     super.onCreate(); | 
| 55 | 56 | 
| 56     // init Adblock | 57     // init Adblock | 
| 57     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(); | 
| 58 | 59 | 
| 59     // provide preloaded subscriptions | 60     // provide preloaded subscriptions | 
| 60     Map<String, Integer> map = new HashMap<String, Integer>(); | 61     Map<String, Integer> map = new HashMap<String, Integer>(); | 
| 61     map.put(AndroidWebRequestResourceWrapper.EASYLIST, R.raw.easylist); | 62     map.put(AndroidWebRequestResourceWrapper.EASYLIST, R.raw.easylist); | 
| 62     map.put(AndroidWebRequestResourceWrapper.EASYLIST_CHINESE, R.raw.easylist); | 63     map.put(AndroidWebRequestResourceWrapper.EASYLIST_CHINESE, R.raw.easylist); | 
| 63     map.put(AndroidWebRequestResourceWrapper.ACCEPTABLE_ADS, R.raw.exceptionrule
    s); | 64     map.put(AndroidWebRequestResourceWrapper.ACCEPTABLE_ADS, R.raw.exceptionrule
    s); | 
| 64 | 65 | 
| 65     AdblockHelper | 66     AdblockHelper | 
| 66       .get() | 67       .get() | 
| 67       .init(this, basePath, true, AdblockHelper.PREFERENCE_NAME) | 68       .init(this, basePath, true, AdblockHelper.PREFERENCE_NAME) | 
| 68       .preloadSubscriptions(AdblockHelper.PRELOAD_PREFERENCE_NAME, map) | 69       .preloadSubscriptions(AdblockHelper.PRELOAD_PREFERENCE_NAME, map) | 
| 69       .addEngineCreatedCallback(onAdblockEngineCreated) | 70       .addEngineCreatedListener(engineCreatedListener) | 
| 70       .addEngineDisposedCallback(onAdblockEngineDisposed); | 71       .addEngineDisposedListener(engineDisposedListener); | 
| 71   } | 72   } | 
| 72 } | 73 } | 
| LEFT | RIGHT | 
|---|