blob: 321b9182ce8ec436830c41e79f73027b6393aa9d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
package com.mapswithme.maps.routing;
import android.animation.Animator;
import android.animation.ValueAnimator;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.mapswithme.maps.MwmActivity;
import com.mapswithme.maps.R;
import com.mapswithme.util.UiUtils;
public class RoutingPlanInplaceController extends RoutingPlanController
{
@NonNull
private final RoutingPlanListener mRoutingPlanListener;
@Nullable
private Animator mAnimator;
public RoutingPlanInplaceController(@NonNull MwmActivity activity,
@NonNull RoutingPlanListener routingPlanListener,
@NonNull RoutingBottomMenuListener listener)
{
super(activity.findViewById(R.id.routing_plan_frame), activity, routingPlanListener, listener);
mRoutingPlanListener = routingPlanListener;
}
public void show(final boolean show)
{
if (mAnimator != null)
{
mAnimator.cancel();
mAnimator.removeAllListeners();
}
if (show)
UiUtils.show(getFrame());
mAnimator = animateFrame(show, new Runnable()
{
@Override
public void run()
{
if (!show)
UiUtils.hide(getFrame());
}
});
}
public void onSaveState(@NonNull Bundle outState)
{
saveRoutingPanelState(outState);
}
public void restoreState(@NonNull Bundle state)
{
restoreRoutingPanelState(state);
}
@Nullable
private ValueAnimator animateFrame(final boolean show, final @Nullable Runnable completion)
{
if (!checkFrameHeight())
{
getFrame().post(new Runnable()
{
@Override
public void run()
{
animateFrame(show, completion);
}
});
return null;
}
mRoutingPlanListener.onRoutingPlanStartAnimate(show);
ValueAnimator animator =
ValueAnimator.ofFloat(show ? -getFrame().getHeight() : 0, show ? 0 : -getFrame().getHeight());
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener()
{
@Override
public void onAnimationUpdate(ValueAnimator animation)
{
getFrame().setTranslationY((Float) animation.getAnimatedValue());
}
});
animator.addListener(new UiUtils.SimpleAnimatorListener()
{
@Override
public void onAnimationEnd(Animator animation)
{
if (completion != null)
completion.run();
}
});
animator.setDuration(ANIM_TOGGLE);
animator.start();
return animator;
}
public interface RoutingPlanListener
{
void onRoutingPlanStartAnimate(boolean show);
}
}
|