OSDN Git Service

Show play icon for panorama.
authorGeorge Mount <mount@google.com>
Fri, 7 Sep 2012 17:36:25 +0000 (10:36 -0700)
committerGeorge Mount <mount@google.com>
Mon, 10 Sep 2012 19:42:28 +0000 (12:42 -0700)
 Bug 7124494

Change-Id: I17fdb5d6bcab1f3997a1ab92fcf45e0309b394b3

src/com/android/gallery3d/app/PhotoDataAdapter.java
src/com/android/gallery3d/app/SinglePhotoDataAdapter.java
src/com/android/gallery3d/data/LocalImage.java
src/com/android/gallery3d/data/LocalVideo.java
src/com/android/gallery3d/data/MediaItem.java
src/com/android/gallery3d/ui/PhotoView.java

index d565f26..abe4e8a 100644 (file)
@@ -38,6 +38,7 @@ import com.android.gallery3d.ui.SynchronizedHandler;
 import com.android.gallery3d.ui.TileImageViewAdapter;
 import com.android.gallery3d.util.Future;
 import com.android.gallery3d.util.FutureListener;
+import com.android.gallery3d.util.LightCycleHelper;
 import com.android.gallery3d.util.MediaSetUtils;
 import com.android.gallery3d.util.ThreadPool;
 import com.android.gallery3d.util.ThreadPool.Job;
@@ -478,6 +479,16 @@ public class PhotoDataAdapter implements PhotoPage.Model {
     }
 
     @Override
+    public boolean usePanoramaViewer(int offset) {
+        MediaItem item = getItem(mCurrentIndex + offset);
+        boolean usePanoramaViewer = false;
+        if (item != null) {
+            usePanoramaViewer = LightCycleHelper.isPanorama(item.getFilePath());
+        }
+        return usePanoramaViewer;
+    }
+
+    @Override
     public boolean isDeletable(int offset) {
         MediaItem item = getItem(mCurrentIndex + offset);
         return (item == null)
index 2f6f16f..90f6060 100644 (file)
@@ -33,6 +33,7 @@ import com.android.gallery3d.ui.SynchronizedHandler;
 import com.android.gallery3d.ui.TileImageViewAdapter;
 import com.android.gallery3d.util.Future;
 import com.android.gallery3d.util.FutureListener;
+import com.android.gallery3d.util.LightCycleHelper;
 import com.android.gallery3d.util.ThreadPool;
 
 public class SinglePhotoDataAdapter extends TileImageViewAdapter
@@ -216,6 +217,11 @@ public class SinglePhotoDataAdapter extends TileImageViewAdapter
     }
 
     @Override
+    public boolean usePanoramaViewer(int offset) {
+        return LightCycleHelper.isPanorama(mItem.getFilePath());
+    }
+
+    @Override
     public boolean isDeletable(int offset) {
         return (mItem.getSupportedOperations() & MediaItem.SUPPORT_DELETE) != 0;
     }
index b803bd2..078229a 100644 (file)
@@ -338,4 +338,9 @@ public class LocalImage extends LocalMediaItem {
     public int getHeight() {
         return height;
     }
+
+    @Override
+    public String getFilePath() {
+        return filePath;
+    }
 }
index addb8fd..5b6ee4b 100644 (file)
@@ -231,4 +231,9 @@ public class LocalVideo extends LocalMediaItem {
     public int getHeight() {
         return height;
     }
+
+    @Override
+    public String getFilePath() {
+        return filePath;
+    }
 }
index 15bb176..2fcd1da 100644 (file)
@@ -103,6 +103,10 @@ public abstract class MediaItem extends MediaObject {
 
     public abstract String getMimeType();
 
+    public String getFilePath() {
+        return "";
+    }
+
     // Returns width and height of the media item.
     // Returns 0, 0 if the information is not available.
     public abstract int getWidth();
index 9346388..932173f 100644 (file)
@@ -79,6 +79,9 @@ public class PhotoView extends GLView {
         // Returns true if the item is the Panorama.
         public boolean isPanorama(int offset);
 
+        // Returns true if the item uses a special panorama viewer
+        public boolean usePanoramaViewer(int offset);
+
         // Returns true if the item is a static image that represents camera
         // preview.
         public boolean isStaticCamera(int offset);
@@ -559,6 +562,7 @@ public class PhotoView extends GLView {
         private int mRotation;
         private boolean mIsCamera;
         private boolean mIsPanorama;
+        private boolean mUsePanoramaViewer;
         private boolean mIsStaticCamera;
         private boolean mIsVideo;
         private boolean mIsDeletable;
@@ -573,6 +577,7 @@ public class PhotoView extends GLView {
 
             mIsCamera = mModel.isCamera(0);
             mIsPanorama = mModel.isPanorama(0);
+            mUsePanoramaViewer = mModel.usePanoramaViewer(0);
             mIsStaticCamera = mModel.isStaticCamera(0);
             mIsVideo = mModel.isVideo(0);
             mIsDeletable = mModel.isDeletable(0);
@@ -712,7 +717,7 @@ public class PhotoView extends GLView {
             // Draw the play video icon and the message.
             canvas.translate((int) (cx + 0.5f), (int) (cy + 0.5f));
             int s = (int) (scale * Math.min(r.width(), r.height()) + 0.5f);
-            if (mIsVideo) drawVideoPlayIcon(canvas, s);
+            if (mIsVideo || mUsePanoramaViewer) drawVideoPlayIcon(canvas, s);
             if (mLoadingState == Model.LOADING_FAIL) {
                 drawLoadingFailMessage(canvas);
             }
@@ -754,6 +759,7 @@ public class PhotoView extends GLView {
         private ScreenNail mScreenNail;
         private boolean mIsCamera;
         private boolean mIsPanorama;
+        private boolean mUsePanoramaViewer;
         private boolean mIsStaticCamera;
         private boolean mIsVideo;
         private boolean mIsDeletable;
@@ -768,6 +774,7 @@ public class PhotoView extends GLView {
         public void reload() {
             mIsCamera = mModel.isCamera(mIndex);
             mIsPanorama = mModel.isPanorama(mIndex);
+            mUsePanoramaViewer = mModel.usePanoramaViewer(mIndex);
             mIsStaticCamera = mModel.isStaticCamera(mIndex);
             mIsVideo = mModel.isVideo(mIndex);
             mIsDeletable = mModel.isDeletable(mIndex);
@@ -833,7 +840,7 @@ public class PhotoView extends GLView {
                 invalidate();
             }
             int s = Math.min(drawW, drawH);
-            if (mIsVideo) drawVideoPlayIcon(canvas, s);
+            if (mIsVideo || mUsePanoramaViewer) drawVideoPlayIcon(canvas, s);
             if (mLoadingState == Model.LOADING_FAIL) {
                 drawLoadingFailMessage(canvas);
             }