1 /* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.gallery3d.data; 18 19 import android.net.Uri; 20 21 public abstract class MediaObject { 22 @SuppressWarnings("unused") 23 private static final String TAG = "MediaObject"; 24 public static final long INVALID_DATA_VERSION = -1; 25 26 // These are the bits returned from getSupportedOperations(): 27 public static final int SUPPORT_DELETE = 1 << 0; 28 public static final int SUPPORT_ROTATE = 1 << 1; 29 public static final int SUPPORT_SHARE = 1 << 2; 30 public static final int SUPPORT_CROP = 1 << 3; 31 public static final int SUPPORT_SHOW_ON_MAP = 1 << 4; 32 public static final int SUPPORT_SETAS = 1 << 5; 33 public static final int SUPPORT_FULL_IMAGE = 1 << 6; 34 public static final int SUPPORT_PLAY = 1 << 7; 35 public static final int SUPPORT_CACHE = 1 << 8; 36 public static final int SUPPORT_EDIT = 1 << 9; 37 public static final int SUPPORT_INFO = 1 << 10; 38 public static final int SUPPORT_IMPORT = 1 << 11; 39 public static final int SUPPORT_ALL = 0xffffffff; 40 41 // These are the bits returned from getMediaType(): 42 public static final int MEDIA_TYPE_UNKNOWN = 1; 43 public static final int MEDIA_TYPE_IMAGE = 2; 44 public static final int MEDIA_TYPE_VIDEO = 4; 45 public static final int MEDIA_TYPE_ALL = MEDIA_TYPE_IMAGE | MEDIA_TYPE_VIDEO; 46 47 // These are flags for cache() and return values for getCacheFlag(): 48 public static final int CACHE_FLAG_NO = 0; 49 public static final int CACHE_FLAG_SCREENNAIL = 1; 50 public static final int CACHE_FLAG_FULL = 2; 51 52 // These are return values for getCacheStatus(): 53 public static final int CACHE_STATUS_NOT_CACHED = 0; 54 public static final int CACHE_STATUS_CACHING = 1; 55 public static final int CACHE_STATUS_CACHED_SCREENNAIL = 2; 56 public static final int CACHE_STATUS_CACHED_FULL = 3; 57 58 private static long sVersionSerial = 0; 59 60 protected long mDataVersion; 61 62 protected final Path mPath; 63 64 public MediaObject(Path path, long version) { 65 path.setObject(this); 66 mPath = path; 67 mDataVersion = version; 68 } 69 70 public Path getPath() { 71 return mPath; 72 } 73 74 public int getSupportedOperations() { 75 return 0; 76 } 77 78 public void delete() { 79 throw new UnsupportedOperationException(); 80 } 81 82 public void rotate(int degrees) { 83 throw new UnsupportedOperationException(); 84 } 85 86 public Uri getContentUri() { 87 throw new UnsupportedOperationException(); 88 } 89 90 public Uri getPlayUri() { 91 throw new UnsupportedOperationException(); 92 } 93 94 public int getMediaType() { 95 return MEDIA_TYPE_UNKNOWN; 96 } 97 98 public boolean Import() { 99 throw new UnsupportedOperationException(); 100 } 101 102 public MediaDetails getDetails() { 103 MediaDetails details = new MediaDetails(); 104 return details; 105 } 106 107 public long getDataVersion() { 108 return mDataVersion; 109 } 110 111 public int getCacheFlag() { 112 return CACHE_FLAG_NO; 113 } 114 115 public int getCacheStatus() { 116 throw new UnsupportedOperationException(); 117 } 118 119 public long getCacheSize() { 120 throw new UnsupportedOperationException(); 121 } 122 123 public void cache(int flag) { 124 throw new UnsupportedOperationException(); 125 } 126 127 public static synchronized long nextVersionNumber() { 128 return ++MediaObject.sVersionSerial; 129 } 130 } 131