|
@@ -33,34 +33,45 @@ public class NavigationAnimator extends BaseAnimator {
|
33
|
33
|
}
|
34
|
34
|
|
35
|
35
|
public void push(ViewController appearing, ViewController disappearing, Options options, Runnable onAnimationEnd) {
|
|
36
|
+ AnimatorSet set = createPushAnimator(appearing, onAnimationEnd);
|
|
37
|
+ runningPushAnimations.put(appearing.getView(), set);
|
|
38
|
+ if (options.animations.push.sharedElements.hasValue()) {
|
|
39
|
+ pushWithElementTransition(appearing, disappearing, options, set);
|
|
40
|
+ } else {
|
|
41
|
+ pushWithoutElementTransitions(appearing, options, set);
|
|
42
|
+ }
|
|
43
|
+ }
|
|
44
|
+
|
|
45
|
+ private AnimatorSet createPushAnimator(ViewController appearing, Runnable onAnimationEnd) {
|
|
46
|
+ AnimatorSet set = new AnimatorSet();
|
|
47
|
+ set.addListener(new AnimatorListenerAdapter() {
|
|
48
|
+ private boolean isCancelled;
|
|
49
|
+
|
|
50
|
+ @Override
|
|
51
|
+ public void onAnimationCancel(Animator animation) {
|
|
52
|
+ isCancelled = true;
|
|
53
|
+ runningPushAnimations.remove(appearing.getView());
|
|
54
|
+ onAnimationEnd.run();
|
|
55
|
+ }
|
|
56
|
+
|
|
57
|
+ @Override
|
|
58
|
+ public void onAnimationEnd(Animator animation) {
|
|
59
|
+ if (!isCancelled) {
|
|
60
|
+ runningPushAnimations.remove(appearing.getView());
|
|
61
|
+ onAnimationEnd.run();
|
|
62
|
+ }
|
|
63
|
+ }
|
|
64
|
+ });
|
|
65
|
+ return set;
|
|
66
|
+ }
|
|
67
|
+
|
|
68
|
+ private void pushWithElementTransition(ViewController appearing, ViewController disappearing, Options options, AnimatorSet set) {
|
36
|
69
|
appearing.getView().setAlpha(0);
|
37
|
70
|
transitionManager.createTransitions(
|
38
|
71
|
options.animations.push,
|
39
|
72
|
disappearing,
|
40
|
73
|
appearing,
|
41
|
74
|
transitionSet -> {
|
42
|
|
- AnimatorSet set = new AnimatorSet();
|
43
|
|
- runningPushAnimations.put(appearing.getView(), set);
|
44
|
|
- set.addListener(new AnimatorListenerAdapter() {
|
45
|
|
- private boolean isCancelled;
|
46
|
|
-
|
47
|
|
- @Override
|
48
|
|
- public void onAnimationCancel(Animator animation) {
|
49
|
|
- isCancelled = true;
|
50
|
|
- runningPushAnimations.remove(appearing.getView());
|
51
|
|
- onAnimationEnd.run();
|
52
|
|
- }
|
53
|
|
-
|
54
|
|
- @Override
|
55
|
|
- public void onAnimationEnd(Animator animation) {
|
56
|
|
- if (!isCancelled) {
|
57
|
|
- runningPushAnimations.remove(appearing.getView());
|
58
|
|
- onAnimationEnd.run();
|
59
|
|
- }
|
60
|
|
- }
|
61
|
|
- });
|
62
|
|
-
|
63
|
|
-
|
64
|
75
|
if (transitionSet.isEmpty()) {
|
65
|
76
|
set.playTogether(options.animations.push.content.getAnimation(appearing.getView(), getDefaultPushAnimation(appearing.getView())));
|
66
|
77
|
} else {
|
|
@@ -76,6 +87,20 @@ public class NavigationAnimator extends BaseAnimator {
|
76
|
87
|
);
|
77
|
88
|
}
|
78
|
89
|
|
|
90
|
+ private void pushWithoutElementTransitions(ViewController appearing, Options options, AnimatorSet set) {
|
|
91
|
+ if (options.animations.push.waitForRender.isTrue()) {
|
|
92
|
+ appearing.getView().setAlpha(0);
|
|
93
|
+ appearing.addOnAppearedListener(() -> {
|
|
94
|
+ appearing.getView().setAlpha(1);
|
|
95
|
+ set.playTogether(options.animations.push.content.getAnimation(appearing.getView(), getDefaultPushAnimation(appearing.getView())));
|
|
96
|
+ set.start();
|
|
97
|
+ });
|
|
98
|
+ } else {
|
|
99
|
+ set.playTogether(options.animations.push.content.getAnimation(appearing.getView(), getDefaultPushAnimation(appearing.getView())));
|
|
100
|
+ set.start();
|
|
101
|
+ }
|
|
102
|
+ }
|
|
103
|
+
|
79
|
104
|
public void pop(View view, NestedAnimationsOptions pop, Runnable onAnimationEnd) {
|
80
|
105
|
if (runningPushAnimations.containsKey(view)) {
|
81
|
106
|
runningPushAnimations.get(view).cancel();
|