summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLi Sun <sunli@codeaurora.org>2013-08-07 14:08:06 +0800
committerLinux Build Service Account <lnxbuild@localhost>2014-11-04 08:23:17 -0700
commit90ade05b6276acb084d490003253d7e3d35e1c47 (patch)
tree9b76be6346da3ffc8681bcbf6d11f001320d8c0f
parent9043df532143a9eb751e2b095ae495ae8a5f054e (diff)
downloadandroid_packages_apps_Gallery2-staging/cm-12.0-caf.tar.gz
android_packages_apps_Gallery2-staging/cm-12.0-caf.tar.bz2
android_packages_apps_Gallery2-staging/cm-12.0-caf.zip
Gallery2: avoid the crash of gallery during trimming videostaging/cm-12.0-caf
- Google only provides the lib of mp4 parser to support the video-trim feature. But some files would fail to trim and cause the gallery crash - catch the IllegalStateException to avoid the crash of gallery Change-Id: Iadda7a42d4d694c102d50d2c52a93979ba2907a7 CRs-Fixed: 523986
-rw-r--r--res/values/strings.xml3
-rw-r--r--src/com/android/gallery3d/app/TrimVideo.java22
2 files changed, 25 insertions, 0 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 13027efd7..e19f95082 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1118,4 +1118,7 @@ CHAR LIMIT = NONE] -->
<item quantity="one">%1$d photo</item>
<item quantity="other">%1$d photos</item>
</plurals>
+
+ <!-- The tips of trimming video -->
+ <string name="fail_trim">Sorry, this video file can not be trimmed</string>
</resources>
diff --git a/src/com/android/gallery3d/app/TrimVideo.java b/src/com/android/gallery3d/app/TrimVideo.java
index b0ed8e635..a1fd26c4a 100644
--- a/src/com/android/gallery3d/app/TrimVideo.java
+++ b/src/com/android/gallery3d/app/TrimVideo.java
@@ -237,6 +237,7 @@ public class TrimVideo extends Activity implements
new Thread(new Runnable() {
@Override
public void run() {
+ boolean hasError = false;
try {
VideoUtils.startTrim(mSrcFile, mDstFileInfo.mFile,
mTrimStartTime, mTrimEndTime);
@@ -244,7 +245,28 @@ public class TrimVideo extends Activity implements
SaveVideoFileUtils.insertContent(mDstFileInfo,
getContentResolver(), mUri);
} catch (IOException e) {
+ hasError = true;
e.printStackTrace();
+ } catch (IllegalStateException e) {
+ hasError = true;
+ e.printStackTrace();
+ }
+ //If the exception happens,just notify the UI and avoid the crash.
+ if (hasError){
+ mHandler.post(new Runnable(){
+ @Override
+ public void run(){
+ Toast.makeText(getApplicationContext(),
+ getString(R.string.fail_trim),
+ Toast.LENGTH_SHORT)
+ .show();
+ if (mProgress != null) {
+ mProgress.dismiss();
+ mProgress = null;
+ }
+ }
+ });
+ return;
}
// After trimming is done, trigger the UI changed.
mHandler.post(new Runnable() {