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

Unified Diff: libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java

Issue 29401555: Issue 5088 - Remove code duplicate for refresh subscriptions (Closed)
Patch Set: Created April 3, 2017, 6:13 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9f4e981b89aa4eb788acaff233f9f14abffbcba9..37daef0858e5e42d488d4f31bcd181d18e75e634 100644
--- a/libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java
+++ b/libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java
@@ -42,8 +42,6 @@ import org.adblockplus.libadblockplus.UpdateCheckDoneCallback;
import org.adblockplus.libadblockplus.WebRequest;
import android.content.Context;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager.NameNotFoundException;
anton 2017/04/03 06:17:54 not related by the task, but desired clean-up
import android.os.Build.VERSION;
import android.os.Handler;
import android.os.Looper;
@@ -251,29 +249,18 @@ public final class AdblockEngine
private final AndroidWebRequestResourceWrapper.Listener resourceWrapperListener =
new AndroidWebRequestResourceWrapper.Listener()
{
- private static final int UPDATE_DELAY_MS = 1 * 1000;
anton 2017/04/03 06:17:54 I'm not sure that 'refresh' is better than 'update
diegocarloslima 2017/04/07 09:36:54 Well, I think that update is a better term in this
Felix Dahlke 2017/04/10 11:59:47 I'd also go for "update", since that's the termino
+ private static final int REFRESH_DELAY_MS = 1 * 1000;
private final Handler handler = new Handler(Looper.getMainLooper());
- private final Runnable forceUpdateRunnable = new Runnable()
+ private final Runnable forceRefreshRunnable = new Runnable()
{
public void run() {
// Filter Engine can be already disposed
if (filterEngine != null)
{
- Log.d(TAG, "Force update subscriptions");
- List<Subscription> subscriptions = filterEngine.getListedSubscriptions();
- for (Subscription eachSubscription : subscriptions)
- {
- try
- {
- eachSubscription.updateFilters();
- }
- finally
- {
- eachSubscription.dispose();
- }
- }
+ Log.d(TAG, "Force refresh subscriptions");
+ AdblockEngine.this.refreshSubscriptions();
}
}
};
@@ -281,15 +268,15 @@ public final class AdblockEngine
@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
+ // we need to force refresh subscriptions ASAP after preloaded one is returned
+ // but we should note that multiple interceptions (for main easylist and AA) and force refresh once only
- // adding into main thread queue to avoid concurrency issues (start update while updating)
+ // adding into main thread queue to avoid concurrency issues (start refresh while refreshing)
// as usually onIntercepted() is invoked in background thread
- handler.removeCallbacks(forceUpdateRunnable);
- handler.postDelayed(forceUpdateRunnable, UPDATE_DELAY_MS);
+ handler.removeCallbacks(forceRefreshRunnable);
+ handler.postDelayed(forceRefreshRunnable, REFRESH_DELAY_MS);
- Log.d(TAG, "Scheduled force update in " + UPDATE_DELAY_MS);
+ Log.d(TAG, "Scheduled force refresh in " + REFRESH_DELAY_MS);
}
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld