OSDN Git Service

Allow for the thumbnail to be updated and refreshed.
authorSascha Haeberling <haeberling@google.com>
Sat, 14 Feb 2015 20:37:10 +0000 (12:37 -0800)
committerSascha Haeberling <haeberling@google.com>
Sat, 14 Feb 2015 20:37:10 +0000 (12:37 -0800)
  Bug: 19325176

Change-Id: Icc0f08b4c8b20e1b6d3e66fa420efea9e24faf73

src/com/android/camera/CameraActivity.java
src/com/android/camera/session/CaptureSession.java
src/com/android/camera/session/CaptureSessionImpl.java
src/com/android/camera/session/CaptureSessionManager.java
src/com/android/camera/session/CaptureSessionManagerImpl.java

index a995f45..4acc1d9 100644 (file)
@@ -876,6 +876,12 @@ public class CameraActivity extends QuickActivity
                 }
 
                 @Override
+                public void onSessionUpdated(Uri uri) {
+                    Log.v(TAG, "onSessionUpdated: " + uri);
+                    mDataAdapter.refresh(uri);
+                }
+
+                @Override
                 public void onSessionDone(final Uri sessionUri) {
                     Log.v(TAG, "onSessionDone:" + sessionUri);
                     Uri contentUri = Storage.getContentUriForSessionUri(sessionUri);
index 4e8ce1a..1e83699 100644 (file)
@@ -184,7 +184,7 @@ public interface CaptureSession {
      * Updates the preview from the file created from
      * {@link #getTempOutputFile()}.
      */
-    public void updatePreviewAndIndicator();
+    public void updatePreview();
 
     /**
      * Adds a progress listener to this session.
index 2d94738..195a20e 100644 (file)
@@ -151,7 +151,7 @@ public class CaptureSessionImpl implements CaptureSession {
     @Override
     public void updateThumbnail(Bitmap bitmap) {
         mPlaceholderManager.replacePlaceholder(mPlaceHolderSession, bitmap);
-        mSessionManager.notifyTaskQueued(mUri);
+        mSessionManager.notifySessionUpdated(mUri);
     }
 
     @Override
@@ -299,7 +299,7 @@ public class CaptureSessionImpl implements CaptureSession {
     }
 
     @Override
-    public void updatePreviewAndIndicator() {
+    public void updatePreview() {
         final File path;
         if (mTempOutputFile.isUsable()) {
             path = mTempOutputFile.getFile();
@@ -322,7 +322,7 @@ public class CaptureSessionImpl implements CaptureSession {
                 Bitmap placeholder = BitmapFactory.decodeByteArray(jpegData, 0, jpegData.length,
                         options);
                 mPlaceholderManager.replacePlaceholder(mPlaceHolderSession, placeholder);
-                onCaptureIndicatorUpdate(placeholder, 0 /* rotation */);
+                mSessionManager.notifySessionUpdated(mUri);
             }
         });
     }
index 488e0b0..6aa6fd5 100644 (file)
@@ -38,6 +38,12 @@ public interface CaptureSessionManager {
         public void onSessionQueued(Uri mediaUri);
 
         /**
+         * Called when the media underlying the session with the given Uri has
+         * been updated.
+         */
+        public void onSessionUpdated(Uri mediaUri);
+
+        /**
          * Called when the capture indicator for the given session has changed
          * and should be updated.
          *
index 22e072a..50635bb 100644 (file)
@@ -274,6 +274,23 @@ public class CaptureSessionManagerImpl implements CaptureSessionManager {
     }
 
     /**
+     * Notifies all task listeners that the media associated with the task has
+     * been updated.
+     */
+    void notifySessionUpdated(final Uri uri) {
+        mMainHandler.execute(new Runnable() {
+            @Override
+            public void run() {
+                synchronized (mTaskListeners) {
+                    for (SessionListener listener : mTaskListeners) {
+                        listener.onSessionUpdated(uri);
+                    }
+                }
+            }
+        });
+    }
+
+    /**
      * Notifies all task listeners that the task with the given URI has updated
      * its media.
      *