forked from organicmaps/organicmaps
[android] simplify viewport size update
Signed-off-by: Arnaud Vergnet <arnaud.vergnet@mailo.com>
This commit is contained in:
parent
f3225be8fa
commit
f8d77e6acf
2 changed files with 8 additions and 16 deletions
|
@ -81,7 +81,7 @@ public class PlacePageController extends Fragment implements
|
|||
if (PlacePageUtils.isSettlingState(newState) || PlacePageUtils.isDraggingState(newState))
|
||||
return;
|
||||
|
||||
PlacePageUtils.moveViewportUp(mPlacePage, mViewportMinHeight);
|
||||
PlacePageUtils.updateMapViewport(mCoordinator, mDistanceToTop, mViewportMinHeight);
|
||||
|
||||
if (PlacePageUtils.isHiddenState(newState))
|
||||
onHiddenInternal();
|
||||
|
@ -165,7 +165,7 @@ public class PlacePageController extends Fragment implements
|
|||
private void onHiddenInternal()
|
||||
{
|
||||
Framework.nativeDeactivatePopup();
|
||||
PlacePageUtils.moveViewportUp(mPlacePage, mViewportMinHeight);
|
||||
PlacePageUtils.updateMapViewport(mCoordinator, mDistanceToTop, mViewportMinHeight);
|
||||
resetPlacePageHeightBounds();
|
||||
removePlacePageFragments();
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ public class PlacePageController extends Fragment implements
|
|||
mViewModel.setPlacePageDistanceToTop(mDistanceToTop);
|
||||
if (value == peekHeight)
|
||||
{
|
||||
PlacePageUtils.moveViewportUp(mPlacePage, mViewportMinHeight);
|
||||
PlacePageUtils.updateMapViewport(mCoordinator, mDistanceToTop, mViewportMinHeight);
|
||||
setPlacePageHeightBounds();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package app.organicmaps.widget.placepage;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.PopupMenu;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -17,18 +15,12 @@ import java.util.List;
|
|||
|
||||
public class PlacePageUtils
|
||||
{
|
||||
static void moveViewportUp(@NonNull View placePageView, int viewportMinHeight)
|
||||
static void updateMapViewport(@NonNull View parent, int placePageDistanceToTop, int viewportMinHeight)
|
||||
{
|
||||
placePageView.post(() -> {
|
||||
final View coordinatorLayout = (ViewGroup) placePageView.getParent();
|
||||
final int viewPortWidth = coordinatorLayout.getWidth();
|
||||
int viewPortHeight = coordinatorLayout.getHeight();
|
||||
Rect sheetRect = new Rect();
|
||||
placePageView.getGlobalVisibleRect(sheetRect);
|
||||
|
||||
viewPortHeight -= sheetRect.height();
|
||||
if (viewPortHeight >= viewportMinHeight)
|
||||
Framework.nativeSetVisibleRect(0, 0, viewPortWidth, viewPortHeight);
|
||||
parent.post(() -> {
|
||||
final int screenWidth = parent.getWidth();
|
||||
if (placePageDistanceToTop >= viewportMinHeight)
|
||||
Framework.nativeSetVisibleRect(0, 0, screenWidth, placePageDistanceToTop);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue