blob: 96b33fa212730872e4e1b740f1f40357a856f4ca (
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
|
package com.mapswithme.maps.widget;
import android.animation.Animator;
import android.content.Context;
import androidx.annotation.NonNull;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.FrameLayout;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
import com.mapswithme.util.UiUtils;
public class FadeView extends FrameLayout
{
private static final float FADE_ALPHA_VALUE = 0.4f;
private static final String PROPERTY_ALPHA = "alpha";
private static final int DURATION = MwmApplication.get().getResources().getInteger(R.integer.anim_fade_main);
private final Animator.AnimatorListener mFadeInListener = new UiUtils.SimpleAnimatorListener()
{
@Override
public void onAnimationEnd(Animator animation)
{
UiUtils.show(FadeView.this);
animation.removeListener(this);
}
};
private final Animator.AnimatorListener mFadeOutListener = new UiUtils.SimpleAnimatorListener()
{
@Override
public void onAnimationEnd(Animator animation)
{
UiUtils.hide(FadeView.this);
animation.removeListener(this);
}
};
public interface Listener
{
boolean onTouch();
}
private Listener mListener;
public FadeView(Context context)
{
super(context);
}
public FadeView(Context context, AttributeSet attrs)
{
super(context, attrs);
}
public FadeView(Context context, AttributeSet attrs, int defStyleAttr)
{
super(context, attrs, defStyleAttr);
}
public void setListener(Listener listener)
{
mListener = listener;
}
public void fadeIn()
{
setAlpha(0.0f);
UiUtils.show(this);
animate().alpha(FADE_ALPHA_VALUE)
.setDuration(DURATION)
.setListener(mFadeInListener)
.start();
}
public void fadeOut()
{
setAlpha(FADE_ALPHA_VALUE);
animate().alpha(0.0f)
.setDuration(DURATION)
.setListener(mFadeOutListener)
.start();
}
@Override
public boolean onTouchEvent(@NonNull MotionEvent event)
{
if (event.getAction() != MotionEvent.ACTION_DOWN)
return true;
if (mListener == null || mListener.onTouch())
fadeOut();
return true;
}
}
|