summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/filmstrip
diff options
context:
space:
mode:
authorPaul Rohde <codelogic@google.com>2014-12-18 11:11:34 -0800
committerPaul Rohde <codelogic@google.com>2015-01-07 14:08:20 -0800
commit8ee16b8a323ffa20e6fb1270d498ec445f64defc (patch)
tree48c7743db34b1c482fe8a25ccc240ace7fce3c84 /src/com/android/camera/filmstrip
parente066c34825af2b3b41894030bed5dde6be6e0af0 (diff)
downloadandroid_packages_apps_Camera2-8ee16b8a323ffa20e6fb1270d498ec445f64defc.tar.gz
android_packages_apps_Camera2-8ee16b8a323ffa20e6fb1270d498ec445f64defc.tar.bz2
android_packages_apps_Camera2-8ee16b8a323ffa20e6fb1270d498ec445f64defc.zip
Refactor the filmstrip backing data.
- Remove unused fields and code. - Rename classes and methods to be consistent with usage - Make data more immutable - Add Location and Metadata classes for typed data access. - Use Date instead of long for DateTime representations. - Filmstrip prefix for filmstrip specific code. - Cleaner Glide implementations. - Initialize Glide bitmap pool. - Eagerly load large image sizes when scroll stops. Change-Id: I3b51d42416ca076c80bf7db441d257659174b47d
Diffstat (limited to 'src/com/android/camera/filmstrip')
-rw-r--r--src/com/android/camera/filmstrip/FilmstripController.java66
-rw-r--r--src/com/android/camera/filmstrip/FilmstripDataAdapter.java (renamed from src/com/android/camera/filmstrip/DataAdapter.java)59
-rw-r--r--src/com/android/camera/filmstrip/ImageData.java121
3 files changed, 62 insertions, 184 deletions
diff --git a/src/com/android/camera/filmstrip/FilmstripController.java b/src/com/android/camera/filmstrip/FilmstripController.java
index af4403f58..8787747ef 100644
--- a/src/com/android/camera/filmstrip/FilmstripController.java
+++ b/src/com/android/camera/filmstrip/FilmstripController.java
@@ -46,9 +46,9 @@ public interface FilmstripController {
/**
* Sets the listener for filmstrip events.
*
- * @param l
+ * @param listener
*/
- public void setListener(FilmstripListener l);
+ public void setListener(FilmstripListener listener);
/**
* Sets the gap width between each images on the filmstrip.
@@ -60,12 +60,12 @@ public interface FilmstripController {
/**
* @return The ID of the current item, or -1.
*/
- public int getCurrentId();
+ public int getCurrentAdapterIndex();
/**
- * Sets the {@link DataAdapter}.
+ * Sets the {@link FilmstripDataAdapter}.
*/
- public void setDataAdapter(DataAdapter adapter);
+ public void setDataAdapter(FilmstripDataAdapter adapter);
/**
* Returns whether the filmstrip is in filmstrip mode.
@@ -83,7 +83,7 @@ public interface FilmstripController {
public boolean isCameraPreview();
/**
- * @return Whether the filmstrip is in full-screen camrea preview.
+ * @return Whether the filmstrip is in full-screen camera preview.
*/
public boolean inCameraFullscreen();
@@ -169,24 +169,24 @@ public interface FilmstripController {
* Callback when the data item is promoted. A data is promoted if the user
* swipe up a data vertically.
*
- * @param dataID The ID of the promoted data.
+ * @param adapterIndex The ID of the promoted data.
*/
- public void onFocusedDataPromoted(int dataID);
+ public void onFocusedDataPromoted(int adapterIndex);
/**
* Callback when the data item is demoted. A data is promoted if the user
* swipe down a data vertically.
*
- * @param dataID The ID of the demoted data.
+ * @param adapterIndex The ID of the demoted data.
*/
- public void onFocusedDataDemoted(int dataID);
+ public void onFocusedDataDemoted(int adapterIndex);
/**
* Callback when the data item is long-pressed.
*
- * @param dataID The ID of the long-pressed data.
+ * @param adapterIndex The ID of the long-pressed data.
*/
- public void onFocusedDataLongPressed(int dataID);
+ public void onFocusedDataLongPressed(int adapterIndex);
/**
* Called when all the data has been reloaded.
@@ -196,75 +196,75 @@ public interface FilmstripController {
/**
* Called when data is updated.
*
- * @param dataId The ID of the updated data.
+ * @param adapterIndex The ID of the updated data.
*/
- public void onDataUpdated(int dataId);
+ public void onDataUpdated(int adapterIndex);
/**
* The callback when the item enters augmented full-screen state.
*
- * @param dataId The ID of the current focused image data.
+ * @param adapterIndex The ID of the current focused image data.
*/
- public void onEnterFullScreenUiShown(int dataId);
+ public void onEnterFullScreenUiShown(int adapterIndex);
/**
* The callback when the item leaves augmented full-screen.
*
- * @param dataId The ID of the current focused image data.
+ * @param adapterIndex The ID of the current focused image data.
*/
- public void onLeaveFullScreenUiShown(int dataId);
+ public void onLeaveFullScreenUiShown(int adapterIndex);
/**
* The callback when the filmstrip enters no UI full-screen.
*
- * @param dataId The ID of the current focused image data.
+ * @param adapterIndex The ID of the current focused image data.
*/
- public void onEnterFullScreenUiHidden(int dataId);
+ public void onEnterFullScreenUiHidden(int adapterIndex);
/**
* The callback when the filmstrip leaves no UI full-screen.
*
- * @param dataId The ID of the current focused image data.
+ * @param adapterIndex The ID of the current focused image data.
*/
- public void onLeaveFullScreenUiHidden(int dataId);
+ public void onLeaveFullScreenUiHidden(int adapterIndex);
/**
* The callback when the item enters filmstrip.
*
- * @param dataId The ID of the current focused image data.
+ * @param adapterIndex The ID of the current focused image data.
*/
- public void onEnterFilmstrip(int dataId);
+ public void onEnterFilmstrip(int adapterIndex);
/**
* The callback when the item leaves filmstrip.
*
- * @param dataId The ID of the current focused image data.
+ * @param adapterIndex The ID of the current focused image data.
*/
- public void onLeaveFilmstrip(int dataId);
+ public void onLeaveFilmstrip(int adapterIndex);
/**
* The callback when the item enters zoom view.
*
- * @param dataID
+ * @param adapterIndex
*/
- public void onEnterZoomView(int dataID);
+ public void onEnterZoomView(int adapterIndex);
/**
* Called when current item or zoom level has changed.
*
- * @param dataId The ID of the current focused image data.
+ * @param adapterIndex The ID of the current focused image data.
* @param zoom Zoom level.
*/
- public void onZoomAtIndexChanged(int dataId, float zoom);
+ public void onZoomAtIndexChanged(int adapterIndex, float zoom);
/**
* The callback when the data focus changed.
*
- * @param prevDataId The ID of the previously focused data or {@code -1} if
+ * @param prevIndex The ID of the previously focused data or {@code -1} if
* none.
- * @param newDataId The ID of the focused data of {@code -1} if none.
+ * @param newIndex The ID of the focused data of {@code -1} if none.
*/
- public void onDataFocusChanged(int prevDataId, int newDataId);
+ public void onDataFocusChanged(int prevIndex, int newIndex);
/**
* The callback when we scroll.
diff --git a/src/com/android/camera/filmstrip/DataAdapter.java b/src/com/android/camera/filmstrip/FilmstripDataAdapter.java
index 65ae48a3a..f0f430725 100644
--- a/src/com/android/camera/filmstrip/DataAdapter.java
+++ b/src/com/android/camera/filmstrip/FilmstripDataAdapter.java
@@ -16,32 +16,32 @@
package com.android.camera.filmstrip;
-import android.content.Context;
import android.view.View;
-import com.android.camera.data.LocalData.ActionCallback;
+import com.android.camera.data.FilmstripItem;
+import com.android.camera.data.FilmstripItem.VideoClickedCallback;
/**
* An interface which defines the interactions between the
- * {@link ImageData} and the
+ * {@link FilmstripItem} and the
* {@link com.android.camera.widget.FilmstripView}.
*/
-public interface DataAdapter {
+public interface FilmstripDataAdapter {
/**
* An interface which defines the update reporter used to return to the
* {@link com.android.camera.filmstrip.FilmstripController.FilmstripListener}.
*/
public interface UpdateReporter {
/** Checks if the data of dataID is removed. */
- public boolean isDataRemoved(int dataID);
+ public boolean isDataRemoved(int index);
/** Checks if the data of dataID is updated. */
- public boolean isDataUpdated(int dataID);
+ public boolean isDataUpdated(int index);
}
/**
* An interface which defines the listener for data events over
- * {@link ImageData}. Usually
+ * {@link FilmstripItem}. Usually
* {@link com.android.camera.widget.FilmstripView} itself.
*/
public interface Listener {
@@ -49,30 +49,30 @@ public interface DataAdapter {
* Called when the whole data loading is done. There is not any
* assumption on the previous data.
*/
- public void onDataLoaded();
+ public void onFilmstripItemLoaded();
/**
* Called when some of the data is updated.
*
* @param reporter Use this reporter to know what happened.
*/
- public void onDataUpdated(UpdateReporter reporter);
+ public void onFilmstripItemUpdated(UpdateReporter reporter);
/**
* Called when a new data item is inserted.
*
- * @param dataID The ID of the inserted data.
- * @param data The inserted data.
+ * @param index The ID of the inserted data.
+ * @param item The inserted data.
*/
- public void onDataInserted(int dataID, ImageData data);
+ public void onFilmstripItemInserted(int index, FilmstripItem item);
/**
* Called when a data item is removed.
*
- * @param dataID The ID of the removed data.
- * @param data The data.
+ * @param index The ID of the removed data.
+ * @param item The data.
*/
- public void onDataRemoved(int dataID, ImageData data);
+ public void onFilmstripItemRemoved(int index, FilmstripItem item);
}
/** Returns the total number of image data. */
@@ -81,45 +81,44 @@ public interface DataAdapter {
/**
* Returns the view to visually present the image data.
*
- * @param context The {@link android.content.Context} to create the view.
* @param recycled A view that can be reused if one is available, or null.
- * @param dataID The ID of the image data to be presented.
+ * @param index The ID of the image data to be presented.
* @return The view representing the image data. Null if unavailable or
* the {@code dataID} is out of range.
*/
- public View getView(Context context, View recycled, int dataID, ActionCallback actionCallback);
+ public View getView(View recycled, int index,
+ VideoClickedCallback videoClickedCallback);
/** Returns a unique identifier for the view created by this data so that the view
* can be reused.
*
* @see android.widget.BaseAdapter#getItemViewType(int)
*/
- public int getItemViewType(int dataId);
+ public int getItemViewType(int index);
/**
* Resizes the view used to visually present the image data. This is
* useful when the view contains a bitmap.
*
- * @param context The {@link android.content.Context} to create the view.
- * @param dataID The ID of the resize data to be presented.
+ * @param index The ID of the resize data to be presented.
* @param view The view to update that was created by getView().
* @param w Width in pixels of rendered view.
* @param h Height in pixels of rendered view.
*/
- public void resizeView(Context context, int dataID, View view, int w, int h);
+ public void resizeView(int index, View view, int w, int h);
/**
- * Returns the {@link ImageData} specified by the ID.
+ * Returns the {@link FilmstripItem} specified by the ID.
*
- * @param dataID The ID of the {@link ImageData}.
- * @return The specified {@link ImageData}. Null if not available.
+ * @param index The ID of the {@link FilmstripItem}.
+ * @return The specified {@link FilmstripItem}. Null if not available.
*/
- public ImageData getImageData(int dataID);
+ public FilmstripItem getFilmstripItemAt(int index);
/**
* Suggests the data adapter the maximum possible size of the layout so
- * the {@link DataAdapter} can optimize the view returned for the
- * {@link ImageData}.
+ * the {@link FilmstripDataAdapter} can optimize the view returned for the
+ * {@link FilmstripItem}.
*
* @param widthPixels Width in pixels of rendered view.
* @param heightPixels Height in pixels of rendered view.
@@ -138,8 +137,8 @@ public interface DataAdapter {
* Returns whether the view of the data can be moved by swipe
* gesture when in full-screen.
*
- * @param dataID The ID of the data.
+ * @param item The ID of the data.
* @return Whether the view can be moved.
*/
- public boolean canSwipeInFullScreen(int dataID);
+ public boolean canSwipeInFullScreen(int item);
}
diff --git a/src/com/android/camera/filmstrip/ImageData.java b/src/com/android/camera/filmstrip/ImageData.java
deleted file mode 100644
index f080f8ec6..000000000
--- a/src/com/android/camera/filmstrip/ImageData.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera.filmstrip;
-
-import android.content.Context;
-import android.net.Uri;
-import android.view.View;
-
-/**
- * Common interface for all images in the filmstrip.
- */
-public interface ImageData {
-
- // View types.
- public static final int VIEW_TYPE_NONE = 0;
- public static final int VIEW_TYPE_STICKY = 1;
- public static final int VIEW_TYPE_REMOVABLE = 2;
-
- // Actions allowed to be performed on the image data.
- // The actions are defined bit-wise so we can use bit operations like
- // | and &.
- public static final int ACTION_NONE = 0;
- public static final int ACTION_PROMOTE = 1;
- public static final int ACTION_DEMOTE = (1 << 1);
- /**
- * For image data that supports zoom, it should also provide a valid
- * content uri.
- */
- public static final int ACTION_ZOOM = (1 << 2);
-
- /**
- * SIZE_FULL can be returned by {@link ImageData#getWidth()} and
- * {@link ImageData#getHeight()}. When SIZE_FULL is returned for
- * width/height, it means the the width or height will be disregarded
- * when deciding the view size of this ImageData, just use full screen
- * size.
- */
- public static final int SIZE_FULL = -2;
-
- /**
- * Returns the width in pixels of the image before orientation applied.
- * The final layout of the view returned by
- * {@link DataAdapter#getView(Context, int)} will
- * preserve the aspect ratio of
- * {@link ImageData#getWidth()} and
- * {@link ImageData#getHeight()}.
- */
- public int getWidth();
-
- /**
- * Returns the height in pixels of the image before orientation applied.
- * The final layout of the view returned by
- * {@link DataAdapter#getView(Context, int)} will
- * preserve the aspect ratio of
- * {@link ImageData#getWidth()} and
- * {@link ImageData#getHeight()}.
- */
- public int getHeight();
-
- /**
- * Returns the rotation of the image in degrees clockwise. The valid values
- * are 0, 90, 180, and 270.
- */
- public int getRotation();
-
- /** Returns the image data type. The current valid values are
- * {@code VIEW_TYPE_*}.
- */
- public int getViewType();
-
- /**
- * Returns the coordinates of this item.
- *
- * @return A 2-element array containing {latitude, longitude}, or null,
- * if no position is known for this item.
- */
- public double[] getLatLong();
-
- /**
- * Checks if the UI action is supported.
- *
- * @param action The UI actions to check.
- * @return Whether at all of the actions set in {@code action} are
- * supported.
- */
- public boolean isUIActionSupported(int action);
-
- /**
- * Gives the data a hint when its view is going to be displayed.
- * {@code FilmStripView} should always call this function before showing
- * its corresponding view every time.
- */
- public void prepare();
-
- /**
- * Gives the data a hint when its view is going to be removed from the
- * view hierarchy. {@code FilmStripView} should always call this
- * function after its corresponding view is removed from the view
- * hierarchy.
- */
- public void recycle(View view);
-
- /**
- * @return The URI of this data. Must be a unique one and not null.
- */
- public Uri getUri();
-}