diff options
author | Owen Lin <owenlin@google.com> | 2009-06-03 17:07:33 -0700 |
---|---|---|
committer | Owen Lin <owenlin@google.com> | 2009-06-03 17:07:33 -0700 |
commit | f271893766a8ade5eea73fc65831f0dd678e3705 (patch) | |
tree | ea655547a55daa7de03e1d05290b8c69b303cf3d /src/com/android/camera/ViewImage.java | |
parent | 0f9c339253b0fabed60efd731869e68d18893837 (diff) | |
download | LegacyCamera-f271893766a8ade5eea73fc65831f0dd678e3705.zip LegacyCamera-f271893766a8ade5eea73fc65831f0dd678e3705.tar.gz LegacyCamera-f271893766a8ade5eea73fc65831f0dd678e3705.tar.bz2 |
Pass image list from ImageGallery to ViewImage to support the uber type
image list.
Diffstat (limited to 'src/com/android/camera/ViewImage.java')
-rw-r--r-- | src/com/android/camera/ViewImage.java | 74 |
1 files changed, 24 insertions, 50 deletions
diff --git a/src/com/android/camera/ViewImage.java b/src/com/android/camera/ViewImage.java index 9ce5e5c..4cfa544 100644 --- a/src/com/android/camera/ViewImage.java +++ b/src/com/android/camera/ViewImage.java @@ -19,6 +19,8 @@ package com.android.camera; import com.android.camera.gallery.Cancelable; import com.android.camera.gallery.IImage; import com.android.camera.gallery.IImageList; +import com.android.camera.gallery.SingleImageList; +import com.android.camera.gallery.VideoObject; import android.app.Activity; import android.content.Context; @@ -60,6 +62,8 @@ import java.util.concurrent.ExecutionException; // button to see the previous or next image. In slide show mode it shows one // image after another, with some transition effect. public class ViewImage extends Activity implements View.OnClickListener { + private static final String KEY_URI = "uri"; + private static final String TAG = "ViewImage"; private ImageGetter mGetter; @@ -83,7 +87,6 @@ public class ViewImage extends Activity implements View.OnClickListener { private boolean mShowActionIcons; private View mActionIconPanel; - private boolean mSortAscending = false; private int mSlideShowInterval; private int mLastSlideShowImage; private ThumbnailController mThumbController; @@ -106,6 +109,8 @@ public class ViewImage extends Activity implements View.OnClickListener { static final int HYSTERESIS = PADDING * 2; static final int BASE_SCROLL_DURATION = 1000; // ms + public static final String KEY_IMAGE_LIST = "image_list"; + IImageList mAllImages; private int mSlideShowImageCurrent = 0; @@ -374,7 +379,6 @@ public class ViewImage extends Activity implements View.OnClickListener { .setAlphabeticShortcut('z') .setVisible(false); - return true; } @@ -562,17 +566,15 @@ public class ViewImage extends Activity implements View.OnClickListener { } Uri uri = getIntent().getData(); - + IImageList imageList = getIntent().getParcelableExtra(KEY_IMAGE_LIST); if (instanceState != null) { - if (instanceState.containsKey("uri")) { - uri = Uri.parse(instanceState.getString("uri")); - } + uri = instanceState.getParcelable(KEY_URI); + imageList = instanceState.getParcelable(KEY_IMAGE_LIST); } - if (uri == null) { + if (!init(uri, imageList)) { finish(); return; } - init(uri); Bundle b = getIntent().getExtras(); @@ -847,38 +849,15 @@ public class ViewImage extends Activity implements View.OnClickListener { mGetter = new ImageGetter(this); } - private boolean desiredSortOrder() { - String sortOrder = mPrefs.getString("pref_gallery_sort_key", null); - boolean sortAscending = false; - if (sortOrder != null) { - sortAscending = sortOrder.equals("ascending"); - } - if (mCameraReviewMode) { - // Force left-arrow older pictures, right-arrow newer pictures. - sortAscending = true; - } - return sortAscending; - } - - private void init(Uri uri) { - if (uri == null) { - return; - } - - mSortAscending = desiredSortOrder(); - int sort = mSortAscending - ? ImageManager.SORT_ASCENDING - : ImageManager.SORT_DESCENDING; - mAllImages = ImageManager.makeImageList(uri, getContentResolver(), - sort); - - uri = uri.buildUpon().query(null).build(); - + private boolean init(Uri uri, IImageList imageList) { + if (uri == null) return false; + mAllImages = imageList == null ? new SingleImageList(uri) : imageList; + mAllImages.open(getContentResolver()); IImage image = mAllImages.getImageForUri(uri); - if (image != null) { - mCurrentPosition = mAllImages.getImageIndex(image); - mLastSlideShowImage = mCurrentPosition; - } + if (image == null) return false; + mCurrentPosition = mAllImages.getImageIndex(image); + mLastSlideShowImage = mCurrentPosition; + return true; } private Uri getCurrentUri() { @@ -902,22 +881,16 @@ public class ViewImage extends Activity implements View.OnClickListener { @Override public void onSaveInstanceState(Bundle b) { super.onSaveInstanceState(b); - - Uri uri = getCurrentUri(); - if (uri != null) { - b.putString("uri", uri.toString()); - } - - if (mMode == MODE_SLIDESHOW) { - b.putBoolean("slideshow", true); - } + b.putParcelable(KEY_URI, + mAllImages.getImageAt(mCurrentPosition).fullSizeImageUri()); + b.putBoolean("slideshow", mMode == MODE_SLIDESHOW); } @Override public void onStart() { super.onStart(); - init(mSavedUri); + init(mSavedUri, mAllImages); if (mCameraReviewMode) { updateLastImage(); } @@ -1358,7 +1331,8 @@ class ImageGetter { if (imageNumber >= 0 && imageNumber < imageCount) { IImage image = mViewImage.mAllImages .getImageAt(lastPosition + offset); - if (mCB.wantsFullImage(lastPosition, offset)) { + if (mCB.wantsFullImage(lastPosition, offset) + && !(image instanceof VideoObject)) { int sizeToUse = mCB.fullImageSizeToUse( lastPosition, offset); if (image != null && !isCanceled()) { |