• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_TRIM = 1 << 12;
40     public static final int SUPPORT_UNLOCK = 1 << 13;
41     public static final int SUPPORT_BACK = 1 << 14;
42     public static final int SUPPORT_ACTION = 1 << 15;
43     public static final int SUPPORT_CAMERA_SHORTCUT = 1 << 16;
44     public static final int SUPPORT_ALL = 0xffffffff;
45 
46     // These are the bits returned from getMediaType():
47     public static final int MEDIA_TYPE_UNKNOWN = 1;
48     public static final int MEDIA_TYPE_IMAGE = 2;
49     public static final int MEDIA_TYPE_VIDEO = 4;
50     public static final int MEDIA_TYPE_ALL = MEDIA_TYPE_IMAGE | MEDIA_TYPE_VIDEO;
51 
52     public static final String MEDIA_TYPE_IMAGE_STRING = "image";
53     public static final String MEDIA_TYPE_VIDEO_STRING = "video";
54     public static final String MEDIA_TYPE_ALL_STRING = "all";
55 
56     // These are flags for cache() and return values for getCacheFlag():
57     public static final int CACHE_FLAG_NO = 0;
58     public static final int CACHE_FLAG_SCREENNAIL = 1;
59     public static final int CACHE_FLAG_FULL = 2;
60 
61     // These are return values for getCacheStatus():
62     public static final int CACHE_STATUS_NOT_CACHED = 0;
63     public static final int CACHE_STATUS_CACHING = 1;
64     public static final int CACHE_STATUS_CACHED_SCREENNAIL = 2;
65     public static final int CACHE_STATUS_CACHED_FULL = 3;
66 
67     private static long sVersionSerial = 0;
68 
69     protected long mDataVersion;
70 
71     protected final Path mPath;
72 
73     public interface PanoramaSupportCallback {
panoramaInfoAvailable(MediaObject mediaObject, boolean isPanorama, boolean isPanorama360)74         void panoramaInfoAvailable(MediaObject mediaObject, boolean isPanorama,
75                 boolean isPanorama360);
76     }
77 
MediaObject(Path path, long version)78     public MediaObject(Path path, long version) {
79         path.setObject(this);
80         mPath = path;
81         mDataVersion = version;
82     }
83 
getPath()84     public Path getPath() {
85         return mPath;
86     }
87 
getSupportedOperations()88     public int getSupportedOperations() {
89         return 0;
90     }
91 
getPanoramaSupport(PanoramaSupportCallback callback)92     public void getPanoramaSupport(PanoramaSupportCallback callback) {
93         callback.panoramaInfoAvailable(this, false, false);
94     }
95 
clearCachedPanoramaSupport()96     public void clearCachedPanoramaSupport() {
97     }
98 
delete()99     public void delete() {
100         throw new UnsupportedOperationException();
101     }
102 
rotate(int degrees)103     public void rotate(int degrees) {
104         throw new UnsupportedOperationException();
105     }
106 
getContentUri()107     public Uri getContentUri() {
108         String className = getClass().getName();
109         Log.e(TAG, "Class " + className + "should implement getContentUri.");
110         Log.e(TAG, "The object was created from path: " + getPath());
111         throw new UnsupportedOperationException();
112     }
113 
getPlayUri()114     public Uri getPlayUri() {
115         throw new UnsupportedOperationException();
116     }
117 
getMediaType()118     public int getMediaType() {
119         return MEDIA_TYPE_UNKNOWN;
120     }
121 
Import()122     public boolean Import() {
123         throw new UnsupportedOperationException();
124     }
125 
getDetails()126     public MediaDetails getDetails() {
127         MediaDetails details = new MediaDetails();
128         return details;
129     }
130 
getDataVersion()131     public long getDataVersion() {
132         return mDataVersion;
133     }
134 
getCacheFlag()135     public int getCacheFlag() {
136         return CACHE_FLAG_NO;
137     }
138 
getCacheStatus()139     public int getCacheStatus() {
140         throw new UnsupportedOperationException();
141     }
142 
getCacheSize()143     public long getCacheSize() {
144         throw new UnsupportedOperationException();
145     }
146 
cache(int flag)147     public void cache(int flag) {
148         throw new UnsupportedOperationException();
149     }
150 
nextVersionNumber()151     public static synchronized long nextVersionNumber() {
152         return ++MediaObject.sVersionSerial;
153     }
154 
getTypeFromString(String s)155     public static int getTypeFromString(String s) {
156         if (MEDIA_TYPE_ALL_STRING.equals(s)) return MediaObject.MEDIA_TYPE_ALL;
157         if (MEDIA_TYPE_IMAGE_STRING.equals(s)) return MediaObject.MEDIA_TYPE_IMAGE;
158         if (MEDIA_TYPE_VIDEO_STRING.equals(s)) return MediaObject.MEDIA_TYPE_VIDEO;
159         throw new IllegalArgumentException(s);
160     }
161 
getTypeString(int type)162     public static String getTypeString(int type) {
163         switch (type) {
164             case MEDIA_TYPE_IMAGE: return MEDIA_TYPE_IMAGE_STRING;
165             case MEDIA_TYPE_VIDEO: return MEDIA_TYPE_VIDEO_STRING;
166             case MEDIA_TYPE_ALL: return MEDIA_TYPE_ALL_STRING;
167         }
168         throw new IllegalArgumentException();
169     }
170 }
171