diff --git a/android/res/layout/place_page.xml b/android/res/layout/place_page.xml
index 76fa88dda7..9dfe3b3d7e 100644
--- a/android/res/layout/place_page.xml
+++ b/android/res/layout/place_page.xml
@@ -8,7 +8,7 @@
android:overScrollMode="never"
android:layout_above="@+id/pp__buttons">
-
@@ -31,7 +31,7 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="?cardBackground"/>
-
+
X_TO_Y_SCROLL_RATIO * Math.abs(distanceX);
if (isVertical)
@@ -185,7 +203,7 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle
if (!translateBy(-distanceY))
{
boolean scrollable = isDetailContentScrollable();
- int maxTranslationY = mDetailsScroll.getHeight() - mDetailsContent.getHeight();
+ int maxTranslationY = mDetailsScroll.getHeight() - mContentHeight;
if ((scrollable && mDetailsScroll.getTranslationY() == 0)
|| (!scrollable && mDetailsScroll.getTranslationY() <= maxTranslationY))
{
@@ -201,6 +219,9 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
{
+ if (mIsHiding)
+ return true;
+
finishDrag(-velocityY);
return true;
}
@@ -208,6 +229,9 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle
@Override
public boolean onSingleTapConfirmed(MotionEvent e)
{
+ if (mIsHiding)
+ return true;
+
MotionEvent evt = MotionEvent.obtain(e.getDownTime(),
e.getEventTime(),
e.getAction(),
@@ -240,6 +264,7 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle
private void finishDrag(float distance)
{
+ mIsDragging = false;
final float currentTranslation = mDetailsScroll.getTranslationY();
if (currentTranslation > mDetailsScroll.getHeight())
{
@@ -303,7 +328,7 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle
float detailsTranslation = mDetailsScroll.getTranslationY() + distanceY;
final boolean isScrollable = isDetailContentScrollable();
boolean consumeEvent = true;
- final float maxTranslationY = mDetailsScroll.getHeight() - mDetailsContent.getHeight();
+ final float maxTranslationY = mDetailsScroll.getHeight() - mContentHeight;
if ((isScrollable && detailsTranslation < 0.0f) || detailsTranslation < maxTranslationY)
{
if (isScrollable)
@@ -335,6 +360,9 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle
@Override
protected void onStateChanged(final State currentState, final State newState, @MapObject.MapObjectType int type)
{
+ if (newState == State.HIDDEN && currentState == newState)
+ return;
+
prepareYTranslations(newState, type);
mDetailsScroll.setGestureDetector(mGestureDetector);
@@ -350,17 +378,7 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle
hidePlacePage();
break;
case PREVIEW:
- mPreview.addOnLayoutChangeListener(new View.OnLayoutChangeListener()
- {
- @Override
- public void onLayoutChange(View v, int left, int top, int right, int bottom,
- int oldLeft, int oldTop, int oldRight, int oldBottom)
- {
- mPreview.removeOnLayoutChangeListener(this);
- showPreview(currentState);
- }
- });
- mPreview.requestLayout();
+ showPreview(currentState);
break;
case DETAILS:
showDetails();
@@ -368,17 +386,7 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle
case FULLSCREEN:
if (isDetailContentScrollable())
mDetailsScroll.setGestureDetector(null);
- mDetailsScroll.addOnLayoutChangeListener(new View.OnLayoutChangeListener()
- {
- @Override
- public void onLayoutChange(View v, int left, int top, int right, int bottom,
- int oldLeft, int oldTop, int oldRight, int oldBottom)
- {
- mDetailsScroll.removeOnLayoutChangeListener(this);
- showFullscreen();
- }
- });
- mDetailsScroll.requestLayout();
+ showFullscreen();
break;
}
}
@@ -465,7 +473,7 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle
else
{
mCurrentAnimator = ValueAnimator.ofFloat(mDetailsScroll.getTranslationY(),
- mDetailsScroll.getHeight() - mDetailsContent.getHeight());
+ mDetailsScroll.getHeight() - mContentHeight);
}
mCurrentAnimator.addUpdateListener(new UpdateListener());
mCurrentAnimator.addListener(new AnimationListener());
@@ -482,7 +490,7 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle
else
{
mCurrentAnimator = ValueAnimator.ofFloat(mDetailsScroll.getTranslationY(),
- mDetailsScroll.getHeight() - mDetailsContent.getHeight());
+ mDetailsScroll.getHeight() - mContentHeight);
}
mCurrentAnimator.addUpdateListener(new UpdateListener());
mCurrentAnimator.addListener(new AnimationListener());
@@ -493,6 +501,7 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle
@SuppressLint("NewApi")
private void hidePlacePage()
{
+ mIsHiding = true;
if (mLayoutToolbar != null)
UiUtils.hide(mLayoutToolbar);
@@ -513,6 +522,7 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle
@Override
public void onAnimationEnd(Animator animation)
{
+ mIsHiding = false;
initialVisibility();
mPlacePage.setTranslationY(0);
mDetailsScroll.setTranslationY(mDetailsScroll.getHeight());
@@ -563,12 +573,31 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle
mBannerOpenListener = bannerOpenListener;
}
- @Override
- protected void onContentSizeChanged()
+ private boolean isOverDetailsState()
{
+ return mDetailsScroll.getTranslationY() < mScreenHeight - mDetailMaxHeight;
+ }
+
+ private void onContentSizeChanged()
+ {
+ if (mIsDragging || mCurrentScrollY > 0)
+ return;
+
MapObject object = mPlacePage.getMapObject();
if (object != null)
- onStateChanged(getState(), getState(), object.getMapObjectType());
+ {
+ State newState = getState();
+ if (isOverDetailsState())
+ newState = State.FULLSCREEN;
+ onStateChanged(getState(), newState, object.getMapObjectType());
+ }
+ }
+
+ @Override
+ public void onSizeChanged(int width, int height, int oldWidth, int oldHeight)
+ {
+ mContentHeight = height;
+ onContentSizeChanged();
}
private class UpdateListener implements ValueAnimator.AnimatorUpdateListener
diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java
index 75d3e390dc..f2a47777f7 100644
--- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java
+++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java
@@ -740,13 +740,10 @@ public class PlacePageView extends RelativeLayout
else
{
UiUtils.show(mHotelFacilities);
- boolean oldValue = mFacilitiesAdapter.isShowAll();
mFacilitiesAdapter.setShowAll(false);
mFacilitiesAdapter.setItems(Arrays.asList(info.mFacilities));
mHotelMoreFacilities.setVisibility(info.mFacilities.length > FacilitiesAdapter.MAX_COUNT
? VISIBLE : GONE);
- if (oldValue != mFacilitiesAdapter.isShowAll())
- mAnimationController.onContentSizeChanged();
}
}
@@ -862,7 +859,11 @@ public class PlacePageView extends RelativeLayout
public void onNeedOpenBanner()
{
if (mBannerController != null)
+ {
+ if (!mBannerController.isOpened())
+ compensateViewHeight(0);
mBannerController.open();
+ }
}
private void compensateViewHeight(int height)
@@ -947,12 +948,16 @@ public class PlacePageView extends RelativeLayout
int heightCompensation = 0;
if (mBannerController != null)
{
- if ((state == State.HIDDEN || state == State.PREVIEW) && !UiUtils.isLandscape(getContext()))
+ State lastState = getState();
+ boolean isLastStateNotHiddenOrPreview = lastState != State.HIDDEN
+ && lastState != State.PREVIEW;
+ if (isLastStateNotHiddenOrPreview && (state == State.HIDDEN || state == State.PREVIEW)
+ && !UiUtils.isLandscape(getContext()))
{
if (mBannerController.close())
heightCompensation = mBannerController.getLastBannerHeight();
}
- else
+ else if (isLastStateNotHiddenOrPreview)
{
mBannerController.open();
}
@@ -1590,14 +1595,12 @@ public class PlacePageView extends RelativeLayout
case R.id.tv__place_hotel_more:
UiUtils.hide(mHotelMoreDescription);
mTvHotelDescription.setMaxLines(Integer.MAX_VALUE);
- mAnimationController.onContentSizeChanged();
break;
case R.id.tv__place_hotel_facilities_more:
if (mSponsored != null && mMapObject != null)
Statistics.INSTANCE.trackHotelEvent(PP_HOTEL_FACILITIES, mSponsored, mMapObject);
UiUtils.hide(mHotelMoreFacilities);
mFacilitiesAdapter.setShowAll(true);
- mAnimationController.onContentSizeChanged();
break;
case R.id.tv__place_hotel_reviews_more:
if (isSponsored())
@@ -1817,7 +1820,6 @@ public class PlacePageView extends RelativeLayout
mCurrentCountry = null;
mDownloaderIcon.show(false);
UiUtils.hide(mDownloaderInfo);
- mAnimationController.onContentSizeChanged();
}
MwmActivity getActivity()
@@ -1844,16 +1846,5 @@ public class PlacePageView extends RelativeLayout
mPreview.setPadding(mPreview.getPaddingLeft(), mPreview.getPaddingTop(),
getPaddingRight(), mMarginBase);
}
- addOnLayoutChangeListener(new OnLayoutChangeListener()
- {
- @Override
- public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft,
- int oldTop, int oldRight, int oldBottom)
- {
- removeOnLayoutChangeListener(this);
- mAnimationController.onContentSizeChanged();
- }
- });
- requestLayout();
}
}