[android] reset place page scroll on open #5159

Merged
arnaudvergnet merged 2 commits from pp-reset-scroll into master 2023-05-18 20:43:28 +00:00

View file

@ -189,14 +189,6 @@ public class PlacePageController extends Fragment implements
return items;
}
private void open()
{
// Only collapse the place page if the data is different from the one already available
mShouldCollapse = PlacePageUtils.isHiddenState(mPlacePageBehavior.getState()) || !MapObject.same(mPreviousMapObject, mMapObject);
mPreviousMapObject = mMapObject;
// Place page will automatically open when the bottom sheet content is loaded so we can compute the peek height
}
private void close()
{
mPlacePageBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
@ -306,7 +298,12 @@ public class PlacePageController extends Fragment implements
mPlacePage.post(() -> {
setPeekHeight();
if (mShouldCollapse && !PlacePageUtils.isCollapsedState(mPlacePageBehavior.getState()))
{
mPlacePageBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
// Make sure to reset the scroll position when opening the place page
if (mPlacePage.getScrollY() != 0)
mPlacePage.setScrollY(0);
}
mShouldCollapse = false;
});
}
@ -558,7 +555,10 @@ public class PlacePageController extends Fragment implements
mMapObject = mapObject;
if (mapObject != null)
{
open();
// Only collapse the place page if the data is different from the one already available
mShouldCollapse = PlacePageUtils.isHiddenState(mPlacePageBehavior.getState()) || !MapObject.same(mPreviousMapObject, mMapObject);
mPreviousMapObject = mMapObject;
// Place page will automatically open when the bottom sheet content is loaded so we can compute the peek height
createPlacePageFragments();
updateButtons(
mapObject,