Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 90ade05b authored by Li Sun's avatar Li Sun Committed by Linux Build Service Account
Browse files

Gallery2: avoid the crash of gallery during trimming video

- 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
parent 9043df53
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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>
+22 −0
Original line number Diff line number Diff line
@@ -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() {