diff options
author | Angus Kong <shkong@google.com> | 2013-05-21 17:00:00 -0700 |
---|---|---|
committer | Angus Kong <shkong@google.com> | 2013-05-21 17:26:34 -0700 |
commit | fd382ee5142bb87707be00dec9bc7235f01733d1 (patch) | |
tree | 4997d1b12acdc4fa6d25cb0d15109d027174b122 /src/com/android/camera | |
parent | 2927b07c036431541a8c64ab479637b05bc0c35d (diff) | |
download | android_packages_apps_Snap-fd382ee5142bb87707be00dec9bc7235f01733d1.tar.gz android_packages_apps_Snap-fd382ee5142bb87707be00dec9bc7235f01733d1.tar.bz2 android_packages_apps_Snap-fd382ee5142bb87707be00dec9bc7235f01733d1.zip |
Keep camera preview in view hierarchy.
Camera preview is a special case that needs to be kept to avoid unnecessary
start and stop preview.
Change-Id: I6c922d4b35ff86981fa6a3ec3b76417d07a68a0e
Diffstat (limited to 'src/com/android/camera')
-rw-r--r-- | src/com/android/camera/ui/FilmStripView.java | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/src/com/android/camera/ui/FilmStripView.java b/src/com/android/camera/ui/FilmStripView.java index f18bba106..b2e36e44c 100644 --- a/src/com/android/camera/ui/FilmStripView.java +++ b/src/com/android/camera/ui/FilmStripView.java @@ -56,6 +56,9 @@ public class FilmStripView extends ViewGroup { private Listener mListener; + private View mCameraView; + private ImageData mCameraData; + // This is used to resolve the misalignment problem when the device // orientation is changed. If the current item is in fullscreen, it might // be shifted because mCenterX is not adjusted with the orientation. @@ -338,15 +341,20 @@ public class FilmStripView extends ViewGroup { View v = mDataAdapter.getView(mContext, dataID); if (v == null) return null; ViewInfo info = new ViewInfo(dataID, v); - addView(info.getView()); + v = info.getView(); + if (v != mCameraView) { + addView(info.getView()); + } else { + v.setVisibility(View.VISIBLE); + } return info; } private void removeInfo(int infoID) { if (infoID >= mViewInfo.length || mViewInfo[infoID] == null) return; - removeView(mViewInfo[infoID].getView()); - mDataAdapter.getImageData(mViewInfo[infoID].getID()).recycle(); + ImageData data = mDataAdapter.getImageData(mViewInfo[infoID].getID()); + checkForRemoval(data, mViewInfo[infoID].getView()); mViewInfo[infoID] = null; } @@ -464,6 +472,23 @@ public class FilmStripView extends ViewGroup { layoutChildren(); } + // Keeps the view in the view hierarchy if it's camera preview. + // Remove from the hierarchy otherwise. + private void checkForRemoval(ImageData data, View v) { + if (data.getType() != ImageData.TYPE_CAMERA_PREVIEW) { + removeView(v); + data.recycle(); + } else { + v.setVisibility(View.INVISIBLE); + if (mCameraView != null && mCameraView != v) { + removeView(mCameraView); + mCameraData = null; + } + mCameraView = v; + mCameraData = data; + } + } + private void slideViewBack(View v) { v.animate() .translationX(0) @@ -557,8 +582,7 @@ public class FilmStripView extends ViewGroup { .withEndAction(new Runnable() { @Override public void run() { - removeView(removedView); - data.recycle(); + checkForRemoval(data, removedView); } }) .start(); |