OSDN Git Service

Avoid black screen when PhotoPage just starts.
authorYuli Huang <yuli@google.com>
Tue, 15 May 2012 14:36:59 +0000 (22:36 +0800)
committerYuli Huang <yuli@google.com>
Wed, 16 May 2012 03:26:40 +0000 (11:26 +0800)
bug:5367032

Change-Id: I6bd56026ec32bcee972d69855966750b9a57cdf4

src/com/android/gallery3d/app/PhotoPage.java
src/com/android/gallery3d/ui/PhotoView.java
src/com/android/gallery3d/ui/PositionController.java

index 52f7c41..a46c777 100644 (file)
@@ -71,8 +71,10 @@ public class PhotoPage extends ActivityState implements
     private static final int MSG_UNLOCK_ORIENTATION = 3;
     private static final int MSG_ON_FULL_SCREEN_CHANGED = 4;
     private static final int MSG_UPDATE_ACTION_BAR = 5;
+    private static final int MSG_UNFREEZE_GLROOT = 6;
 
     private static final int HIDE_BARS_TIMEOUT = 3500;
+    private static final int UNFREEZE_GLROOT_TIMEOUT = 250;
 
     private static final int REQUEST_SLIDESHOW = 1;
     private static final int REQUEST_CROP = 2;
@@ -276,6 +278,10 @@ public class PhotoPage extends ActivityState implements
                         updateBars();
                         break;
                     }
+                    case MSG_UNFREEZE_GLROOT: {
+                        mActivity.getGLRoot().unfreeze();
+                        break;
+                    }
                     default: throw new AssertionError(message.what);
                 }
             }
@@ -720,6 +726,8 @@ public class PhotoPage extends ActivityState implements
 
     @Override
     public void onPause() {
+        mActivity.getGLRoot().unfreeze();
+        mHandler.removeMessages(MSG_UNFREEZE_GLROOT);
         super.onPause();
         mIsActive = false;
         if (mAppBridge != null) mAppBridge.setServer(null);
@@ -733,7 +741,13 @@ public class PhotoPage extends ActivityState implements
     }
 
     @Override
+    public void onCurrentImageUpdated() {
+        mActivity.getGLRoot().unfreeze();
+    }
+
+    @Override
     protected void onResume() {
+        mActivity.getGLRoot().freeze();
         super.onResume();
         mIsActive = true;
         setContentPane(mRootPane);
@@ -750,6 +764,7 @@ public class PhotoPage extends ActivityState implements
             mAppBridge.setServer(this);
             mPhotoView.resetToFirstPicture();
         }
+        mHandler.sendEmptyMessageDelayed(MSG_UNFREEZE_GLROOT, UNFREEZE_GLROOT_TIMEOUT);
     }
 
     @Override
index dce3728..1c04849 100644 (file)
@@ -79,6 +79,7 @@ public class PhotoView extends GLView {
         public void unlockOrientation();
         public void onFullScreenChanged(boolean full);
         public void onActionBarAllowed(boolean allowed);
+        public void onCurrentImageUpdated();
     }
 
     // Here is a graph showing the places we need to lock/unlock device
@@ -318,6 +319,9 @@ public class PhotoView extends GLView {
     }
 
     public void notifyImageChange(int index) {
+        if (index == 0) {
+            mListener.onCurrentImageUpdated();
+        }
         mPictures.get(index).reload();
         invalidate();
     }
index f49a0b7..99d36ba 100644 (file)
@@ -207,6 +207,7 @@ class PositionController {
         }
 
         updateScaleAndGapLimit();
+        startOpeningAnimationIfNeeded();
         snapAndRedraw();
     }
 
@@ -233,7 +234,6 @@ class PositionController {
         }
 
         updateScaleAndGapLimit();
-        startOpeningAnimationIfNeeded();
         snapAndRedraw();
     }