mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-28 05:13:53 +01:00
Catch exceptions in Zoom.java
This commit is contained in:
parent
50b674f221
commit
0d282af0e6
1 changed files with 10 additions and 3 deletions
|
|
@ -15,6 +15,8 @@ import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
public class Zoom {
|
public class Zoom {
|
||||||
|
|
||||||
private View thumbView;
|
private View thumbView;
|
||||||
|
|
@ -23,7 +25,6 @@ public class Zoom {
|
||||||
private ContentResolver contentResolver;
|
private ContentResolver contentResolver;
|
||||||
private FrameLayout flContainer;
|
private FrameLayout flContainer;
|
||||||
|
|
||||||
|
|
||||||
Zoom(View thumbView, FrameLayout flContainer, InputStream input, Uri imageUri, ContentResolver contentResolver) {
|
Zoom(View thumbView, FrameLayout flContainer, InputStream input, Uri imageUri, ContentResolver contentResolver) {
|
||||||
this.thumbView = thumbView;
|
this.thumbView = thumbView;
|
||||||
this.input = input;
|
this.input = input;
|
||||||
|
|
@ -36,12 +37,16 @@ public class Zoom {
|
||||||
|
|
||||||
Bitmap scaled = null;
|
Bitmap scaled = null;
|
||||||
BitmapRegionDecoder decoder = null;
|
BitmapRegionDecoder decoder = null;
|
||||||
|
Bitmap bitmap = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
decoder = BitmapRegionDecoder.newInstance(input, false);
|
decoder = BitmapRegionDecoder.newInstance(input, false);
|
||||||
|
bitmap = decoder.decodeRegion(new Rect(10, 10, 50, 50), null);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
Timber.e(e);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
Timber.e(e);
|
||||||
}
|
}
|
||||||
Bitmap bitmap = decoder.decodeRegion(new Rect(10, 10, 50, 50), null);
|
|
||||||
try {
|
try {
|
||||||
//Compress the Image
|
//Compress the Image
|
||||||
System.gc();
|
System.gc();
|
||||||
|
|
@ -55,7 +60,9 @@ public class Zoom {
|
||||||
long calWidth = (long) ((width * maxMemory) / (bitmapByteCount * 1.1));
|
long calWidth = (long) ((width * maxMemory) / (bitmapByteCount * 1.1));
|
||||||
scaled = Bitmap.createScaledBitmap(bitmap, (int) Math.min(width, calWidth), (int) Math.min(height, calHeight), true);
|
scaled = Bitmap.createScaledBitmap(bitmap, (int) Math.min(width, calWidth), (int) Math.min(height, calHeight), true);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
Timber.e(e);
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
|
Timber.e(e);
|
||||||
scaled = bitmap;
|
scaled = bitmap;
|
||||||
}
|
}
|
||||||
return scaled;
|
return scaled;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue