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

Side by Side Diff: libadblockplus-android-settings/src/org/adblockplus/libadblockplus/android/settings/AdblockHelper.java

Issue 29678590: Issue 6307 - Introduce external engine created callback (Closed)
Patch Set: Created Jan. 24, 2018, 12:46 p.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 30 matching lines...) Expand all
41 41
42 /** 42 /**
43 * Suggested preference name to store intercepted subscription requests 43 * Suggested preference name to store intercepted subscription requests
44 */ 44 */
45 public static final String PRELOAD_PREFERENCE_NAME = "ADBLOCK_PRELOAD"; 45 public static final String PRELOAD_PREFERENCE_NAME = "ADBLOCK_PRELOAD";
46 private static AdblockHelper _instance; 46 private static AdblockHelper _instance;
47 47
48 private SingleInstanceEngineProvider provider; 48 private SingleInstanceEngineProvider provider;
49 private AdblockSettingsStorage storage; 49 private AdblockSettingsStorage storage;
50 50
51 private final Runnable engineCreatedCallback = new Runnable() 51 private final Runnable engineCreatedCallback = new Runnable()
anton 2018/01/24 12:50:05 We could accept Runnable in some `AdblockHelper` m
52 { 52 {
53 @Override 53 @Override
54 public void run() 54 public void run()
55 { 55 {
56 AdblockSettings settings = storage.load(); 56 AdblockSettings settings = storage.load();
57 if (settings != null) 57 if (settings != null)
58 { 58 {
59 Log.d(TAG, "Applying saved adblock settings to adblock engine"); 59 Log.d(TAG, "Applying saved adblock settings to adblock engine");
60 // apply last saved settings to adblock engine. 60 // apply last saved settings to adblock engine.
61 // all the settings except `enabled` and whitelisted domains list 61 // all the settings except `enabled` and whitelisted domains list
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 boolean developmentBuild, String pref erenceName) 141 boolean developmentBuild, String pref erenceName)
142 { 142 {
143 initProvider(context, basePath, developmentBuild); 143 initProvider(context, basePath, developmentBuild);
144 initStorage(context, preferenceName); 144 initStorage(context, preferenceName);
145 return provider; 145 return provider;
146 } 146 }
147 147
148 private void initProvider(Context context, String basePath, boolean developmen tBuild) 148 private void initProvider(Context context, String basePath, boolean developmen tBuild)
149 { 149 {
150 provider = new SingleInstanceEngineProvider(context, basePath, developmentBu ild); 150 provider = new SingleInstanceEngineProvider(context, basePath, developmentBu ild);
151 provider.setEngineCreatedCallback(engineCreatedCallback); 151 provider.addEngineCreatedCallback(engineCreatedCallback);
152 provider.setEngineDisposedCallback(engineDisposedCallback); 152 provider.addEngineDisposedCallback(engineDisposedCallback);
153 } 153 }
154 154
155 private void initStorage(Context context, String settingsPreferenceName) 155 private void initStorage(Context context, String settingsPreferenceName)
156 { 156 {
157 // read and apply current settings 157 // read and apply current settings
158 SharedPreferences settingsPrefs = context.getSharedPreferences( 158 SharedPreferences settingsPrefs = context.getSharedPreferences(
159 settingsPreferenceName, 159 settingsPreferenceName,
160 Context.MODE_PRIVATE); 160 Context.MODE_PRIVATE);
161 161
162 storage = new SharedPrefsStorage(settingsPrefs); 162 storage = new SharedPrefsStorage(settingsPrefs);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 /** 201 /**
202 * @deprecated The method is deprecated: use .getProvider().getCounter() inste ad 202 * @deprecated The method is deprecated: use .getProvider().getCounter() inste ad
203 */ 203 */
204 @Deprecated 204 @Deprecated
205 public int getCounter() 205 public int getCounter()
206 { 206 {
207 return provider.getCounter(); 207 return provider.getCounter();
208 } 208 }
209 } 209 }
OLDNEW

Powered by Google App Engine
This is Rietveld