• 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.picasasource;
18 
19 import com.android.gallery3d.app.GalleryApp;
20 import com.android.gallery3d.data.MediaObject;
21 import com.android.gallery3d.data.MediaSet;
22 import com.android.gallery3d.data.MediaSource;
23 import com.android.gallery3d.data.Path;
24 import com.android.gallery3d.data.PathMatcher;
25 
26 import android.app.Activity;
27 import android.content.Context;
28 import android.media.ExifInterface;
29 import android.os.ParcelFileDescriptor;
30 
31 import java.io.FileNotFoundException;
32 
33 public class PicasaSource extends MediaSource {
34     private static final String TAG = "PicasaSource";
35 
36     private static final int NO_MATCH = -1;
37     private static final int IMAGE_MEDIA_ID = 1;
38 
39     private static final int PICASA_ALBUMSET = 0;
40     private static final int MAP_BATCH_COUNT = 100;
41 
42     private GalleryApp mApplication;
43     private PathMatcher mMatcher;
44 
45     public static final Path ALBUM_PATH = Path.fromString("/picasa/all");
46 
PicasaSource(GalleryApp application)47     public PicasaSource(GalleryApp application) {
48         super("picasa");
49         mApplication = application;
50         mMatcher = new PathMatcher();
51         mMatcher.add("/picasa/all", PICASA_ALBUMSET);
52         mMatcher.add("/picasa/image", PICASA_ALBUMSET);
53         mMatcher.add("/picasa/video", PICASA_ALBUMSET);
54     }
55 
56     private static class EmptyAlbumSet extends MediaSet {
57 
EmptyAlbumSet(Path path, long version)58         public EmptyAlbumSet(Path path, long version) {
59             super(path, version);
60         }
61 
62         @Override
getName()63         public String getName() {
64             return "picasa";
65         }
66 
67         @Override
reload()68         public long reload() {
69             return mDataVersion;
70         }
71     }
72 
73     @Override
createMediaObject(Path path)74     public MediaObject createMediaObject(Path path) {
75         switch (mMatcher.match(path)) {
76             case PICASA_ALBUMSET:
77                 return new EmptyAlbumSet(path, MediaObject.nextVersionNumber());
78             default:
79                 throw new RuntimeException("bad path: " + path);
80         }
81     }
82 
isPicasaImage(MediaObject object)83     public static boolean isPicasaImage(MediaObject object) {
84         return false;
85     }
86 
getImageTitle(MediaObject image)87     public static String getImageTitle(MediaObject image) {
88         throw new UnsupportedOperationException();
89     }
90 
getImageSize(MediaObject image)91     public static int getImageSize(MediaObject image) {
92         throw new UnsupportedOperationException();
93     }
94 
getContentType(MediaObject image)95     public static String getContentType(MediaObject image) {
96         throw new UnsupportedOperationException();
97     }
98 
getDateTaken(MediaObject image)99     public static long getDateTaken(MediaObject image) {
100         throw new UnsupportedOperationException();
101     }
102 
getLatitude(MediaObject image)103     public static double getLatitude(MediaObject image) {
104         throw new UnsupportedOperationException();
105     }
106 
getLongitude(MediaObject image)107     public static double getLongitude(MediaObject image) {
108         throw new UnsupportedOperationException();
109     }
110 
getRotation(MediaObject image)111     public static int getRotation(MediaObject image) {
112         throw new UnsupportedOperationException();
113     }
114 
openFile(Context context, MediaObject image, String mode)115     public static ParcelFileDescriptor openFile(Context context, MediaObject image, String mode)
116             throws FileNotFoundException {
117         throw new UnsupportedOperationException();
118     }
119 
initialize(Context context)120     public static void initialize(Context context) {/*do nothing*/}
121 
requestSync(Context context)122     public static void requestSync(Context context) {/*do nothing*/}
123 
showSignInReminder(Activity context)124     public static void showSignInReminder(Activity context) {/*do nothing*/}
125 
onPackageAdded(Context context, String packageName)126     public static void onPackageAdded(Context context, String packageName) {/*do nothing*/}
127 
onPackageRemoved(Context context, String packageName)128     public static void onPackageRemoved(Context context, String packageName) {/*do nothing*/}
129 
extractExifValues(MediaObject item, ExifInterface exif)130     public static void extractExifValues(MediaObject item, ExifInterface exif) {/*do nothing*/}
131 }
132