diff options
4 files changed, 13 insertions, 14 deletions
diff --git a/android_webview/java/src/org/chromium/android_webview/AwResource.java b/android_webview/java/src/org/chromium/android_webview/AwResource.java index a4fddcb..ee658e4 100644 --- a/android_webview/java/src/org/chromium/android_webview/AwResource.java +++ b/android_webview/java/src/org/chromium/android_webview/AwResource.java @@ -5,6 +5,7 @@ package org.chromium.android_webview; import android.content.res.Resources; +import android.util.SparseArray; import org.chromium.base.CalledByNative; import org.chromium.base.JNINamespace; @@ -12,8 +13,6 @@ import org.chromium.base.JNINamespace; import java.io.IOException; import java.io.InputStreamReader; import java.lang.ref.SoftReference; -import java.util.HashMap; -import java.util.Map; import java.util.NoSuchElementException; import java.util.Scanner; @@ -41,14 +40,14 @@ public class AwResource { private static Resources sResources; // Loading some resources is expensive, so cache the results. - private static Map<Integer, SoftReference<String> > sResourceCache; + private static SparseArray<SoftReference<String>> sResourceCache; private static final int TYPE_STRING = 0; private static final int TYPE_RAW = 1; public static void setResources(Resources resources) { sResources = resources; - sResourceCache = new HashMap<Integer, SoftReference<String> >(); + sResourceCache = new SparseArray<SoftReference<String>>(); } public static void setErrorPageResources(int loaderror, int nodomain) { @@ -80,8 +79,8 @@ public class AwResource { assert sResources != null; assert sResourceCache != null; - String result = sResourceCache.get(resid) == null ? - null : sResourceCache.get(resid).get(); + SoftReference<String> stringRef = sResourceCache.get(resid); + String result = stringRef == null ? null : stringRef.get(); if (result == null) { switch (type) { case TYPE_STRING: diff --git a/build/android/lint/suppressions.xml b/build/android/lint/suppressions.xml index d6e7553..acf8af8 100644 --- a/build/android/lint/suppressions.xml +++ b/build/android/lint/suppressions.xml @@ -113,11 +113,6 @@ Still reading? <ignore path="content/public/android/java/src/org/chromium/content/browser/MediaResourceGetter.java"/> </issue> <issue id="SetJavaScriptEnabled" severity="ignore"/> - <issue id="UseSparseArrays"> - <ignore path="android_webview/java/src/org/chromium/android_webview/AwResource.java"/> - <ignore path="remoting/android/java/src/org/chromium/chromoting/TapGestureDetector.java"/> - <ignore path="ui/android/java/src/org/chromium/ui/base/WindowAndroid.java"/> - </issue> <issue id="ViewConstructor" severity="ignore"/> <issue id="WrongCall" severity="ignore"/> </lint> diff --git a/remoting/android/java/src/org/chromium/chromoting/TapGestureDetector.java b/remoting/android/java/src/org/chromium/chromoting/TapGestureDetector.java index fa30b02..32c37d7 100644 --- a/remoting/android/java/src/org/chromium/chromoting/TapGestureDetector.java +++ b/remoting/android/java/src/org/chromium/chromoting/TapGestureDetector.java @@ -8,11 +8,10 @@ import android.content.Context; import android.graphics.PointF; import android.os.Handler; import android.os.Message; +import android.util.SparseArray; import android.view.MotionEvent; import android.view.ViewConfiguration; -import java.util.HashMap; - /** * This class detects multi-finger tap and long-press events. This is provided since the stock * Android gesture-detectors only detect taps/long-presses made with one finger. @@ -49,7 +48,7 @@ public class TapGestureDetector { * Stores the location of each down MotionEvent (by pointer ID), for detecting motion of any * pointer beyond the TouchSlop region. */ - private HashMap<Integer, PointF> mInitialPositions = new HashMap<Integer, PointF>(); + private SparseArray<PointF> mInitialPositions = new SparseArray<PointF>(); /** * Threshold squared-distance, in pixels, to use for motion-detection. If a finger moves less diff --git a/ui/android/java/src/org/chromium/ui/base/WindowAndroid.java b/ui/android/java/src/org/chromium/ui/base/WindowAndroid.java index 03a3898..309b735 100644 --- a/ui/android/java/src/org/chromium/ui/base/WindowAndroid.java +++ b/ui/android/java/src/org/chromium/ui/base/WindowAndroid.java @@ -4,6 +4,7 @@ package org.chromium.ui.base; +import android.annotation.SuppressLint; import android.app.Activity; import android.app.PendingIntent; import android.content.ContentResolver; @@ -38,11 +39,16 @@ public class WindowAndroid { protected Context mApplicationContext; protected SparseArray<IntentCallback> mOutstandingIntents; + + // Ideally, this would be a SparseArray<String>, but there's no easy way to store a + // SparseArray<String> in a bundle during saveInstanceState(). So we use a HashMap and suppress + // the Android lint warning "UseSparseArrays". protected HashMap<Integer, String> mIntentErrors; /** * @param context The application context. */ + @SuppressLint("UseSparseArrays") public WindowAndroid(Context context) { assert context == context.getApplicationContext(); mApplicationContext = context; |