diff options
| author | nicolasroard <nicolasroard@google.com> | 2012-10-16 14:25:09 -0700 |
|---|---|---|
| committer | nicolasroard <nicolasroard@google.com> | 2012-10-16 14:25:09 -0700 |
| commit | e34a5a5eaedb870798a5cc7415079d04a6ca42e0 (patch) | |
| tree | ec2acd1dc8d61dcc441d9979fed8c5019cfa18c0 | |
| parent | 20fb632c407a2dfb5ec769560c61deacc77b8764 (diff) | |
| download | android_packages_apps_Gallery2-e34a5a5eaedb870798a5cc7415079d04a6ca42e0.tar.gz android_packages_apps_Gallery2-e34a5a5eaedb870798a5cc7415079d04a6ca42e0.tar.bz2 android_packages_apps_Gallery2-e34a5a5eaedb870798a5cc7415079d04a6ca42e0.zip | |
Fix when we cannot load an image
bug:7321636
Change-Id: I82cd603d531a1b743737a7c5b65005d370f2cdb1
| -rw-r--r-- | res/values/filtershow_strings.xml | 3 | ||||
| -rw-r--r-- | src/com/android/gallery3d/filtershow/FilterShowActivity.java | 11 | ||||
| -rw-r--r-- | src/com/android/gallery3d/filtershow/cache/ImageLoader.java | 9 |
3 files changed, 21 insertions, 2 deletions
diff --git a/res/values/filtershow_strings.xml b/res/values/filtershow_strings.xml index e5d8b3f3f..51ff00ec2 100644 --- a/res/values/filtershow_strings.xml +++ b/res/values/filtershow_strings.xml @@ -21,6 +21,9 @@ <!-- Title for the image editor activity [CHAR LIMIT=NONE]--> <string name="title_activity_filter_show">FilterShowActivity</string> + <!-- String shown when we cannot load the image when starting the activity [CHAR LIMIT=NONE] --> + <string name="cannot_load_image">Cannot load the image!</string> + <!-- actionbar menu --> <!-- Text for the actionbar confirmation button [CHAR LIMIT=20] --> diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java index abbd596ab..f76179d8b 100644 --- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java +++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java @@ -31,6 +31,7 @@ import android.widget.ListView; import android.widget.SeekBar; import android.widget.ShareActionProvider; import android.widget.ShareActionProvider.OnShareTargetSelectedListener; +import android.widget.Toast; import com.android.gallery3d.R; import com.android.gallery3d.filtershow.cache.ImageLoader; @@ -145,7 +146,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, } }); - mImageLoader = new ImageLoader(getApplicationContext()); + mImageLoader = new ImageLoader(this, getApplicationContext()); LinearLayout listFilters = (LinearLayout) findViewById(R.id.listFilters); LinearLayout listBorders = (LinearLayout) findViewById(R.id.listBorders); @@ -729,6 +730,14 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, finish(); } } + + public void cannotLoadImage() { + CharSequence text = getString(R.string.cannot_load_image); + Toast toast = Toast.makeText(this, text, Toast.LENGTH_SHORT); + toast.show(); + finish(); + } + // ////////////////////////////////////////////////////////////////////////////// public float getPixelsFromDip(float value) { diff --git a/src/com/android/gallery3d/filtershow/cache/ImageLoader.java b/src/com/android/gallery3d/filtershow/cache/ImageLoader.java index 3fabc4493..eeba4da41 100644 --- a/src/com/android/gallery3d/filtershow/cache/ImageLoader.java +++ b/src/com/android/gallery3d/filtershow/cache/ImageLoader.java @@ -49,6 +49,8 @@ public class ImageLoader { private int mOrientation = 0; private HistoryAdapter mAdapter = null; + private FilterShowActivity mActivity = null; + private static final int ORI_NORMAL = ExifInterface.ORIENTATION_NORMAL; private static final int ORI_ROTATE_90 = ExifInterface.ORIENTATION_ROTATE_90; private static final int ORI_ROTATE_180 = ExifInterface.ORIENTATION_ROTATE_180; @@ -63,7 +65,8 @@ public class ImageLoader { private Rect mOriginalBounds = null; - public ImageLoader(Context context) { + public ImageLoader(FilterShowActivity activity, Context context) { + mActivity = activity; mContext = context; mCache = new DelayedPresetCache(this, 30); mHiresCache = new DelayedPresetCache(this, 2); @@ -74,6 +77,10 @@ public class ImageLoader { mOrientation = getOrientation(uri); mOriginalBitmapSmall = loadScaledBitmap(uri, 160); + if (mOriginalBitmapSmall == null) { + // Couldn't read the bitmap, let's exit + mActivity.cannotLoadImage(); + } mOriginalBitmapLarge = loadScaledBitmap(uri, size); updateBitmaps(); } |
