OSDN Git Service

Add UriImage support for viewing LightCycle panoramas.
[android-x86/packages-apps-Gallery2.git] / src / com / android / gallery3d / data / LocalImage.java
index 078229a..a00525c 100644 (file)
@@ -19,6 +19,7 @@ package com.android.gallery3d.data;
 import android.annotation.TargetApi;
 import android.content.ContentResolver;
 import android.content.ContentValues;
+import android.content.Context;
 import android.database.Cursor;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
@@ -99,6 +100,9 @@ public class LocalImage extends LocalMediaItem {
 
     public int rotation;
 
+    private boolean mUsePanoramaViewer;
+    private boolean mUsePanoramaViewerInitialized;
+
     public LocalImage(Path path, GalleryApp application, Cursor cursor) {
         super(path, nextVersionNumber());
         mApplication = application;
@@ -241,9 +245,7 @@ public class LocalImage extends LocalMediaItem {
             operation |= SUPPORT_SHOW_ON_MAP;
         }
 
-        if (LightCycleHelper.isPanorama(filePath) &&
-                LightCycleHelper.hasLightCycleView(
-                        mApplication.getAndroidContext())) {
+        if (usePanoramaViewer()) {
             operation |= SUPPORT_VIEW_PANORAMA;
         }
         return operation;
@@ -343,4 +345,16 @@ public class LocalImage extends LocalMediaItem {
     public String getFilePath() {
         return filePath;
     }
+
+    @Override
+    public boolean usePanoramaViewer() {
+        if (!mUsePanoramaViewerInitialized) {
+            Context context = mApplication.getAndroidContext();
+            mUsePanoramaViewer = LightCycleHelper.hasLightCycleView(context)
+                    && LightCycleHelper.isPanorama(mApplication.getContentResolver(),
+                            getContentUri());
+            mUsePanoramaViewerInitialized = true;
+        }
+        return mUsePanoramaViewer;
+    }
 }