[Android] Prevent IllegalArgumentException
Geoffrey Métais
git at videolan.org
Mon Sep 4 10:14:35 CEST 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Sep 4 10:08:59 2017 +0200| [d1fde6366edc79ac1abbed2a8d01c36337adfc13] | committer: Geoffrey Métais
Prevent IllegalArgumentException
> https://code.videolan.org/videolan/vlc-android/commit/d1fde6366edc79ac1abbed2a8d01c36337adfc13
---
.../org/videolan/vlc/gui/helpers/BitmapUtil.java | 24 +++++++++-------------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/BitmapUtil.java b/vlc-android/src/org/videolan/vlc/gui/helpers/BitmapUtil.java
index 4b8009710..e78194a5b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/BitmapUtil.java
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/BitmapUtil.java
@@ -97,7 +97,7 @@ public class BitmapUtil {
}
}
- public static Bitmap fetchPicture(MediaWrapper media) {
+ private static Bitmap fetchPicture(MediaWrapper media) {
final BitmapCache cache = BitmapCache.getInstance();
Bitmap picture = readCoverBitmap(media.getArtworkURL());
@@ -175,32 +175,28 @@ public class BitmapUtil {
/**
* A helper function to return the byte usage per pixel of a bitmap based on its configuration.
*/
- static int getBytesPerPixel(Bitmap.Config config) {
- if (config == Bitmap.Config.ARGB_8888) {
+ private static int getBytesPerPixel(Bitmap.Config config) {
+ if (config == Bitmap.Config.ARGB_8888)
return 4;
- } else if (config == Bitmap.Config.RGB_565) {
+ else if (config == Bitmap.Config.RGB_565)
return 2;
- } else if (config == Bitmap.Config.ARGB_4444) {
+ else if (config == Bitmap.Config.ARGB_4444)
return 2;
- } else if (config == Bitmap.Config.ALPHA_8) {
+ else
return 1;
- }
- return 1;
}
public static Bitmap centerCrop(Bitmap srcBmp, int width, int height) {
- Bitmap dstBmp;
- int widthDiff = srcBmp.getWidth()-width;
- int heightDiff = srcBmp.getHeight()-height;
- if (widthDiff == 0 && heightDiff == 0)
+ final int widthDiff = srcBmp.getWidth()-width;
+ final int heightDiff = srcBmp.getHeight()-height;
+ if (widthDiff <= 0 && heightDiff <= 0)
return srcBmp;
- dstBmp = Bitmap.createBitmap(
+ return Bitmap.createBitmap(
srcBmp,
widthDiff/2,
heightDiff/2,
width,
height
);
- return dstBmp;
}
}
More information about the Android
mailing list