forked from organicmaps/organicmaps
[android] Refactored the nav buttons animation, added debug logs
This commit is contained in:
parent
c011bf379f
commit
9c2b46556f
3 changed files with 57 additions and 10 deletions
|
@ -1427,10 +1427,11 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
if (completionListener != null)
|
||||
completionListener.run();
|
||||
|
||||
if (mRoutingPlanInplaceController.getHeight() > 0)
|
||||
int routingPlanPanelHeight = mRoutingPlanInplaceController.getHeight();
|
||||
if (routingPlanPanelHeight > 0)
|
||||
{
|
||||
setNavButtonsTopLimit(mRoutingPlanInplaceController.getHeight());
|
||||
adjustCompassAndTraffic(mRoutingPlanInplaceController.getHeight());
|
||||
adjustCompassAndTraffic(routingPlanPanelHeight);
|
||||
setNavButtonsTopLimit(routingPlanPanelHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1444,8 +1445,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
if (completionListener != null)
|
||||
completionListener.run();
|
||||
|
||||
setNavButtonsTopLimit(0);
|
||||
adjustCompassAndTraffic(UiUtils.getStatusBarHeight(getApplicationContext()));
|
||||
setNavButtonsTopLimit(0);
|
||||
}
|
||||
|
||||
mPlacePage.refreshViews();
|
||||
|
@ -1463,8 +1464,9 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
if (mNavAnimationController == null)
|
||||
return;
|
||||
|
||||
setNavButtonsTopLimit(mRoutingPlanInplaceController.getHeight());
|
||||
adjustCompassAndTraffic(mRoutingPlanInplaceController.getHeight());
|
||||
int routingPlanPanelHeight = mRoutingPlanInplaceController.getHeight();
|
||||
adjustCompassAndTraffic(routingPlanPanelHeight);
|
||||
setNavButtonsTopLimit(routingPlanPanelHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1473,8 +1475,9 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
if (mNavAnimationController == null)
|
||||
return;
|
||||
|
||||
setNavButtonsTopLimit(visible ? mSearchController.getToolbar().getHeight() : 0);
|
||||
adjustCompassAndTraffic(visible ? mSearchController.getToolbar().getHeight(): UiUtils.getStatusBarHeight(this));
|
||||
int toolbarHeight = mSearchController.getToolbar().getHeight();
|
||||
adjustCompassAndTraffic(visible ? toolbarHeight: UiUtils.getStatusBarHeight(this));
|
||||
setNavButtonsTopLimit(visible ? toolbarHeight : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,11 +6,15 @@ import android.support.annotation.Nullable;
|
|||
import android.view.View;
|
||||
|
||||
import com.mapswithme.maps.routing.RoutingController;
|
||||
import com.mapswithme.maps.widget.placepage.PlacePageView;
|
||||
import com.mapswithme.util.Animations;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
import com.mapswithme.util.log.DebugLogger;
|
||||
|
||||
class NavigationButtonsAnimationController
|
||||
{
|
||||
private static final DebugLogger LOGGER =
|
||||
new DebugLogger(NavigationButtonsAnimationController.class.getSimpleName());
|
||||
@NonNull
|
||||
private final View mZoomIn;
|
||||
@NonNull
|
||||
|
@ -26,6 +30,7 @@ class NavigationButtonsAnimationController
|
|||
|
||||
private boolean mIsZoomAnimate;
|
||||
private boolean mIsMyPosAnimate;
|
||||
private float mLastPlacePageY;
|
||||
|
||||
NavigationButtonsAnimationController(@NonNull View zoomIn, @NonNull View zoomOut,
|
||||
@NonNull View myPosition, @Nullable View center)
|
||||
|
@ -36,6 +41,7 @@ class NavigationButtonsAnimationController
|
|||
mCenter = center;
|
||||
Resources res = mZoomIn.getResources();
|
||||
mMargin = res.getDimension(R.dimen.nav_button_top_limit);
|
||||
mLastPlacePageY = res.getDisplayMetrics().heightPixels;
|
||||
calculateLimitTranslations();
|
||||
}
|
||||
|
||||
|
@ -130,8 +136,44 @@ class NavigationButtonsAnimationController
|
|||
if (mCenter == null || mBottom == 0)
|
||||
return;
|
||||
|
||||
final float translation = translationY - mBottom;
|
||||
update(translation <= 0 ? translation : 0);
|
||||
float translation = translationY - mBottom;
|
||||
if (shouldMoveNavButtons(translationY, translation))
|
||||
update(translation);
|
||||
else
|
||||
update(0);
|
||||
|
||||
mLastPlacePageY = translationY;
|
||||
}
|
||||
|
||||
private boolean shouldMoveNavButtons(float ppTranslationY, float translation)
|
||||
{
|
||||
if (ppTranslationY == mLastPlacePageY)
|
||||
{
|
||||
LOGGER.d("Start of movement. Nav buttons are no needed to be moved");
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean isMoveUp = ppTranslationY < mLastPlacePageY;
|
||||
if (isMoveUp)
|
||||
{
|
||||
if (translation > 0)
|
||||
{
|
||||
LOGGER.d("Move up. Bottom limit hasn't been reached yet.");
|
||||
return false;
|
||||
}
|
||||
|
||||
LOGGER.d("Move up. PP follows the nav buttons.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (translation <= 0)
|
||||
{
|
||||
LOGGER.d("Move down. Bottom limit hasn't been reached yet.");
|
||||
return true;
|
||||
}
|
||||
|
||||
LOGGER.d("Move down. Nav buttons follow PP.");
|
||||
return false;
|
||||
}
|
||||
|
||||
void update()
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.support.annotation.Nullable;
|
|||
import android.support.v4.view.GestureDetectorCompat;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
@ -499,6 +500,7 @@ class BottomPlacePageAnimationController extends BasePlacePageAnimationControlle
|
|||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation)
|
||||
{
|
||||
// FIXME: This translation adds a weird jumping up at end of PP closing
|
||||
mPlacePage.setTranslationY((Float) animation.getAnimatedValue());
|
||||
notifyProgress();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue