From 980724bab5c59526803b302ccba25a9f50f27d1c Mon Sep 17 00:00:00 2001 From: Chih-Chung Chang Date: Wed, 22 Feb 2012 08:00:31 +0800 Subject: Remove unused code. Change-Id: I167596ab023671651df298ddb2b80b7c782f4223 --- .../com/android/gallery3d/common/BitmapUtils.java | 25 ------- .../src/com/android/gallery3d/common/Utils.java | 83 ---------------------- 2 files changed, 108 deletions(-) (limited to 'gallerycommon/src/com/android/gallery3d/common') diff --git a/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java b/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java index 67aa6d77b..75ae25fc1 100644 --- a/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java +++ b/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java @@ -113,15 +113,6 @@ public class BitmapUtils { : (initialSize + 7) / 8 * 8; } - public static Bitmap resizeDownToPixels( - Bitmap bitmap, int targetPixels, boolean recycle) { - int width = bitmap.getWidth(); - int height = bitmap.getHeight(); - float scale = FloatMath.sqrt((float) targetPixels / (width * height)); - if (scale >= 1.0f) return bitmap; - return resizeBitmapByScale(bitmap, scale, recycle); - } - public static Bitmap resizeBitmapByScale( Bitmap bitmap, float scale, boolean recycle) { int width = Math.round(bitmap.getWidth() * scale); @@ -166,22 +157,6 @@ public class BitmapUtils { return resizeBitmapByScale(bitmap, scale, recycle); } - // Crops a square from the center of the original image. - public static Bitmap cropCenter(Bitmap bitmap, boolean recycle) { - int width = bitmap.getWidth(); - int height = bitmap.getHeight(); - if (width == height) return bitmap; - int size = Math.min(width, height); - - Bitmap target = Bitmap.createBitmap(size, size, getConfig(bitmap)); - Canvas canvas = new Canvas(target); - canvas.translate((size - width) / 2, (size - height) / 2); - Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG); - canvas.drawBitmap(bitmap, 0, 0, paint); - if (recycle) bitmap.recycle(); - return target; - } - public static Bitmap resizeDownAndCropCenter(Bitmap bitmap, int size, boolean recycle) { int w = bitmap.getWidth(); diff --git a/gallerycommon/src/com/android/gallery3d/common/Utils.java b/gallerycommon/src/com/android/gallery3d/common/Utils.java index 6996015a3..bbe2a5d55 100644 --- a/gallerycommon/src/com/android/gallery3d/common/Utils.java +++ b/gallerycommon/src/com/android/gallery3d/common/Utils.java @@ -76,13 +76,6 @@ public class Utils { return (a == b) || (a == null ? false : a.equals(b)); } - // Returns true if the input is power of 2. - // Throws IllegalArgumentException if the input is <= 0. - public static boolean isPowerOf2(int n) { - if (n <= 0) throw new IllegalArgumentException(); - return (n & -n) == n; - } - // Returns the next power of two. // Returns the input if it is already power of 2. // Throws IllegalArgumentException if the input is <= 0 or @@ -106,13 +99,6 @@ public class Utils { return Integer.highestOneBit(n); } - // Returns the euclidean distance between (x, y) and (sx, sy). - public static float distance(float x, float y, float sx, float sy) { - float dx = x - sx; - float dy = y - sy; - return (float) Math.hypot(dx, dy); - } - // Returns the input value x clamped to the range [min, max]. public static int clamp(int x, int min, int max) { if (x > max) return max; @@ -138,12 +124,6 @@ public class Utils { return color >>> 24 == 0xFF; } - public static void swap(T[] array, int i, int j) { - T temp = array[i]; - array[i] = array[j]; - array[j] = temp; - } - public static void swap(int[] array, int i, int j) { int temp = array[i]; array[i] = array[j]; @@ -261,15 +241,6 @@ public class Utils { return value == null ? "" : value; } - // Used for debugging. Should be removed before submitting. - public static void debug(String format, Object ... args) { - if (args.length == 0) { - Log.d(DEBUG_TAG, format); - } else { - Log.d(DEBUG_TAG, String.format(format, args)); - } - } - public static float parseFloatSafely(String content, float defaultValue) { if (content == null) return defaultValue; try { @@ -292,22 +263,6 @@ public class Utils { return TextUtils.isEmpty(exifMake); } - public static boolean hasSpaceForSize(long size) { - String state = Environment.getExternalStorageState(); - if (!Environment.MEDIA_MOUNTED.equals(state)) { - return false; - } - - String path = Environment.getExternalStorageDirectory().getPath(); - try { - StatFs stat = new StatFs(path); - return stat.getAvailableBlocks() * (long) stat.getBlockSize() > size; - } catch (Exception e) { - Log.i(TAG, "Fail to access external storage", e); - } - return false; - } - public static void waitWithoutInterrupt(Object object) { try { object.wait(); @@ -316,16 +271,6 @@ public class Utils { } } - public static void shuffle(int array[], Random random) { - for (int i = array.length; i > 0; --i) { - int t = random.nextInt(i); - if (t == i - 1) continue; - int tmp = array[i - 1]; - array[i - 1] = array[t]; - array[t] = tmp; - } - } - public static boolean handleInterrruptedException(Throwable e) { // A helper to deal with the interrupt exception // If an interrupt detected, we will setup the bit again. @@ -382,34 +327,6 @@ public class Utils { return result; } - public static PendingIntent deserializePendingIntent(byte[] rawPendingIntent) { - Parcel parcel = null; - try { - if (rawPendingIntent != null) { - parcel = Parcel.obtain(); - parcel.unmarshall(rawPendingIntent, 0, rawPendingIntent.length); - return PendingIntent.readPendingIntentOrNullFromParcel(parcel); - } else { - return null; - } - } catch (Exception e) { - throw new IllegalArgumentException("error parsing PendingIntent"); - } finally { - if (parcel != null) parcel.recycle(); - } - } - - public static byte[] serializePendingIntent(PendingIntent pendingIntent) { - Parcel parcel = null; - try { - parcel = Parcel.obtain(); - PendingIntent.writePendingIntentOrNullToParcel(pendingIntent, parcel); - return parcel.marshall(); - } finally { - if (parcel != null) parcel.recycle(); - } - } - // Mask information for debugging only. It returns info.toString() directly // for debugging build (i.e., 'eng' and 'userdebug') and returns a mask ("****") // in release build to protect the information (e.g. for privacy issue). -- cgit v1.2.3