From f664866edca7b92b29ab9f4bc1dc2c2b009b7ee0 Mon Sep 17 00:00:00 2001 From: David Morrissey Date: Sun, 3 Apr 2016 11:01:52 +0100 Subject: [PATCH] #176 Catch and wrap OutOfMemoryErrors thrown when decoding bitmaps so listeners can be called --- .../labs/subscaleview/SubsamplingScaleImageView.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/library/src/com/davemorrissey/labs/subscaleview/SubsamplingScaleImageView.java b/library/src/com/davemorrissey/labs/subscaleview/SubsamplingScaleImageView.java index 2a330043..32bfea63 100644 --- a/library/src/com/davemorrissey/labs/subscaleview/SubsamplingScaleImageView.java +++ b/library/src/com/davemorrissey/labs/subscaleview/SubsamplingScaleImageView.java @@ -1505,6 +1505,9 @@ protected Bitmap doInBackground(Void... params) { } catch (Exception e) { Log.e(TAG, "Failed to decode tile", e); this.exception = e; + } catch (OutOfMemoryError e) { + Log.e(TAG, "Failed to decode tile - OutOfMemoryError", e); + this.exception = new RuntimeException(e); } return null; } @@ -1576,6 +1579,9 @@ protected Integer doInBackground(Void... params) { } catch (Exception e) { Log.e(TAG, "Failed to load bitmap", e); this.exception = e; + } catch (OutOfMemoryError e) { + Log.e(TAG, "Failed to load bitmap - OutOfMemoryError", e); + this.exception = new RuntimeException(e); } return null; }