Bitmapfun Sample: Minor updates to match zip file in training class.

Change-Id: I0fa13d5d8947532e9b5906b863ca75e5c85ac544
diff --git a/samples/training/bitmapfun/BitmapFun/src/main/java/com/example/android/bitmapfun/util/ImageCache.java b/samples/training/bitmapfun/BitmapFun/src/main/java/com/example/android/bitmapfun/util/ImageCache.java
index 7dd8e25..145c881 100644
--- a/samples/training/bitmapfun/BitmapFun/src/main/java/com/example/android/bitmapfun/util/ImageCache.java
+++ b/samples/training/bitmapfun/BitmapFun/src/main/java/com/example/android/bitmapfun/util/ImageCache.java
@@ -506,20 +506,23 @@
     private static boolean canUseForInBitmap(
             Bitmap candidate, BitmapFactory.Options targetOptions) {
 
-        if (Utils.hasKitKat()) {
-            int width = targetOptions.outWidth / targetOptions.inSampleSize;
-            int height = targetOptions.outHeight / targetOptions.inSampleSize;
-            int byteCount = width * height * getBytesPerPixel(candidate.getConfig());
-            return byteCount <= candidate.getAllocationByteCount();
+        if (!Utils.hasKitKat()) {
+            // On earlier versions, the dimensions must match exactly and the inSampleSize must be 1
+            return candidate.getWidth() == targetOptions.outWidth
+                    && candidate.getHeight() == targetOptions.outHeight
+                    && targetOptions.inSampleSize == 1;
         }
 
-        return candidate.getWidth() == targetOptions.outWidth
-                && candidate.getHeight() == targetOptions.outHeight
-                && targetOptions.inSampleSize <= 1;
+        // From Android 4.4 (KitKat) onward we can re-use if the byte size of the new bitmap
+        // is smaller than the reusable bitmap candidate allocation byte count.
+        int width = targetOptions.outWidth / targetOptions.inSampleSize;
+        int height = targetOptions.outHeight / targetOptions.inSampleSize;
+        int byteCount = width * height * getBytesPerPixel(candidate.getConfig());
+        return byteCount <= candidate.getAllocationByteCount();
     }
 
     /**
-     * Return the byte usage per pixel of a bitmap based on it's configuration.
+     * Return the byte usage per pixel of a bitmap based on its configuration.
      * @param config The bitmap configuration.
      * @return The byte usage per pixel.
      */
@@ -528,6 +531,8 @@
             return 4;
         } else if (config == Config.RGB_565) {
             return 2;
+        } else if (config == Config.ARGB_4444) {
+            return 2;
         } else if (config == Config.ALPHA_8) {
             return 1;
         }
@@ -582,7 +587,10 @@
     }
 
     /**
-     * Get the size in bytes of a bitmap in a BitmapDrawable.
+     * Get the size in bytes of a bitmap in a BitmapDrawable. Note that from Android 4.4 (KitKat)
+     * onward this returns the allocated memory size of the bitmap which can be larger than the
+     * actual bitmap data byte count (in the case it was re-used).
+     *
      * @param value
      * @return size in bytes
      */
diff --git a/samples/training/bitmapfun/BitmapFun/src/main/java/com/example/android/bitmapfun/util/ImageResizer.java b/samples/training/bitmapfun/BitmapFun/src/main/java/com/example/android/bitmapfun/util/ImageResizer.java
index 596a991..e8ce4e1 100644
--- a/samples/training/bitmapfun/BitmapFun/src/main/java/com/example/android/bitmapfun/util/ImageResizer.java
+++ b/samples/training/bitmapfun/BitmapFun/src/main/java/com/example/android/bitmapfun/util/ImageResizer.java
@@ -207,12 +207,7 @@
             Bitmap inBitmap = cache.getBitmapFromReusableSet(options);
 
             if (inBitmap != null) {
-                if (BuildConfig.DEBUG) {
-                    Log.d(TAG, "Found bitmap to use for inBitmap");
-                }
                 options.inBitmap = inBitmap;
-            } else {
-                Log.d(TAG, "Did NOT find bitmap to use for inBitmap");
             }
         }
     }