• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2013 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.camera.data;
18 
19 import android.net.Uri;
20 import android.os.AsyncTask;
21 
22 import com.android.camera.filmstrip.FilmstripDataAdapter;
23 import com.android.camera.util.Callback;
24 import com.android.camera.widget.Preloader;
25 
26 import java.util.List;
27 
28 /**
29  * An interface which extends {@link com.android.camera.filmstrip.FilmstripDataAdapter}
30  * and defines operations on the data in the local camera folder.
31  */
32 public interface LocalFilmstripDataAdapter extends FilmstripDataAdapter,
33         Preloader.ItemLoader<Integer, AsyncTask>, Preloader.ItemSource<Integer> {
34 
35     public interface FilmstripItemListener {
36         /**
37          * Metadata of a {@link FilmstripItem} is loaded on
38          * demand. Once the metadata is loaded this listener is notified.
39          *
40          * @param indexes The indexes of the data whose metadata has been
41          *            updated.
42          */
onMetadataUpdated(List<Integer> indexes)43         public void onMetadataUpdated(List<Integer> indexes);
44     }
45 
46     /**
47      * Request for loading any photos that may have been added to the
48      * media store since the last update.
49      */
requestLoadNewPhotos()50     public void requestLoadNewPhotos();
51 
52     /**
53      * Request for loading the local data.
54      */
requestLoad(Callback<Void> onDone)55     public void requestLoad(Callback<Void> onDone);
56 
57     /**
58      * Returns the specified {@link FilmstripItem}.
59      *
60      * @param index The ID of the {@link FilmstripItem} to get.
61      * @return The {@link FilmstripItem} to get. {@code null} if not available.
62      */
getItemAt(int index)63     public FilmstripItem getItemAt(int index);
64 
65     /**
66      * Remove the data in the local camera folder.
67      *
68      * @param index of data to be deleted.
69      */
removeAt(int index)70     public void removeAt(int index);
71 
72     /**
73      * Adds new local data. The data is either inserted or updated, depending
74      * on the existence of the Uri.
75      *
76      * @param item The new data.
77      * @return Whether the data is newly inserted.
78      */
addOrUpdate(FilmstripItem item)79     public boolean addOrUpdate(FilmstripItem item);
80 
81     /**
82      * Refresh the data by {@link Uri}.
83      *
84      * @param uri The {@link Uri} of the data to refresh.
85      */
refresh(Uri uri)86     public void refresh(Uri uri);
87 
88     /**
89      * Finds the {@link FilmstripItem} of the specified content Uri.
90      *
91      * @param uri The content Uri of the {@link FilmstripItem}.
92      * @return The index of the data. {@code -1} if not found.
93      */
findByContentUri(Uri uri)94     public int findByContentUri(Uri uri);
95 
96     /**
97      * Clears all the data currently loaded.
98      */
clear()99     public void clear();
100 
101     /**
102      * Executes the deletion task. Delete the data waiting in the deletion
103      * queue.
104      *
105      * @return Whether the task has been executed
106      */
executeDeletion()107     public boolean executeDeletion();
108 
109     /**
110      * Undo a deletion. If there is any data waiting to be deleted in the queue,
111      * move it out of the deletion queue.
112      *
113      * @return Whether there are items in the queue.
114      */
undoDeletion()115     public boolean undoDeletion();
116 
117     /**
118      * Update the data in a specific position.
119      *
120      * @param index The position of the data to be updated.
121      * @param item The new data.
122      */
updateItemAt(int index, FilmstripItem item)123     public void updateItemAt(int index, FilmstripItem item);
124 
125     /** Sets the listener for the LocalData change. */
setLocalDataListener(FilmstripItemListener listener)126     public void setLocalDataListener(FilmstripItemListener listener);
127 
128     /**
129      * Updates the metadata in the background. The completion of the updating
130      * will be notified through
131      * {@link LocalFilmstripDataAdapter.FilmstripItemListener}.
132      *
133      * @param index The ID of the data to update the metadata for.
134      * @return An {@link android.os.AsyncTask} performing the background load
135      *      that can be used to cancel the load if it's no longer needed.
136      */
updateMetadataAt(int index)137     public AsyncTask updateMetadataAt(int index);
138 
139     /**
140      * @return whether the metadata is already updated.
141      */
isMetadataUpdatedAt(int index)142     public boolean isMetadataUpdatedAt(int index);
143 }
144