@@ -57,12 +57,12 @@ public class MotionEffect extends MotionHelper {
5757 public static final int EAST = 2 ;
5858 public static final int WEST = 3 ;
5959
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 ;
6666 private static final int UNSET = -1 ;
6767 private int viewTransitionId = UNSET ;
6868
@@ -88,31 +88,31 @@ private void init(Context context, AttributeSet attrs) {
8888 final int N = a .getIndexCount ();
8989 for (int i = 0 ; i < N ; i ++) {
9090 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 ) {
104104 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 ) {
108108 viewTransitionId = a .getResourceId (attr , viewTransitionId );
109109 }
110110 }
111- if (fadeStart == fadeEnd ) {
112- if (fadeStart > 0 ) {
113- fadeStart --;
111+ if (motionEffectStart == motionEffectEnd ) {
112+ if (motionEffectStart > 0 ) {
113+ motionEffectStart --;
114114 } else {
115- fadeEnd ++;
115+ motionEffectEnd ++;
116116 }
117117 }
118118 a .recycle ();
@@ -137,41 +137,41 @@ public void onPreSetup(MotionLayout motionLayout, HashMap<View, MotionController
137137
138138 KeyAttributes alpha1 = new KeyAttributes ();
139139 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 );
144144 KeyPosition stick1 = new KeyPosition ();
145- stick1 .setFramePosition (fadeStart );
145+ stick1 .setFramePosition (motionEffectStart );
146146 stick1 .setType (KeyPosition .TYPE_CARTESIAN );
147147 stick1 .setValue (KeyPosition .PERCENT_X , 0 );
148148 stick1 .setValue (KeyPosition .PERCENT_Y , 0 );
149149 KeyPosition stick2 = new KeyPosition ();
150- stick2 .setFramePosition (fadeEnd );
150+ stick2 .setFramePosition (motionEffectEnd );
151151 stick2 .setType (KeyPosition .TYPE_CARTESIAN );
152152 stick2 .setValue (KeyPosition .PERCENT_X , 1 );
153153 stick2 .setValue (KeyPosition .PERCENT_Y , 1 );
154154
155155 KeyAttributes translationX1 = null ;
156156 KeyAttributes translationX2 = null ;
157- if (fadeTranslationX > 0 ) {
157+ if (motionEffectTranslationX > 0 ) {
158158 translationX1 = new KeyAttributes ();
159159 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 );
162162 translationX2 .setValue (Key .TRANSLATION_X , 0 );
163- translationX2 .setFramePosition (fadeEnd - 1 );
163+ translationX2 .setFramePosition (motionEffectEnd - 1 );
164164 }
165165
166166 KeyAttributes translationY1 = null ;
167167 KeyAttributes translationY2 = null ;
168- if (fadeTranslationY > 0 ) {
168+ if (motionEffectTranslationY > 0 ) {
169169 translationY1 = new KeyAttributes ();
170170 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 );
173173 translationY2 .setValue (Key .TRANSLATION_Y , 0 );
174- translationY2 .setFramePosition (fadeEnd - 1 );
174+ translationY2 .setFramePosition (motionEffectEnd - 1 );
175175 }
176176
177177 int moveDirection = fadeMove ;
@@ -215,19 +215,19 @@ public void onPreSetup(MotionLayout motionLayout, HashMap<View, MotionController
215215 // if move strict is true, also include views that are moving in diagonal, even
216216 // if they aren't moving in the opposite direction.
217217 if (moveDirection == NORTH ) {
218- if (y > 0 && (!fadeMoveStrict || x == 0 )) {
218+ if (y > 0 && (!motionEffectStrictMove || x == 0 )) {
219219 apply = false ;
220220 }
221221 } else if (moveDirection == SOUTH ) {
222- if (y < 0 && (!fadeMoveStrict || x == 0 )) {
222+ if (y < 0 && (!motionEffectStrictMove || x == 0 )) {
223223 apply = false ;
224224 }
225225 } else if (moveDirection == EAST ) {
226- if (x < 0 && (!fadeMoveStrict || y == 0 )) {
226+ if (x < 0 && (!motionEffectStrictMove || y == 0 )) {
227227 apply = false ;
228228 }
229229 } else if (moveDirection == WEST ) {
230- if (x > 0 && (!fadeMoveStrict || y == 0 )) {
230+ if (x > 0 && (!motionEffectStrictMove || y == 0 )) {
231231 apply = false ;
232232 }
233233 }
@@ -238,11 +238,11 @@ public void onPreSetup(MotionLayout motionLayout, HashMap<View, MotionController
238238 mc .addKey (alpha2 );
239239 mc .addKey (stick1 );
240240 mc .addKey (stick2 );
241- if (fadeTranslationX > 0 ) {
241+ if (motionEffectTranslationX > 0 ) {
242242 mc .addKey (translationX1 );
243243 mc .addKey (translationX2 );
244244 }
245- if (fadeTranslationY > 0 ) {
245+ if (motionEffectTranslationY > 0 ) {
246246 mc .addKey (translationY1 );
247247 mc .addKey (translationY2 );
248248 }
0 commit comments