Index: libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java |
diff --git a/libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java b/libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java |
index 3afec963c4a28cd2c762b6522536e2daad8c69f9..8a433df778c13ac951dd445cfaa5cc2bb83bc0fb 100644 |
--- a/libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java |
+++ b/libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java |
@@ -202,7 +202,26 @@ public final class AdblockEngine |
{ |
AndroidWebRequestResourceWrapper wrapper = new AndroidWebRequestResourceWrapper( |
context, engine.webRequest, urlToResourceIdMap, resourceStorage); |
- wrapper.setListener(engine.resourceWrapperListener); |
+ wrapper.setListener(new AndroidWebRequestResourceWrapper.Listener() |
+ { |
+ private AdblockEngine adblockEngine; |
+ |
+ AndroidWebRequestResourceWrapper.Listener init(AdblockEngine adblockEngine) |
+ { |
+ this.adblockEngine = adblockEngine; |
+ return this; |
+ } |
+ |
+ @Override |
+ public void onIntercepted(String url, int resourceId) |
+ { |
+ Log.d(TAG, "Force subscription update for intercepted URL " + url); |
+ if (this.adblockEngine.filterEngine != null) |
+ { |
+ this.adblockEngine.filterEngine.updateFiltersAsync(url); |
+ } |
+ } |
+ }.init(this.engine)); |
engine.webRequest = wrapper; |
} |
@@ -259,40 +278,6 @@ public final class AdblockEngine |
return new Builder(appInfo, basePath); |
} |
- private final AndroidWebRequestResourceWrapper.Listener resourceWrapperListener = |
- new AndroidWebRequestResourceWrapper.Listener() |
- { |
- private static final int UPDATE_DELAY_MS = 1 * 1000; |
- |
- private final Handler handler = new Handler(Looper.getMainLooper()); |
- |
- private final Runnable forceUpdateRunnable = new Runnable() |
- { |
- public void run() { |
- // Filter Engine can be already disposed |
- if (filterEngine != null) |
- { |
- Log.d(TAG, "Force update subscriptions"); |
- AdblockEngine.this.updateSubscriptions(); |
- } |
- } |
- }; |
- |
- @Override |
- public void onIntercepted(String url, int resourceId) |
- { |
- // we need to force update subscriptions ASAP after preloaded one is returned |
- // but we should note that multiple interceptions (for main easylist and AA) and force update once only |
- |
- // adding into main thread queue to avoid concurrency issues (start update while updating) |
- // as usually onIntercepted() is invoked in background thread |
- handler.removeCallbacks(forceUpdateRunnable); |
- handler.postDelayed(forceUpdateRunnable, UPDATE_DELAY_MS); |
- |
- Log.d(TAG, "Scheduled force update in " + UPDATE_DELAY_MS); |
- } |
- }; |
- |
public void dispose() |
{ |
Log.w(TAG, "Dispose"); |
@@ -495,21 +480,6 @@ public final class AdblockEngine |
} |
} |
- public void updateSubscriptions() |
- { |
- for (final Subscription s : this.filterEngine.getListedSubscriptions()) |
- { |
- try |
- { |
- s.updateFilters(); |
- } |
- finally |
- { |
- s.dispose(); |
- } |
- } |
- } |
- |
public void setEnabled(final boolean enabled) |
{ |
this.enabled = enabled; |