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

Delta Between Two Patch Sets: mobile/android/base/java/org/adblockplus/browser/SubscriptionContainer.java

Issue 29863604: Issue 6865 - Update ABP dependency to version 3.2 (Closed)
Left Patch Set: Removing allowed contexts Created Aug. 28, 2018, 5:08 p.m.
Right Patch Set: Adjusting code style Created Jan. 16, 2019, 1:45 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 private final List<SubscriptionContainer.Subscription> entries = new ArrayList <>(); 45 private final List<SubscriptionContainer.Subscription> entries = new ArrayList <>();
46 private final HashMap<String, SubscriptionContainer.Subscription> urlMap = new HashMap<>(); 46 private final HashMap<String, SubscriptionContainer.Subscription> urlMap = new HashMap<>();
47 private final List<WeakReference<SubscriptionListener>> subscriptionListeners = new ArrayList<>(); 47 private final List<WeakReference<SubscriptionListener>> subscriptionListeners = new ArrayList<>();
48 48
49 // prevent external instantiation 49 // prevent external instantiation
50 private SubscriptionContainer(final Context context) 50 private SubscriptionContainer(final Context context)
51 { 51 {
52 loadSubscriptions(context); 52 loadSubscriptions(context);
53 } 53 }
54 54
55 public final static SubscriptionContainer create(Context context) 55 public final static SubscriptionContainer create(final Context context)
56 { 56 {
57 return create(context, true); 57 return create(context, true);
58 } 58 }
59 59
60 public final static SubscriptionContainer create(Context context, final boolea n refresh) 60 public final static SubscriptionContainer create(final Context context, final boolean refresh)
61 { 61 {
62 final SubscriptionContainer sc = new SubscriptionContainer(context); 62 final SubscriptionContainer sc = new SubscriptionContainer(context);
63 63
64 for (final SubscriptionContainer.Subscription e : sc.entries) 64 for (final SubscriptionContainer.Subscription e : sc.entries)
65 { 65 {
66 sc.urlMap.put(e.url, e); 66 sc.urlMap.put(e.url, e);
67 sc.enableState.put(e.url, Boolean.FALSE); 67 sc.enableState.put(e.url, Boolean.FALSE);
68 } 68 }
69 69
70 if (refresh) 70 if (refresh)
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 iterator.remove(); 146 iterator.remove();
147 } 147 }
148 } 148 }
149 149
150 if (shouldAddListener) 150 if (shouldAddListener)
151 { 151 {
152 this.subscriptionListeners.add(new WeakReference<>(listener)); 152 this.subscriptionListeners.add(new WeakReference<>(listener));
153 } 153 }
154 } 154 }
155 155
156 private void loadSubscriptions(Context context) 156 private void loadSubscriptions(final Context context)
157 { 157 {
158 158
159 final XmlPullParser parser = Xml.newPullParser(); 159 final XmlPullParser parser = Xml.newPullParser();
160 try 160 try
161 { 161 {
162 final BufferedReader reader = new BufferedReader(new InputStreamReader( 162 final BufferedReader reader = new BufferedReader(new InputStreamReader(
163 context.getAssets().open("extensions/subscriptions.xml"))); 163 context.getAssets().open("extensions/subscriptions.xml")));
164 164
165 parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); 165 parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
166 parser.setInput(reader); 166 parser.setInput(reader);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 { 324 {
325 return this.specialization + " (" + this.title + ") @ " + this.url; 325 return this.specialization + " (" + this.title + ") @ " + this.url;
326 } 326 }
327 } 327 }
328 328
329 public interface SubscriptionListener 329 public interface SubscriptionListener
330 { 330 {
331 void onSubscriptionUpdated(); 331 void onSubscriptionUpdated();
332 } 332 }
333 } 333 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld