• 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.filmstrip;
18 
19 import android.content.Context;
20 import android.view.View;
21 
22 import com.android.camera.data.LocalData.ActionCallback;
23 
24 /**
25  * An interface which defines the interactions between the
26  * {@link ImageData} and the
27  * {@link com.android.camera.widget.FilmstripView}.
28  */
29 public interface DataAdapter {
30     /**
31      * An interface which defines the update reporter used to return to the
32      * {@link com.android.camera.filmstrip.FilmstripController.FilmstripListener}.
33      */
34     public interface UpdateReporter {
35         /** Checks if the data of dataID is removed. */
isDataRemoved(int dataID)36         public boolean isDataRemoved(int dataID);
37 
38         /** Checks if the data of dataID is updated. */
isDataUpdated(int dataID)39         public boolean isDataUpdated(int dataID);
40     }
41 
42     /**
43      * An interface which defines the listener for data events over
44      * {@link ImageData}. Usually
45      * {@link com.android.camera.widget.FilmstripView} itself.
46      */
47     public interface Listener {
48         /**
49          * Called when the whole data loading is done. There is not any
50          * assumption on the previous data.
51          */
onDataLoaded()52         public void onDataLoaded();
53 
54         /**
55          * Called when some of the data is updated.
56          *
57          * @param reporter Use this reporter to know what happened.
58          */
onDataUpdated(UpdateReporter reporter)59         public void onDataUpdated(UpdateReporter reporter);
60 
61         /**
62          * Called when a new data item is inserted.
63          *
64          * @param dataID The ID of the inserted data.
65          * @param data The inserted data.
66          */
onDataInserted(int dataID, ImageData data)67         public void onDataInserted(int dataID, ImageData data);
68 
69         /**
70          * Called when a data item is removed.
71          *
72          * @param dataID The ID of the removed data.
73          * @param data The data.
74          */
onDataRemoved(int dataID, ImageData data)75         public void onDataRemoved(int dataID, ImageData data);
76     }
77 
78     /** Returns the total number of image data. */
getTotalNumber()79     public int getTotalNumber();
80 
81     /**
82      * Returns the view to visually present the image data.
83      *
84      * @param context The {@link android.content.Context} to create the view.
85      * @param recycled A view that can be reused if one is available, or null.
86      * @param dataID The ID of the image data to be presented.
87      * @return The view representing the image data. Null if unavailable or
88      *         the {@code dataID} is out of range.
89      */
getView(Context context, View recycled, int dataID, ActionCallback actionCallback)90     public View getView(Context context, View recycled, int dataID, ActionCallback actionCallback);
91 
92     /** Returns a unique identifier for the view created by this data so that the view
93      * can be reused.
94      *
95      * @see android.widget.BaseAdapter#getItemViewType(int)
96      */
getItemViewType(int dataId)97     public int getItemViewType(int dataId);
98 
99     /**
100      * Resizes the view used to visually present the image data.  This is
101      * useful when the view contains a bitmap.
102      *
103      * @param context The {@link android.content.Context} to create the view.
104      * @param dataID The ID of the resize data to be presented.
105      * @param view The view to update that was created by getView().
106      * @param w Width in pixels of rendered view.
107      * @param h Height in pixels of rendered view.
108      */
resizeView(Context context, int dataID, View view, int w, int h)109     public void resizeView(Context context, int dataID, View view, int w, int h);
110 
111     /**
112      * Returns the {@link ImageData} specified by the ID.
113      *
114      * @param dataID The ID of the {@link ImageData}.
115      * @return The specified {@link ImageData}. Null if not available.
116      */
getImageData(int dataID)117     public ImageData getImageData(int dataID);
118 
119     /**
120      * Suggests the data adapter the maximum possible size of the layout so
121      * the {@link DataAdapter} can optimize the view returned for the
122      * {@link ImageData}.
123      *
124      * @param widthPixels Width in pixels of rendered view.
125      * @param heightPixels Height in pixels of rendered view.
126      */
suggestViewSizeBound(int widthPixels, int heightPixels)127     public void suggestViewSizeBound(int widthPixels, int heightPixels);
128 
129     /**
130      * Sets the listener for data events over the ImageData. Replaces the
131      * previous listener if it exists.
132      *
133      * @param listener The listener to use.
134      */
setListener(Listener listener)135     public void setListener(Listener listener);
136 
137     /**
138      * Returns whether the view of the data can be moved by swipe
139      * gesture when in full-screen.
140      *
141      * @param dataID The ID of the data.
142      * @return Whether the view can be moved.
143      */
canSwipeInFullScreen(int dataID)144     public boolean canSwipeInFullScreen(int dataID);
145 }
146