summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/MovieView.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/camera/MovieView.java')
-rw-r--r--src/com/android/camera/MovieView.java88
1 files changed, 50 insertions, 38 deletions
diff --git a/src/com/android/camera/MovieView.java b/src/com/android/camera/MovieView.java
index 091cc28..bf0e6ca 100644
--- a/src/com/android/camera/MovieView.java
+++ b/src/com/android/camera/MovieView.java
@@ -127,37 +127,46 @@ public class MovieView extends Activity implements MediaPlayer.OnErrorListener,
}
}
+ private static boolean uriSupportsBookmarks(Uri uri) {
+ String scheme = uri.getScheme();
+ String authority = uri.getAuthority();
+ return ("content".equalsIgnoreCase(scheme)
+ && MediaStore.AUTHORITY.equalsIgnoreCase(authority));
+ }
+
private Integer getBookmark() {
- String scheme = mUri.getScheme();
- if ("content".equalsIgnoreCase(scheme)) {
- String[] projection = new String[]{Video.VideoColumns.DURATION,
- Video.VideoColumns.BOOKMARK};
- try {
- Cursor cursor = getContentResolver().query(mUri, projection, null, null, null);
- if (cursor != null) {
- try {
- if ( cursor.moveToFirst() ) {
- int duration = getCursorInteger(cursor, 0);
- int bookmark = getCursorInteger(cursor, 1);
- final int ONE_MINUTE = 60 * 1000;
- final int TWO_MINUTES = 2 * ONE_MINUTE;
- final int FIVE_MINUTES = 5 * ONE_MINUTE;
- if ((bookmark < TWO_MINUTES)
- || (duration < FIVE_MINUTES)
- || (bookmark > (duration - ONE_MINUTE))) {
- return null;
- }
-
- return new Integer(bookmark);
+ if (!uriSupportsBookmarks(mUri)) {
+ return null;
+ }
+
+ String[] projection = new String[]{Video.VideoColumns.DURATION,
+ Video.VideoColumns.BOOKMARK};
+ try {
+ Cursor cursor = getContentResolver().query(mUri, projection, null, null, null);
+ if (cursor != null) {
+ try {
+ if ( cursor.moveToFirst() ) {
+ int duration = getCursorInteger(cursor, 0);
+ int bookmark = getCursorInteger(cursor, 1);
+ final int ONE_MINUTE = 60 * 1000;
+ final int TWO_MINUTES = 2 * ONE_MINUTE;
+ final int FIVE_MINUTES = 5 * ONE_MINUTE;
+ if ((bookmark < TWO_MINUTES)
+ || (duration < FIVE_MINUTES)
+ || (bookmark > (duration - ONE_MINUTE))) {
+ return null;
}
- } finally {
- cursor.close();
+
+ return new Integer(bookmark);
}
+ } finally {
+ cursor.close();
}
- } catch (SQLiteException e) {
- // ignore
}
+ } catch (SQLiteException e) {
+ // ignore
}
+
return null;
}
@@ -173,19 +182,22 @@ public class MovieView extends Activity implements MediaPlayer.OnErrorListener,
}
private void setBookmark(int bookmark) {
- String scheme = mUri.getScheme();
- if ("content".equalsIgnoreCase(scheme)) {
- ContentValues values = new ContentValues();
- values.put(Video.VideoColumns.BOOKMARK, Integer.toString(bookmark));
- try {
- getContentResolver().update(mUri, values, null, null);
- } catch (SecurityException ex) {
- // Ignore, can happen if we try to set the bookmark on a read-only resource
- // such as a video attached to GMail.
- } catch (SQLiteException e) {
- // ignore. can happen if the content doesn't support a bookmark column.
- }
- }
+ if (!uriSupportsBookmarks(mUri)) {
+ return;
+ }
+
+ ContentValues values = new ContentValues();
+ values.put(Video.VideoColumns.BOOKMARK, Integer.toString(bookmark));
+ try {
+ getContentResolver().update(mUri, values, null, null);
+ } catch (SecurityException ex) {
+ // Ignore, can happen if we try to set the bookmark on a read-only resource
+ // such as a video attached to GMail.
+ } catch (SQLiteException e) {
+ // ignore. can happen if the content doesn't support a bookmark column.
+ } catch (UnsupportedOperationException e) {
+ // ignore. can happen if the external volume is already detached.
+ }
}
@Override