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

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

Issue 29572644: Noissue - Lint adjustments
Patch Set: Created Oct. 10, 2017, 12:03 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: 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
@@ -37,18 +37,18 @@ import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
public class MoreSubscriptionsPreferenceGroup extends PreferenceGroup implements
UrlInputDialog.UrlReadyCallback
{
private static final String TAG = "AdblockBrowser.OtherPreferenceGroup";
- private static final HashMap<String, Integer> BUILTIN_URL_TO_INDEX = new HashMap<String, Integer>();
- private static final HashSet<String> IGNORED_URLS = new HashSet<String>();
+ private static final HashMap<String, Integer> BUILTIN_URL_TO_INDEX = new HashMap<>();
+ private static final HashSet<String> IGNORED_URLS = new HashSet<>();
private static SubscriptionContainer recommendedSubscriptions = null;
private final CheckBoxChangeListener checkBoxChangeListener = new CheckBoxChangeListener();
private final ActiveSubscriptionContainer activeSubscriptions;
private ProgressDialog progressDialog;
private static final int[] BUILTIN_TITLES =
{
@@ -69,17 +69,17 @@ public class MoreSubscriptionsPreference
"Fanboy's Social Blocking List",
"https://easylist-downloads.adblockplus.org/fanboy-social.txt"
};
static
{
for (int i = 0; i < BUILTIN_TITLES.length; i++)
{
- BUILTIN_URL_TO_INDEX.put(BUILTIN_LISTS[i * 2 + 1], Integer.valueOf(i));
+ BUILTIN_URL_TO_INDEX.put(BUILTIN_LISTS[i * 2 + 1], i);
}
IGNORED_URLS.add("https://easylist-downloads.adblockplus.org/exceptionrules.txt");
}
private synchronized static void initRecommendedSubscriptions()
{
if (recommendedSubscriptions == null)
@@ -107,35 +107,16 @@ public class MoreSubscriptionsPreference
@Override
protected View onCreateView(final ViewGroup parent)
{
this.setLayoutResource(R.layout.abb_minimal_widget);
return super.onCreateView(parent);
}
- public static Preference createCheckBoxOrSwitch(final Context context)
anton 2017/10/10 12:19:43 this seems to be not for lint change, is it?
diegocarloslima 2017/10/10 14:54:18 Yeah it was a lint warning for unused method. This
anton 2017/10/12 05:50:18 Acknowledged.
- {
- if (Build.VERSION.SDK_INT < 14)
- {
- return new CustomCheckBoxPreference(context);
- }
- try
- {
- return (Preference) Class.forName("android.preference.SwitchPreference")
- .getConstructor(Context.class)
- .newInstance(context);
- }
- catch (Exception e)
- {
- Log.e(TAG, "Failed to create SwitchPreference, falling back to CheckBoxPreference", e);
- return new CustomCheckBoxPreference(context);
- }
- }
-
@Override
protected void onAttachedToActivity()
{
this.setEnabled(false);
this.setShouldDisableView(true);
super.onAttachedToActivity();
@@ -273,17 +254,17 @@ public class MoreSubscriptionsPreference
}
Log.d(TAG, "Adding: " + url);
this.addNewSubscription(url);
}
private static class ActiveSubscriptionContainer implements AdblockPlusApiCallback
{
- public final HashMap<String, String> enabledSubscriptions = new HashMap<String, String>();
+ public final HashMap<String, String> enabledSubscriptions = new HashMap<>();
private final Semaphore entriesReady = new Semaphore(0);
private final Context context;
ActiveSubscriptionContainer(Context context)
{
this.context = context;
}
@@ -297,21 +278,21 @@ public class MoreSubscriptionsPreference
public void onApiRequestSucceeded(NativeJSObject jsObject)
{
try
{
this.enabledSubscriptions.clear();
if (jsObject.getBoolean("success"))
{
NativeJSObject[] subs = jsObject.getObjectArray("value");
- for (int i = 0; i < subs.length; i++)
+ for (final NativeJSObject sub : subs)
{
- final String url = subs[i].getString("url");
+ final String url = sub.getString("url");
- String title = subs[i].has("title") ? subs[i].getString("title") : url;
+ String title = sub.has("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);
@@ -337,17 +318,17 @@ public class MoreSubscriptionsPreference
AdblockPlusApiCallback
{
@Override
public boolean onPreferenceChange(Preference preference, Object newValue)
{
if (preference instanceof CheckBoxPreference && newValue instanceof Boolean)
{
final CheckBoxPreference cbp = (CheckBoxPreference) preference;
- final boolean enable = ((Boolean) newValue).booleanValue();
+ final boolean enable = (Boolean) newValue;
if (enable)
{
AddOnBridge.addSubscription(this, cbp.getKey(), null);
}
else
{
AddOnBridge.removeSubscription(this, cbp.getKey());

Powered by Google App Engine
This is Rietveld