FilmstripDataAdapter.java revision 628481532e1e58a0a26330d238e850aec5657bce
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 17package com.android.camera.filmstrip; 18 19import android.app.Activity; 20import android.view.View; 21 22/** 23 * An interfaces which defines the interactions between the 24 * {@link FilmstripImageData} and the {@link com.android.camera.ui.FilmstripView}. 25 */ 26public interface FilmstripDataAdapter { 27 /** 28 * An interface which defines the update report used to return to the 29 * {@link FilmstripListener}. 30 */ 31 public interface UpdateReporter { 32 /** Checks if the data of dataID is removed. */ 33 public boolean isDataRemoved(int dataID); 34 35 /** Checks if the data of dataID is updated. */ 36 public boolean isDataUpdated(int dataID); 37 } 38 39 /** 40 * An interface which defines the listener for data events over 41 * {@link FilmstripImageData}. Usually {@link com.android.camera.ui.FilmstripView} itself. 42 */ 43 public interface Listener { 44 // Called when the whole data loading is done. No any assumption 45 // on previous data. 46 public void onDataLoaded(); 47 48 // Only some of the data is changed. The listener should check 49 // if any thing needs to be updated. 50 public void onDataUpdated(UpdateReporter reporter); 51 52 public void onDataInserted(int dataID, FilmstripImageData data); 53 54 public void onDataRemoved(int dataID, FilmstripImageData data); 55 } 56 57 /** Returns the total number of image data */ 58 public int getTotalNumber(); 59 60 /** 61 * Returns the view to visually present the image data. 62 * 63 * @param activity The {@link android.app.Activity} context to create the view. 64 * @param dataID The ID of the image data to be presented. 65 * @return The view representing the image data. Null if unavailable or 66 * the {@code dataID} is out of range. 67 */ 68 public View getView(Activity activity, int dataID); 69 70 /** 71 * Returns the {@link FilmstripImageData} specified by the ID. 72 * 73 * @param dataID The ID of the {@link FilmstripImageData}. 74 * @return The specified {@link FilmstripImageData}. Null if not available. 75 */ 76 public FilmstripImageData getImageData(int dataID); 77 78 /** 79 * Suggests the data adapter the maximum possible size of the layout so 80 * the {@link FilmstripDataAdapter} can optimize the view returned for the 81 * {@link FilmstripImageData}. 82 * 83 * @param w Maximum width. 84 * @param h Maximum height. 85 */ 86 public void suggestViewSizeBound(int w, int h); 87 88 /** 89 * Sets the listener for data events over the ImageData. 90 * 91 * @param listener The listener to use. 92 */ 93 public void setListener(Listener listener); 94 95 /** 96 * Returns {@code true} if the view of the data can be moved by swipe 97 * gesture when in full-screen. 98 * 99 * @param dataID The ID of the data. 100 * @return {@code true} if the view can be moved, {@code false} 101 * otherwise. 102 */ 103 public boolean canSwipeInFullScreen(int dataID); 104} 105