clampCenterX();
- mViewItem[mCurrentItem].layoutIn(mDrawArea, mCenterX, mScale);
-
- int currentViewLeft = mViewItem[mCurrentItem].getLeftPosition();
- int currentViewCenter = mViewItem[mCurrentItem].getCenterX();
- int fullScreenWidth = mDrawArea.width() + mViewGap;
/**
* Transformed scale fraction between 0 and 1. 0 if the scale is
* {@link FILM_STRIP_SCALE}. 1 if the scale is {@link FULL_SCREEN_SCALE}
float scaleFraction = mViewAnimInterpolator.getInterpolation(
(mScale - FILM_STRIP_SCALE) / (FULL_SCREEN_SCALE - FILM_STRIP_SCALE));
+ // Layout the current ViewItem first.
+ if (scaleFraction == 1
+ && mViewItem[mCurrentItem - 1] != null
+ && mCenterX < mViewItem[mCurrentItem].getCenterX()) {
+ // In full-screen and it's not the first one and mCenterX is on
+ // the left of the center, we draw the current one to "fade down".
+ ViewItem curr = mViewItem[mCurrentItem];
+ ViewItem prev = mViewItem[mCurrentItem - 1];
+ int currCenterX = curr.getCenterX();
+ int prevCenterX = prev.getCenterX();
+ float fadeUpFraction =
+ ((float) mCenterX - prevCenterX)
+ / (currCenterX - prevCenterX);
+ curr.layoutIn(mDrawArea, currCenterX,
+ FILM_STRIP_SCALE
+ + (1f - FILM_STRIP_SCALE) * fadeUpFraction);
+ curr.getView().setAlpha(fadeUpFraction);
+ } else {
+ mViewItem[mCurrentItem].layoutIn(mDrawArea, mCenterX, mScale);
+ }
+
+ // Layout the rest dependent on the current scale.
+ int currentViewLeft = mViewItem[mCurrentItem].getLeftPosition();
+ int currentViewCenter = mViewItem[mCurrentItem].getCenterX();
+ int fullScreenWidth = mDrawArea.width() + mViewGap;
+
// images on the left
for (int itemID = mCurrentItem - 1; itemID >= 0; itemID--) {
ViewItem curr = mViewItem[itemID];
ViewItem next = mViewItem[itemID + 1];
int myLeft =
- next.getLeftPosition() - curr.getView().getMeasuredWidth() - mViewGap;
+ next.getLeftPosition() - curr.getView().getMeasuredWidth()
+ - mViewGap;
curr.setLeftPosition(myLeft);
curr.layoutIn(mDrawArea, mCenterX, mScale);
curr.getView().setAlpha(1f);
int itemDiff = mCurrentItem - itemID;
curr.setTranslationX(
(currentViewCenter
- - fullScreenWidth * itemDiff - curr.getCenterX()) * scaleFraction,
+ - fullScreenWidth * itemDiff - curr.getCenterX()) * scaleFraction,
mScale);
}
ViewItem prev = mViewItem[itemID - 1];
int myLeft =
- prev.getLeftPosition() + prev.getView().getMeasuredWidth() + mViewGap;
+ prev.getLeftPosition() + prev.getView().getMeasuredWidth()
+ + mViewGap;
curr.setLeftPosition(myLeft);
curr.layoutIn(mDrawArea, mCenterX, mScale);
View currView = curr.getView();
if (scaleFraction == 1) {
- currView.setVisibility(INVISIBLE);
+ // It's in full-screen mode.
+ if (itemID == mCurrentItem + 1) {
+ int currCenterX = curr.getCenterX();
+ int prevCenterX = prev.getCenterX();
+ if (mCenterX == prevCenterX) {
+ currView.setVisibility(INVISIBLE);
+ } else {
+ float fadeUpFraction =
+ ((float) mCenterX - prevCenterX)
+ / (currCenterX - prevCenterX);
+ curr.layoutIn(mDrawArea, currCenterX,
+ FILM_STRIP_SCALE
+ + (1f - FILM_STRIP_SCALE) * fadeUpFraction);
+ currView.setAlpha(fadeUpFraction);
+ currView.setVisibility(VISIBLE);
+ }
+ } else {
+ currView.setVisibility(INVISIBLE);
+ }
+ curr.setTranslationX(0, mScale);
} else {
if (currView.getVisibility() == INVISIBLE) {
currView.setVisibility(VISIBLE);
currView.setVisibility(INVISIBLE);
}
}
+ curr.setTranslationX((currentViewLeft - myLeft) * scaleFraction, mScale);
}
- curr.setTranslationX((currentViewLeft - myLeft) * scaleFraction, mScale);
}
stepIfNeeded();
if (mViewItem[mCurrentItem] == null) {
return;
}
- if (getCurrentViewType() == ImageData.TYPE_STICKY_VIEW) {
- // we are in camera mode by default.
- mController.lockAtCurrentView();
- }
for (int i = 1; mCurrentItem + i < BUFFER_SIZE || mCurrentItem - i >= 0; i++) {
int itemID = mCurrentItem + i;
if (itemID < BUFFER_SIZE && mViewItem[itemID - 1] != null) {
return;
}
if (mCenterX == item.getCenterX()) {
- if (inFullScreen()) {
- lockAtCurrentView();
- } else if (inFilmStrip()) {
+ if (inFilmStrip()) {
unlockPosition();
snapInCenter();
}
if (deltaX > 0 && inCameraFullscreen()) {
mController.gotoFilmStrip();
}
- mController.scroll(deltaX);
+ // Multiplied by 1.2 to make it more easy to swipe.
+ mController.scroll((int) (deltaX * 1.2));
}
layoutChildren();
@Override
public boolean onFling(float velocityX, float velocityY) {
- if (Math.abs(velocityX) > Math.abs(velocityY)) {
- mController.fling(velocityX);
- } else {
+ if (Math.abs(velocityX) < Math.abs(velocityY)) {
// ignore vertical fling.
+ return true;
+ }
+
+ if (mScale != FILM_STRIP_SCALE) {
+ // No fling in other modes.
+ return true;
}
+ mController.fling(velocityX);
return true;
}