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

Unified Diff: mobile/android/thirdparty/org/adblockplus/browser/MoreSubscriptionsPreferenceGroup.java

Issue 29588596: Issue 5919 - Adjust our code to the new messaging system (Closed)
Patch Set: Adding missing return statements Created Nov. 2, 2017, 10:12 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
Index: mobile/android/thirdparty/org/adblockplus/browser/MoreSubscriptionsPreferenceGroup.java
===================================================================
--- a/mobile/android/thirdparty/org/adblockplus/browser/MoreSubscriptionsPreferenceGroup.java
+++ b/mobile/android/thirdparty/org/adblockplus/browser/MoreSubscriptionsPreferenceGroup.java
@@ -19,17 +19,17 @@ package org.adblockplus.browser;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.concurrent.Semaphore;
import org.mozilla.gecko.R;
import org.mozilla.gecko.preferences.CustomCheckBoxPreference;
-import org.mozilla.gecko.util.NativeJSObject;
+import org.mozilla.gecko.util.GeckoBundle;
import org.mozilla.gecko.util.ThreadUtils;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.Build;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.PreferenceGroup;
@@ -219,30 +219,30 @@ public class MoreSubscriptionsPreference
{
@Override
public void run()
{
try
{
final Semaphore finished = new Semaphore(0);
- AddOnBridge.addSubscription(new AdblockPlusApiCallback()
+ AddOnBridge.addSubscription(url, null, new AdblockPlusApiCallback()
{
@Override
- public void onApiRequestSucceeded(NativeJSObject jsObject)
+ public void onApiRequestSucceeded(GeckoBundle bundle)
{
finished.release();
}
@Override
public void onApiRequestFailed(String errorMessage)
{
finished.release();
}
- }, url, null);
+ });
finished.acquireUninterruptibly();
MoreSubscriptionsPreferenceGroup.this.activeSubscriptions.refresh();
ThreadUtils.postToUiThread(new Runnable()
{
@Override
@@ -289,39 +289,36 @@ public class MoreSubscriptionsPreference
public void refresh()
{
AddOnBridge.queryActiveSubscriptions(this);
this.entriesReady.acquireUninterruptibly();
}
@Override
- public void onApiRequestSucceeded(NativeJSObject jsObject)
+ public void onApiRequestSucceeded(GeckoBundle bundle)
{
try
{
this.enabledSubscriptions.clear();
- if (jsObject.getBoolean("success"))
+ final GeckoBundle[] subs = bundle.getBundleArray("value");
+ for (final GeckoBundle sub : subs)
{
- NativeJSObject[] subs = jsObject.getObjectArray("value");
- for (int i = 0; i < subs.length; i++)
- {
- final String url = subs[i].getString("url");
+ final String url = sub.getString("url");
- String title = subs[i].has("title") ? subs[i].getString("title") : url;
- if (title.startsWith("~user~"))
- {
- title = this.context.getString(R.string.abb_pref_category_whitelisted_sites);
- }
+ String title = sub.getString("title", url);
+ if (title.startsWith("~user~"))
+ {
+ title = this.context.getString(R.string.abb_pref_category_whitelisted_sites);
+ }
- if (!IGNORED_URLS.contains(url))
- {
- Log.d(TAG, "Adding: " + url + ", " + title);
- this.enabledSubscriptions.put(url, title);
- }
+ if (!IGNORED_URLS.contains(url))
+ {
+ Log.d(TAG, "Adding: " + url + ", " + title);
+ this.enabledSubscriptions.put(url, title);
}
}
}
finally
{
this.entriesReady.release();
}
}
@@ -341,28 +338,28 @@ public class MoreSubscriptionsPreference
{
if (preference instanceof CheckBoxPreference && newValue instanceof Boolean)
{
final CheckBoxPreference cbp = (CheckBoxPreference) preference;
final boolean enable = ((Boolean) newValue).booleanValue();
if (enable)
{
- AddOnBridge.addSubscription(this, cbp.getKey(), null);
+ AddOnBridge.addSubscription(cbp.getKey(), null, this);
}
else
{
- AddOnBridge.removeSubscription(this, cbp.getKey());
+ AddOnBridge.removeSubscription(cbp.getKey(), this);
}
}
return true;
}
@Override
- public void onApiRequestSucceeded(NativeJSObject jsObject)
+ public void onApiRequestSucceeded(GeckoBundle bundle)
{
// ignored
}
@Override
public void onApiRequestFailed(String errorMessage)
{
// ignored

Powered by Google App Engine
This is Rietveld