forked from organicmaps/organicmaps
[android] Rolled back animation util class to fix menu appearing
This commit is contained in:
parent
ac2ead6063
commit
56c890e2b7
2 changed files with 109 additions and 2 deletions
android/src/com/mapswithme
|
@ -1,7 +1,6 @@
|
|||
package com.mapswithme.maps.widget.menu;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
@ -13,6 +12,7 @@ import com.mapswithme.maps.R;
|
|||
import com.mapswithme.maps.downloader.MapManager;
|
||||
import com.mapswithme.maps.downloader.UpdateInfo;
|
||||
import com.mapswithme.maps.routing.RoutingController;
|
||||
import com.mapswithme.util.Animations;
|
||||
import com.mapswithme.util.Graphics;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
|
||||
|
@ -422,6 +422,15 @@ public class MainMenu extends BaseMenu
|
|||
|
||||
public void showLineFrame(boolean show)
|
||||
{
|
||||
UiUtils.showIf(show, mFrame);
|
||||
if (show)
|
||||
{
|
||||
UiUtils.hide(mFrame);
|
||||
Animations.appearSliding(mFrame, Animations.BOTTOM, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
UiUtils.show(mFrame);
|
||||
Animations.disappearSliding(mFrame, Animations.BOTTOM, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
98
android/src/com/mapswithme/util/Animations.java
Normal file
98
android/src/com/mapswithme/util/Animations.java
Normal file
|
@ -0,0 +1,98 @@
|
|||
package com.mapswithme.util;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.support.annotation.IntDef;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.View;
|
||||
import android.view.ViewPropertyAnimator;
|
||||
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
public final class Animations
|
||||
{
|
||||
private Animations() {}
|
||||
|
||||
@IntDef({LEFT, RIGHT, TOP, BOTTOM})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@interface AnimationDirection {}
|
||||
static final int LEFT = 0;
|
||||
static final int RIGHT = 1;
|
||||
static final int TOP = 2;
|
||||
public static final int BOTTOM = 3;
|
||||
|
||||
private static final int DURATION_DEFAULT = MwmApplication.get().getResources().getInteger(R.integer.anim_default);
|
||||
|
||||
public static void appearSliding(final View view, @AnimationDirection int appearFrom, @Nullable final Runnable completionListener)
|
||||
{
|
||||
if (UiUtils.isVisible(view))
|
||||
{
|
||||
if (completionListener != null)
|
||||
completionListener.run();
|
||||
return;
|
||||
}
|
||||
final ViewPropertyAnimator animator = view.animate().setDuration(DURATION_DEFAULT).alpha(1).setListener(new UiUtils.SimpleAnimatorListener()
|
||||
{
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation)
|
||||
{
|
||||
if (completionListener != null)
|
||||
completionListener.run();
|
||||
}
|
||||
});
|
||||
|
||||
switch (appearFrom)
|
||||
{
|
||||
case LEFT:
|
||||
case RIGHT:
|
||||
animator.translationX(0);
|
||||
break;
|
||||
case TOP:
|
||||
case BOTTOM:
|
||||
animator.translationY(0);
|
||||
break;
|
||||
}
|
||||
|
||||
UiUtils.show(view);
|
||||
}
|
||||
|
||||
public static void disappearSliding(final View view, @AnimationDirection int disappearTo, @Nullable final Runnable completionListener)
|
||||
{
|
||||
if (!UiUtils.isVisible(view))
|
||||
{
|
||||
if (completionListener != null)
|
||||
completionListener.run();
|
||||
return;
|
||||
}
|
||||
|
||||
final ViewPropertyAnimator animator = view.animate().setDuration(DURATION_DEFAULT).alpha(0).setListener(new UiUtils.SimpleAnimatorListener()
|
||||
{
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation)
|
||||
{
|
||||
UiUtils.hide(view);
|
||||
if (completionListener != null)
|
||||
completionListener.run();
|
||||
}
|
||||
});
|
||||
|
||||
switch (disappearTo)
|
||||
{
|
||||
case RIGHT:
|
||||
animator.translationX(view.getWidth());
|
||||
break;
|
||||
case LEFT:
|
||||
animator.translationX(-view.getWidth());
|
||||
break;
|
||||
case BOTTOM:
|
||||
animator.translationY(view.getHeight());
|
||||
break;
|
||||
case TOP:
|
||||
animator.translationY(-view.getHeight());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue