Bug 975173 - (Part 3) Declare local variables as final in getDrawable. r=jdover
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Sat, 22 Feb 2014 09:41:30 -0800
changeset 170450 eeda6a335f1401cd3cffe07b2c12952ecbeca046
parent 170449 af0f055d4ca33253aafee2bd2ca36e8e89611824
child 170451 fb9c889df184784af0519d8f5ac5fc350ebdc7de
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersjdover
bugs975173
milestone30.0a1
Bug 975173 - (Part 3) Declare local variables as final in getDrawable. r=jdover
mobile/android/base/gfx/BitmapUtils.java
--- a/mobile/android/base/gfx/BitmapUtils.java
+++ b/mobile/android/base/gfx/BitmapUtils.java
@@ -64,17 +64,17 @@ public final class BitmapUtils {
      */
     public static void getDrawable(final Context context, final String data, final BitmapLoader loader) {
         if (TextUtils.isEmpty(data)) {
             runOnBitmapFoundOnUiThread(loader, null);
             return;
         }
 
         if (data.startsWith("data")) {
-            BitmapDrawable d = new BitmapDrawable(context.getResources(), getBitmapFromDataURI(data));
+            final BitmapDrawable d = new BitmapDrawable(context.getResources(), getBitmapFromDataURI(data));
             runOnBitmapFoundOnUiThread(loader, d);
             return;
         }
 
         if (data.startsWith("jar:") || data.startsWith("file://")) {
             (new UiAsyncTask<Void, Void, Drawable>(ThreadUtils.getBackgroundHandler()) {
                 @Override
                 public Drawable doInBackground(Void... params) {
@@ -83,18 +83,18 @@ public final class BitmapUtils {
                             return GeckoJarReader.getBitmapDrawable(context.getResources(), data);
                         }
 
                         // Don't attempt to validate the JAR signature when loading an add-on icon
                         if (data.startsWith("jar:file")) {
                             return GeckoJarReader.getBitmapDrawable(context.getResources(), Uri.decode(data));
                         }
 
-                        URL url = new URL(data);
-                        InputStream is = (InputStream) url.getContent();
+                        final URL url = new URL(data);
+                        final InputStream is = (InputStream) url.getContent();
                         try {
                             return Drawable.createFromStream(is, "src");
                         } finally {
                             is.close();
                         }
                     } catch (Exception e) {
                         Log.w(LOGTAG, "Unable to set icon", e);
                     }
@@ -104,33 +104,33 @@ public final class BitmapUtils {
                 @Override
                 public void onPostExecute(Drawable drawable) {
                     loader.onBitmapFound(drawable);
                 }
             }).execute();
             return;
         }
 
-        if(data.startsWith("-moz-icon://")) {
-            Uri imageUri = Uri.parse(data);
-            String resource = imageUri.getSchemeSpecificPart();
-            resource = resource.substring(resource.lastIndexOf('/') + 1);
+        if (data.startsWith("-moz-icon://")) {
+            final Uri imageUri = Uri.parse(data);
+            final String ssp = imageUri.getSchemeSpecificPart();
+            final String resource = ssp.substring(ssp.lastIndexOf('/') + 1);
 
             try {
-                Drawable d = context.getPackageManager().getApplicationIcon(resource);
+                final Drawable d = context.getPackageManager().getApplicationIcon(resource);
                 runOnBitmapFoundOnUiThread(loader, d);
             } catch(Exception ex) { }
 
             return;
         }
 
-        if(data.startsWith("drawable://")) {
-            Uri imageUri = Uri.parse(data);
-            int id = getResource(imageUri, R.drawable.ic_status_logo);
-            Drawable d = context.getResources().getDrawable(id);
+        if (data.startsWith("drawable://")) {
+            final Uri imageUri = Uri.parse(data);
+            final int id = getResource(imageUri, R.drawable.ic_status_logo);
+            final Drawable d = context.getResources().getDrawable(id);
 
             runOnBitmapFoundOnUiThread(loader, d);
             return;
         }
 
         runOnBitmapFoundOnUiThread(loader, null);
     }