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

Unified Diff: src/org/adblockplus/android/BridgeCommand.java

Issue 4705284891082752: Proxy configurators (Closed)
Patch Set: Created Aug. 11, 2014, 12:36 p.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
Index: src/org/adblockplus/android/BridgeCommand.java
diff --git a/src/org/adblockplus/android/AndroidFilterChangeCallback.java b/src/org/adblockplus/android/BridgeCommand.java
similarity index 51%
copy from src/org/adblockplus/android/AndroidFilterChangeCallback.java
copy to src/org/adblockplus/android/BridgeCommand.java
index f07836c5b4162160706fc92ea7c96df54e8235ab..e4fbb603f40a1506b8569b4818c352af72628c6d 100644
--- a/src/org/adblockplus/android/AndroidFilterChangeCallback.java
+++ b/src/org/adblockplus/android/BridgeCommand.java
@@ -17,29 +17,35 @@
package org.adblockplus.android;
-import org.adblockplus.libadblockplus.FilterChangeCallback;
-import org.adblockplus.libadblockplus.JsValue;
-import org.adblockplus.libadblockplus.Subscription;
+import java.util.HashMap;
+import java.util.Locale;
-import android.content.Context;
-
-public class AndroidFilterChangeCallback extends FilterChangeCallback
+public enum BridgeCommand
{
- private final Context context;
+ /** Used for e.g. no-traffic check, rebuilds/redisplays notification. */
+ STATE_CHANGED,
+ UNKNOWN;
- public AndroidFilterChangeCallback(final Context context)
- {
- this.context = context;
- }
+ private static final HashMap<String, BridgeCommand> MAP = new HashMap<String, BridgeCommand>();
- @Override
- public void filterChangeCallback(final String action, final JsValue jsValue)
+ static
{
- if (action.equals("subscription.lastDownload") || action.equals("subscription.downloadStatus"))
+ final Locale locale = Locale.getDefault();
Felix Dahlke 2014/08/19 09:06:00 Shouldn't we hard code EN-US here instead? Otherwi
René Jeschke 2014/08/19 10:41:33 Done.
+ for (final BridgeCommand e : BridgeCommand.values())
{
- final Subscription sub = new Subscription(jsValue);
-
- Utils.updateSubscriptionStatus(this.context, sub);
+ if (e != UNKNOWN)
+ {
+ final String name = e.toString();
+ MAP.put(name, e);
+ MAP.put(name.toLowerCase(locale), e);
+ MAP.put(name.toUpperCase(locale), e);
+ }
}
}
+
+ public static BridgeCommand fromString(final String str)
+ {
+ final BridgeCommand e = MAP.get(str);
Felix Dahlke 2014/08/19 09:06:00 I guess I'm missing something here, but wouldn't B
René Jeschke 2014/08/19 10:41:33 'valueOf' requires that 'str' exactly matches the
Felix Dahlke 2014/08/19 12:37:26 This seems overengineered. If we really do need a
René Jeschke 2014/08/19 12:57:36 I just don't know why you insist on replacing a fu
Felix Dahlke 2014/08/19 13:14:57 I just get the very strong expression that this is
René Jeschke 2014/08/19 13:23:53 Well, k. But I won't leave exception handling for
+ return e != null ? e : UNKNOWN;
+ }
}

Powered by Google App Engine
This is Rietveld