summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/MenuHelper.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/camera/MenuHelper.java')
-rw-r--r--src/com/android/camera/MenuHelper.java135
1 files changed, 73 insertions, 62 deletions
diff --git a/src/com/android/camera/MenuHelper.java b/src/com/android/camera/MenuHelper.java
index 034c441..1976444 100644
--- a/src/com/android/camera/MenuHelper.java
+++ b/src/com/android/camera/MenuHelper.java
@@ -290,74 +290,84 @@ public class MenuHelper {
d.findViewById(R.id.details_codec_row).setVisibility(View.GONE);
} else {
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
- retriever.setMode(MediaMetadataRetriever.MODE_GET_METADATA_ONLY);
- retriever.setDataSource(image.getDataPath());
try {
- dimensionWidth = Integer.parseInt(
- retriever.extractMetadata(
- MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH));
- dimensionHeight = Integer.parseInt(
- retriever.extractMetadata(
- MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT));
- } catch (NumberFormatException e) {
- dimensionWidth = 0;
- dimensionHeight = 0;
- }
-
- try {
- int durationMs = Integer.parseInt(retriever.extractMetadata(
- MediaMetadataRetriever.METADATA_KEY_DURATION));
- String durationValue = formatDuration(
- activity, durationMs);
- ((TextView)d.findViewById(R.id.details_duration_value))
- .setText(durationValue);
- } catch (NumberFormatException e) {
- d.findViewById(R.id.details_frame_rate_row)
- .setVisibility(View.GONE);
- }
+ retriever.setMode(MediaMetadataRetriever.MODE_GET_METADATA_ONLY);
+ retriever.setDataSource(image.getDataPath());
+ try {
+ dimensionWidth = Integer.parseInt(
+ retriever.extractMetadata(
+ MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH));
+ dimensionHeight = Integer.parseInt(
+ retriever.extractMetadata(
+ MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT));
+ } catch (NumberFormatException e) {
+ dimensionWidth = 0;
+ dimensionHeight = 0;
+ }
- try {
- String frame_rate = String.format(
- activity.getString(R.string.details_fps),
- Integer.parseInt(
- retriever.extractMetadata(
- MediaMetadataRetriever.METADATA_KEY_FRAME_RATE)));
- ((TextView)d.findViewById(R.id.details_frame_rate_value))
- .setText(frame_rate);
- } catch (NumberFormatException e) {
- d.findViewById(R.id.details_frame_rate_row)
- .setVisibility(View.GONE);
- }
+ try {
+ int durationMs = Integer.parseInt(retriever.extractMetadata(
+ MediaMetadataRetriever.METADATA_KEY_DURATION));
+ String durationValue = formatDuration(
+ activity, durationMs);
+ ((TextView)d.findViewById(R.id.details_duration_value))
+ .setText(durationValue);
+ } catch (NumberFormatException e) {
+ d.findViewById(R.id.details_frame_rate_row)
+ .setVisibility(View.GONE);
+ }
- try {
- long bitRate = Long.parseLong(retriever.extractMetadata(
- MediaMetadataRetriever.METADATA_KEY_BIT_RATE));
- String bps;
- if (bitRate < 1000000) {
- bps = String.format(
- activity.getString(R.string.details_kbps),
- bitRate / 1000);
- } else {
- bps = String.format(
- activity.getString(R.string.details_mbps),
- ((double) bitRate) / 1000000.0);
+ try {
+ String frame_rate = String.format(
+ activity.getString(R.string.details_fps),
+ Integer.parseInt(
+ retriever.extractMetadata(
+ MediaMetadataRetriever.METADATA_KEY_FRAME_RATE)));
+ ((TextView)d.findViewById(R.id.details_frame_rate_value))
+ .setText(frame_rate);
+ } catch (NumberFormatException e) {
+ d.findViewById(R.id.details_frame_rate_row)
+ .setVisibility(View.GONE);
}
- ((TextView)d.findViewById(R.id.details_bit_rate_value))
- .setText(bps);
- } catch (NumberFormatException e) {
- d.findViewById(R.id.details_bit_rate_row)
- .setVisibility(View.GONE);
- }
- String format = retriever.extractMetadata(
- MediaMetadataRetriever.METADATA_KEY_VIDEO_FORMAT);
- ((TextView)d.findViewById(R.id.details_format_value))
- .setText(format);
+ try {
+ long bitRate = Long.parseLong(retriever.extractMetadata(
+ MediaMetadataRetriever.METADATA_KEY_BIT_RATE));
+ String bps;
+ if (bitRate < 1000000) {
+ bps = String.format(
+ activity.getString(R.string.details_kbps),
+ bitRate / 1000);
+ } else {
+ bps = String.format(
+ activity.getString(R.string.details_mbps),
+ ((double) bitRate) / 1000000.0);
+ }
+ ((TextView)d.findViewById(R.id.details_bit_rate_value))
+ .setText(bps);
+ } catch (NumberFormatException e) {
+ d.findViewById(R.id.details_bit_rate_row)
+ .setVisibility(View.GONE);
+ }
- String codec = retriever.extractMetadata(
- MediaMetadataRetriever.METADATA_KEY_CODEC);
- ((TextView)d.findViewById(R.id.details_codec_value))
- .setText(codec);
+ String format = retriever.extractMetadata(
+ MediaMetadataRetriever.METADATA_KEY_VIDEO_FORMAT);
+ ((TextView)d.findViewById(R.id.details_format_value))
+ .setText(format);
+
+ String codec = retriever.extractMetadata(
+ MediaMetadataRetriever.METADATA_KEY_CODEC);
+ ((TextView)d.findViewById(R.id.details_codec_value))
+ .setText(codec);
+ } catch(RuntimeException ex) {
+ // Assume this is a corrupt video file.
+ } finally {
+ try {
+ retriever.release();
+ } catch (RuntimeException ex) {
+ // Ignore failures while cleaning up.
+ }
+ }
}
String dimensionsString = String.format(
@@ -512,6 +522,7 @@ public class MenuHelper {
static void gotoStillImageCapture(Activity activity) {
Intent intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try {
activity.startActivity(intent);
} catch (ActivityNotFoundException e) {