[android] Recovered moving of nav button on map while place page is sliding

This commit is contained in:
Александр Зацепин 2019-02-07 19:22:24 +03:00 committed by yoksnod
parent dcf5ac9835
commit 21ade67ef1
4 changed files with 35 additions and 9 deletions

View file

@ -153,7 +153,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
OnSubwayLayerToggleListener,
BookmarkManager.BookmarksCatalogListener,
AdsRemovalPurchaseControllerProvider,
AdsRemovalActivationCallback
AdsRemovalActivationCallback,
PlacePageController.SlideListener
{
private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.MISC);
private static final String TAG = MwmActivity.class.getSimpleName();
@ -234,6 +235,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
private PurchaseController<FailedPurchaseChecker> mBookmarkPurchaseController;
@NonNull
private final OnClickListener mOnMyPositionClickListener = new CurrentPositionClickListener();
@SuppressWarnings("NullableProblems")
@NonNull
private PlacePageController mPlacePageController;
@ -475,8 +477,9 @@ public class MwmActivity extends BaseMwmFragmentActivity
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
setContentView(R.layout.activity_map);
mPlacePageController = new BottomSheetPlacePageController(this, this);
mPlacePageController = new BottomSheetPlacePageController(this, this, this);
mPlacePageController.initialize();
mIsLaunchByDeepLink = getIntent().getBooleanExtra(EXTRA_LAUNCH_BY_DEEP_LINK, false);
initViews();
@ -1528,12 +1531,19 @@ public class MwmActivity extends BaseMwmFragmentActivity
public void onProgress(float translationX, float translationY)
{
if (mNavAnimationController != null)
mNavAnimationController.onPlacePageMoved(translationY);
mNavAnimationController.move(translationY);
if (mPlacePageTracker != null)
mPlacePageTracker.onMove();
}
*/
@Override
public void onPlacePageSlide(int top)
{
if (mNavAnimationController != null)
mNavAnimationController.move(top);
}
@Override
public void onClick(View v)
{

View file

@ -181,13 +181,12 @@ class NavigationButtonsAnimationController
});
}
void onPlacePageMoved(float translationY)
void move(float translationY)
{
if (UiUtils.isLandscape(mMyPosition.getContext()) || mMyPositionBottom == 0 || mContentHeight == 0)
if (mMyPositionBottom == 0 || mContentHeight == 0)
return;
final float amount = mCurrentOffset > 0 ? mMargin : -mMargin;
final float translation = translationY - (mMyPositionBottom - mCurrentOffset + amount);
final float translation = translationY - (mMyPositionBottom - mCurrentOffset);
update(translation <= mCurrentOffset ? translation : mCurrentOffset);
}
@ -238,6 +237,7 @@ class NavigationButtonsAnimationController
&& (RoutingController.get().isPlanning() || RoutingController.get().isNavigating());
}
// TODO: check for tablet
void slide(boolean isDown, float distance)
{
if (UiUtils.isLandscape(mMyPosition.getContext())

View file

@ -70,6 +70,8 @@ public class BottomSheetPlacePageController implements PlacePageController, Loca
@NonNull
private final AdsRemovalPurchaseControllerProvider mPurchaseControllerProvider;
@NonNull
private final SlideListener mSlideListener;
@NonNull
private final AnchorBottomSheetBehavior.BottomSheetCallback mSheetCallback
= new AnchorBottomSheetBehavior.BottomSheetCallback()
@ -98,6 +100,8 @@ public class BottomSheetPlacePageController implements PlacePageController, Loca
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset)
{
mSlideListener.onPlacePageSlide(bottomSheet.getTop());
if (slideOffset < 0)
return;
@ -148,7 +152,6 @@ public class BottomSheetPlacePageController implements PlacePageController, Loca
int height = coordinatorLayout.getHeight();
int maxY = mPlacePage.getHeight() > height * (1 - ANCHOR_RATIO)
? (int) (height * ANCHOR_RATIO) : height - mPlacePage.getHeight();
Resources res = mActivity.getResources();
return maxY + mOpenBannerTouchSlop;
}
@ -160,10 +163,12 @@ public class BottomSheetPlacePageController implements PlacePageController, Loca
}
public BottomSheetPlacePageController(@NonNull Activity activity,
@NonNull AdsRemovalPurchaseControllerProvider provider)
@NonNull AdsRemovalPurchaseControllerProvider provider,
@NonNull SlideListener listener)
{
mActivity = activity;
mPurchaseControllerProvider = provider;
mSlideListener = listener;
}
@Override
@ -297,10 +302,16 @@ public class BottomSheetPlacePageController implements PlacePageController, Loca
mPlacePageBehavior.setPeekHeight(peekHeight);
}
});
animator.addUpdateListener(animation -> onUpdateTranslation());
animator.start();
}
private void onUpdateTranslation()
{
mSlideListener.onPlacePageSlide((int) (mPlacePage.getTop() + mPlacePage.getTranslationY()));
}
private void setPlacePageAnchor()
{
View parent = (View) mPlacePage.getParent();

View file

@ -14,4 +14,9 @@ public interface PlacePageController extends Initializable, Savable<Bundle>,
void openFor(@NonNull MapObject object);
void close();
boolean isClosed();
interface SlideListener
{
void onPlacePageSlide(int top);
}
}