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 29533572: Issue 5556 - Update to use libadblockplus revision hg:566f64c8a2a8 (Closed) Base URL: github.com:abby-sergz/libadblockplus-android.git
Patch Set: Created Sept. 1, 2017, 9:41 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 private Context context; 53 private Context context;
54 private String basePath; 54 private String basePath;
55 private boolean developmentBuild; 55 private boolean developmentBuild;
56 private String settingsPreferenceName; 56 private String settingsPreferenceName;
57 private String preloadedPreferenceName; 57 private String preloadedPreferenceName;
58 private Map<String, Integer> urlToResourceIdMap; 58 private Map<String, Integer> urlToResourceIdMap;
59 private AdblockEngine engine; 59 private AdblockEngine engine;
60 private AdblockSettingsStorage storage; 60 private AdblockSettingsStorage storage;
61 private CountDownLatch engineCreated; 61 private CountDownLatch engineCreated;
62 62
63 private IsAllowedConnectionCallback isAllowedConnectionCallback;
64
65 /* 63 /*
66 Simple ARC management for AdblockEngine 64 Simple ARC management for AdblockEngine
67 Use `retain` and `release` 65 Use `retain` and `release`
68 */ 66 */
69 67
70 private AtomicInteger referenceCounter = new AtomicInteger(0); 68 private AtomicInteger referenceCounter = new AtomicInteger(0);
71 69
72 // singleton 70 // singleton
73 protected AdblockHelper() 71 protected AdblockHelper()
74 { 72 {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 { 128 {
131 this.preloadedPreferenceName = preferenceName; 129 this.preloadedPreferenceName = preferenceName;
132 this.urlToResourceIdMap = urlToResourceIdMap; 130 this.urlToResourceIdMap = urlToResourceIdMap;
133 return this; 131 return this;
134 } 132 }
135 133
136 private void createAdblock() 134 private void createAdblock()
137 { 135 {
138 ConnectivityManager connectivityManager = 136 ConnectivityManager connectivityManager =
139 (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVIC E); 137 (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVIC E);
140 this.isAllowedConnectionCallback = new IsAllowedConnectionCallbackImpl(conne ctivityManager); 138 IsAllowedConnectionCallback isAllowedConnectionCallback = new IsAllowedConne ctionCallbackImpl(connectivityManager);
anton 2017/09/01 09:56:37 it would be better to create it right in line #152
sergei 2017/09/01 10:04:22 Line 152 is already a part of a long multiline exp
anton 2017/09/01 10:05:58 ok
141 139
142 Log.d(TAG, "Creating adblock engine ..."); 140 Log.d(TAG, "Creating adblock engine ...");
143 141
144 // read and apply current settings 142 // read and apply current settings
145 SharedPreferences settingsPrefs = context.getSharedPreferences( 143 SharedPreferences settingsPrefs = context.getSharedPreferences(
146 settingsPreferenceName, 144 settingsPreferenceName,
147 Context.MODE_PRIVATE); 145 Context.MODE_PRIVATE);
148 storage = new SharedPrefsStorage(settingsPrefs); 146 storage = new SharedPrefsStorage(settingsPrefs);
149 147
150 AdblockEngine.Builder builder = AdblockEngine 148 AdblockEngine.Builder builder = AdblockEngine
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 } 216 }
219 217
220 private void disposeAdblock() 218 private void disposeAdblock()
221 { 219 {
222 Log.w(TAG, "Disposing adblock engine"); 220 Log.w(TAG, "Disposing adblock engine");
223 221
224 engine.dispose(); 222 engine.dispose();
225 engine = null; 223 engine = null;
226 224
227 storage = null; 225 storage = null;
228
229 // callbacks
230 this.isAllowedConnectionCallback.dispose();
231 this.isAllowedConnectionCallback = null;
232 } 226 }
233 227
234 /** 228 /**
235 * Get registered clients count 229 * Get registered clients count
236 * @return registered clients count 230 * @return registered clients count
237 */ 231 */
238 public int getCounter() 232 public int getCounter()
239 { 233 {
240 return referenceCounter.get(); 234 return referenceCounter.get();
241 } 235 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 engineCreated.countDown(); 285 engineCreated.countDown();
292 engineCreated = null; 286 engineCreated = null;
293 } 287 }
294 else 288 else
295 { 289 {
296 disposeAdblock(); 290 disposeAdblock();
297 } 291 }
298 } 292 }
299 } 293 }
300 } 294 }
OLDNEW
« no previous file with comments | « no previous file | libadblockplus-android-settings/src/org/adblockplus/libadblockplus/android/settings/IsAllowedConnectionCallbackImpl.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld