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