@@ -57,12 +57,12 @@ public class MotionEffect extends MotionHelper {
57
57
public static final int EAST = 2 ;
58
58
public static final int WEST = 3 ;
59
59
60
- private float fadeAlpha = 0.1f ;
61
- private int fadeStart = 49 ;
62
- private int fadeEnd = 50 ;
63
- private int fadeTranslationX = 0 ;
64
- private int fadeTranslationY = 0 ;
65
- private boolean fadeMoveStrict = true ;
60
+ private float motionEffectAlpha = 0.1f ;
61
+ private int motionEffectStart = 49 ;
62
+ private int motionEffectEnd = 50 ;
63
+ private int motionEffectTranslationX = 0 ;
64
+ private int motionEffectTranslationY = 0 ;
65
+ private boolean motionEffectStrictMove = true ;
66
66
private static final int UNSET = -1 ;
67
67
private int viewTransitionId = UNSET ;
68
68
@@ -88,31 +88,31 @@ private void init(Context context, AttributeSet attrs) {
88
88
final int N = a .getIndexCount ();
89
89
for (int i = 0 ; i < N ; i ++) {
90
90
int attr = a .getIndex (i );
91
- if (attr == R .styleable .MotionEffect_fadeMove_start ) {
92
- fadeStart = a .getInt (attr , fadeStart );
93
- fadeStart = Math .max (Math .min (fadeStart , 99 ), 0 );
94
- } else if (attr == R .styleable .MotionEffect_fadeMove_end ) {
95
- fadeEnd = a .getInt (attr , fadeEnd );
96
- fadeEnd = Math .max (Math .min (fadeEnd , 99 ), 0 );
97
- } else if (attr == R .styleable .MotionEffect_fadeMove_translationX ) {
98
- fadeTranslationX = a .getDimensionPixelOffset (attr , fadeTranslationX );
99
- } else if (attr == R .styleable .MotionEffect_fadeMove_translationY ) {
100
- fadeTranslationY = a .getDimensionPixelOffset (attr , fadeTranslationY );
101
- } else if (attr == R .styleable .MotionEffect_fadeMove_alpha ) {
102
- fadeAlpha = a .getFloat (attr , fadeAlpha );
103
- } else if (attr == R .styleable .MotionEffect_fadeMove_move ) {
91
+ if (attr == R .styleable .MotionEffect_motionEffect_start ) {
92
+ motionEffectStart = a .getInt (attr , motionEffectStart );
93
+ motionEffectStart = Math .max (Math .min (motionEffectStart , 99 ), 0 );
94
+ } else if (attr == R .styleable .MotionEffect_motionEffect_end ) {
95
+ motionEffectEnd = a .getInt (attr , motionEffectEnd );
96
+ motionEffectEnd = Math .max (Math .min (motionEffectEnd , 99 ), 0 );
97
+ } else if (attr == R .styleable .MotionEffect_motionEffect_translationX ) {
98
+ motionEffectTranslationX = a .getDimensionPixelOffset (attr , motionEffectTranslationX );
99
+ } else if (attr == R .styleable .MotionEffect_motionEffect_translationY ) {
100
+ motionEffectTranslationY = a .getDimensionPixelOffset (attr , motionEffectTranslationY );
101
+ } else if (attr == R .styleable .MotionEffect_motionEffect_alpha ) {
102
+ motionEffectAlpha = a .getFloat (attr , motionEffectAlpha );
103
+ } else if (attr == R .styleable .MotionEffect_motionEffect_move ) {
104
104
fadeMove = a .getInt (attr , fadeMove );
105
- } else if (attr == R .styleable .MotionEffect_fadeMove_strict ) {
106
- fadeMoveStrict = a .getBoolean (attr , fadeMoveStrict );
107
- } else if (attr == R .styleable .MotionEffect_fadeMove_viewTransition ) {
105
+ } else if (attr == R .styleable .MotionEffect_motionEffect_strict ) {
106
+ motionEffectStrictMove = a .getBoolean (attr , motionEffectStrictMove );
107
+ } else if (attr == R .styleable .MotionEffect_motionEffect_viewTransition ) {
108
108
viewTransitionId = a .getResourceId (attr , viewTransitionId );
109
109
}
110
110
}
111
- if (fadeStart == fadeEnd ) {
112
- if (fadeStart > 0 ) {
113
- fadeStart --;
111
+ if (motionEffectStart == motionEffectEnd ) {
112
+ if (motionEffectStart > 0 ) {
113
+ motionEffectStart --;
114
114
} else {
115
- fadeEnd ++;
115
+ motionEffectEnd ++;
116
116
}
117
117
}
118
118
a .recycle ();
@@ -137,41 +137,41 @@ public void onPreSetup(MotionLayout motionLayout, HashMap<View, MotionController
137
137
138
138
KeyAttributes alpha1 = new KeyAttributes ();
139
139
KeyAttributes alpha2 = new KeyAttributes ();
140
- alpha1 .setValue (Key .ALPHA , fadeAlpha );
141
- alpha2 .setValue (Key .ALPHA , fadeAlpha );
142
- alpha1 .setFramePosition (fadeStart );
143
- alpha2 .setFramePosition (fadeEnd );
140
+ alpha1 .setValue (Key .ALPHA , motionEffectAlpha );
141
+ alpha2 .setValue (Key .ALPHA , motionEffectAlpha );
142
+ alpha1 .setFramePosition (motionEffectStart );
143
+ alpha2 .setFramePosition (motionEffectEnd );
144
144
KeyPosition stick1 = new KeyPosition ();
145
- stick1 .setFramePosition (fadeStart );
145
+ stick1 .setFramePosition (motionEffectStart );
146
146
stick1 .setType (KeyPosition .TYPE_CARTESIAN );
147
147
stick1 .setValue (KeyPosition .PERCENT_X , 0 );
148
148
stick1 .setValue (KeyPosition .PERCENT_Y , 0 );
149
149
KeyPosition stick2 = new KeyPosition ();
150
- stick2 .setFramePosition (fadeEnd );
150
+ stick2 .setFramePosition (motionEffectEnd );
151
151
stick2 .setType (KeyPosition .TYPE_CARTESIAN );
152
152
stick2 .setValue (KeyPosition .PERCENT_X , 1 );
153
153
stick2 .setValue (KeyPosition .PERCENT_Y , 1 );
154
154
155
155
KeyAttributes translationX1 = null ;
156
156
KeyAttributes translationX2 = null ;
157
- if (fadeTranslationX > 0 ) {
157
+ if (motionEffectTranslationX > 0 ) {
158
158
translationX1 = new KeyAttributes ();
159
159
translationX2 = new KeyAttributes ();
160
- translationX1 .setValue (Key .TRANSLATION_X , fadeTranslationX );
161
- translationX1 .setFramePosition (fadeEnd );
160
+ translationX1 .setValue (Key .TRANSLATION_X , motionEffectTranslationX );
161
+ translationX1 .setFramePosition (motionEffectEnd );
162
162
translationX2 .setValue (Key .TRANSLATION_X , 0 );
163
- translationX2 .setFramePosition (fadeEnd - 1 );
163
+ translationX2 .setFramePosition (motionEffectEnd - 1 );
164
164
}
165
165
166
166
KeyAttributes translationY1 = null ;
167
167
KeyAttributes translationY2 = null ;
168
- if (fadeTranslationY > 0 ) {
168
+ if (motionEffectTranslationY > 0 ) {
169
169
translationY1 = new KeyAttributes ();
170
170
translationY2 = new KeyAttributes ();
171
- translationY1 .setValue (Key .TRANSLATION_Y , fadeTranslationY );
172
- translationY1 .setFramePosition (fadeEnd );
171
+ translationY1 .setValue (Key .TRANSLATION_Y , motionEffectTranslationY );
172
+ translationY1 .setFramePosition (motionEffectEnd );
173
173
translationY2 .setValue (Key .TRANSLATION_Y , 0 );
174
- translationY2 .setFramePosition (fadeEnd - 1 );
174
+ translationY2 .setFramePosition (motionEffectEnd - 1 );
175
175
}
176
176
177
177
int moveDirection = fadeMove ;
@@ -215,19 +215,19 @@ public void onPreSetup(MotionLayout motionLayout, HashMap<View, MotionController
215
215
// if move strict is true, also include views that are moving in diagonal, even
216
216
// if they aren't moving in the opposite direction.
217
217
if (moveDirection == NORTH ) {
218
- if (y > 0 && (!fadeMoveStrict || x == 0 )) {
218
+ if (y > 0 && (!motionEffectStrictMove || x == 0 )) {
219
219
apply = false ;
220
220
}
221
221
} else if (moveDirection == SOUTH ) {
222
- if (y < 0 && (!fadeMoveStrict || x == 0 )) {
222
+ if (y < 0 && (!motionEffectStrictMove || x == 0 )) {
223
223
apply = false ;
224
224
}
225
225
} else if (moveDirection == EAST ) {
226
- if (x < 0 && (!fadeMoveStrict || y == 0 )) {
226
+ if (x < 0 && (!motionEffectStrictMove || y == 0 )) {
227
227
apply = false ;
228
228
}
229
229
} else if (moveDirection == WEST ) {
230
- if (x > 0 && (!fadeMoveStrict || y == 0 )) {
230
+ if (x > 0 && (!motionEffectStrictMove || y == 0 )) {
231
231
apply = false ;
232
232
}
233
233
}
@@ -238,11 +238,11 @@ public void onPreSetup(MotionLayout motionLayout, HashMap<View, MotionController
238
238
mc .addKey (alpha2 );
239
239
mc .addKey (stick1 );
240
240
mc .addKey (stick2 );
241
- if (fadeTranslationX > 0 ) {
241
+ if (motionEffectTranslationX > 0 ) {
242
242
mc .addKey (translationX1 );
243
243
mc .addKey (translationX2 );
244
244
}
245
- if (fadeTranslationY > 0 ) {
245
+ if (motionEffectTranslationY > 0 ) {
246
246
mc .addKey (translationY1 );
247
247
mc .addKey (translationY2 );
248
248
}
0 commit comments