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