diff options
Diffstat (limited to 'src/com/android/gallery3d/ui/PhotoView.java')
-rw-r--r-- | src/com/android/gallery3d/ui/PhotoView.java | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java index 0758656a1..40e01ab07 100644 --- a/src/com/android/gallery3d/ui/PhotoView.java +++ b/src/com/android/gallery3d/ui/PhotoView.java @@ -35,6 +35,11 @@ import com.android.gallery3d.common.Utils; import com.android.gallery3d.data.MediaItem; import com.android.gallery3d.data.MediaObject; import com.android.gallery3d.data.Path; +import com.android.gallery3d.glrenderer.GLCanvas; +import com.android.gallery3d.glrenderer.RawTexture; +import com.android.gallery3d.glrenderer.ResourceTexture; +import com.android.gallery3d.glrenderer.StringTexture; +import com.android.gallery3d.glrenderer.Texture; import com.android.gallery3d.util.GalleryUtils; import com.android.gallery3d.util.RangeArray; @@ -52,7 +57,7 @@ public class PhotoView extends GLView { public int height; } - public interface Model extends TileImageView.Model { + public interface Model extends TileImageView.TileSource { public int getCurrentIndex(); public void moveTo(int index); @@ -174,8 +179,9 @@ public class PhotoView extends GLView { public static final int SCREEN_NAIL_MAX = 3; // These are constants for the delete gesture. - private static final int SWIPE_ESCAPE_VELOCITY = 2500; // dp/sec - private static final int MAX_DISMISS_VELOCITY = 4000; // dp/sec + private static final int SWIPE_ESCAPE_VELOCITY = 500; // dp/sec + private static final int MAX_DISMISS_VELOCITY = 2500; // dp/sec + private static final int SWIPE_ESCAPE_DISTANCE = 150; // dp // The picture entries, the valid index is from -SCREEN_NAIL_MAX to // SCREEN_NAIL_MAX. @@ -205,6 +211,7 @@ public class PhotoView extends GLView { private boolean mFullScreenCamera; private Rect mCameraRelativeFrame = new Rect(); private Rect mCameraRect = new Rect(); + private boolean mFirst = true; // [mPrevBound, mNextBound] is the range of index for all pictures in the // model, if we assume the index of current focused picture is 0. So if @@ -1069,19 +1076,19 @@ public class PhotoView extends GLView { } @Override - public boolean onFling(float velocityX, float velocityY) { + public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if (mIgnoreSwipingGesture) return true; if (mModeChanged) return true; if (swipeImages(velocityX, velocityY)) { mIgnoreUpEvent = true; } else { - flingImages(velocityX, velocityY); + flingImages(velocityX, velocityY, Math.abs(e2.getY() - e1.getY())); } mHadFling = true; return true; } - private boolean flingImages(float velocityX, float velocityY) { + private boolean flingImages(float velocityX, float velocityY, float dY) { int vx = (int) (velocityX + 0.5f); int vy = (int) (velocityY + 0.5f); if (!mFilmMode) { @@ -1098,11 +1105,13 @@ public class PhotoView extends GLView { } int maxVelocity = GalleryUtils.dpToPixel(MAX_DISMISS_VELOCITY); int escapeVelocity = GalleryUtils.dpToPixel(SWIPE_ESCAPE_VELOCITY); + int escapeDistance = GalleryUtils.dpToPixel(SWIPE_ESCAPE_DISTANCE); int centerY = mPositionController.getPosition(mTouchBoxIndex) .centerY(); boolean fastEnough = (Math.abs(vy) > escapeVelocity) && (Math.abs(vy) > Math.abs(vx)) - && ((vy > 0) == (centerY > getHeight() / 2)); + && ((vy > 0) == (centerY > getHeight() / 2)) + && dY >= escapeDistance; if (fastEnough) { vy = Math.min(vy, maxVelocity); int duration = mPositionController.flingFilmY(mTouchBoxIndex, vy); @@ -1236,7 +1245,10 @@ public class PhotoView extends GLView { if (mFilmMode) { int xi = (int) (x + 0.5f); int yi = (int) (y + 0.5f); - mTouchBoxIndex = mPositionController.hitTest(xi, yi); + // We only care about being within the x bounds, necessary for + // handling very wide images which are otherwise very hard to fling + mTouchBoxIndex = mPositionController.hitTest(xi, getHeight() / 2); + if (mTouchBoxIndex < mPrevBound || mTouchBoxIndex > mNextBound) { mTouchBoxIndex = Integer.MAX_VALUE; } else { @@ -1406,8 +1418,9 @@ public class PhotoView extends GLView { boolean full = !mFilmMode && mPictures.get(0).isCamera() && mPositionController.isCenter() && mPositionController.isAtMinimalScale(); - if (full != mFullScreenCamera) { + if (mFirst || full != mFullScreenCamera) { mFullScreenCamera = full; + mFirst = false; mListener.onFullScreenChanged(full); if (full) mHandler.sendEmptyMessage(MSG_UNDO_BAR_FULL_CAMERA); } |