@@ -36,18 +36,18 @@ public class BorderEffect implements Effect {
3636 private View mTarget ;
3737
3838 public BorderEffect () {
39- mFocusListener .add (focusListener );
39+ mFocusListener .add (focusScaleListener );
4040 mFocusListener .add (focusMoveListener );
41+ mFocusListener .add (focusPlayListener );
4142 }
4243
4344 public interface FocusListener {
4445 public void onFocusChanged (View oldFocus , View newFocus );
4546 }
46-
4747 private List <FocusListener > mFocusListener = new ArrayList <FocusListener >(1 );
48+ private List <Animator .AnimatorListener > mAnimatorListener =new ArrayList <Animator .AnimatorListener >(1 );
4849
49-
50- private FocusListener focusListener = new FocusListener () {
50+ public FocusListener focusScaleListener = new FocusListener () {
5151 @ Override
5252 public void onFocusChanged (View oldFocus , View newFocus ) {
5353 if (mScalable ) {
@@ -56,7 +56,7 @@ public void onFocusChanged(View oldFocus, View newFocus) {
5656 }
5757 }
5858 };
59- public FocusListener focusScaleListener = new FocusListener () {
59+ public FocusListener focusScale2Listener = new FocusListener () {
6060 @ Override
6161 public void onFocusChanged (View oldFocus , View newFocus ) {
6262 ObjectAnimator scaleX = new ObjectAnimator ().ofFloat (newFocus , "scaleX" , 1.0f , mScale );
@@ -72,7 +72,21 @@ public void onFocusChanged(View oldFocus, View newFocus) {
7272 }
7373 }
7474 };
75- private FocusListener focusMoveListener = new FocusListener () {
75+ public FocusListener focusPlayListener =new FocusListener () {
76+ @ Override
77+ public void onFocusChanged (View oldFocus , View newFocus ) {
78+ AnimatorSet animatorSet = new AnimatorSet ();
79+ animatorSet .setInterpolator (new DecelerateInterpolator (1 ));
80+ animatorSet .setDuration (mDurationTraslate );
81+ animatorSet .playTogether (mAnimatorList );
82+ for (Animator .AnimatorListener listener : mAnimatorListener ){
83+ animatorSet .addListener (listener );
84+ }
85+ mAnimatorSet = animatorSet ;
86+ animatorSet .start ();
87+ }
88+ };
89+ public FocusListener focusMoveListener = new FocusListener () {
7690 @ Override
7791 public void onFocusChanged (View oldFocus , View newFocus ) {
7892 if (newFocus == null ) return ;
@@ -98,7 +112,6 @@ public void onFocusChanged(View oldFocus, View newFocus) {
98112
99113 PropertyValuesHolder valuesWithdHolder = PropertyValuesHolder .ofInt ("width" , mTarget .getMeasuredWidth (), newWidth );
100114 PropertyValuesHolder valuesHeightHolder = PropertyValuesHolder .ofInt ("height" , mTarget .getMeasuredHeight (), newHeight );
101-
102115 PropertyValuesHolder valuesXHolder = PropertyValuesHolder .ofInt ("x" , oldXY [0 ], newXY [0 ]);
103116 PropertyValuesHolder valuesYHolder = PropertyValuesHolder .ofInt ("y" , oldXY [1 ], newXY [1 ]);
104117 final ObjectAnimator scaleAnimator = ObjectAnimator .ofPropertyValuesHolder (mTarget , valuesWithdHolder , valuesHeightHolder , valuesYHolder , valuesXHolder );
@@ -125,12 +138,6 @@ public void onAnimationUpdate(ValueAnimator animation) {
125138 });
126139 mAnimatorList .add (scaleAnimator );
127140
128- AnimatorSet animatorSet = new AnimatorSet ();
129- animatorSet .setInterpolator (new DecelerateInterpolator (1 ));
130- animatorSet .setDuration (mDurationTraslate );
131- animatorSet .playTogether (mAnimatorList );
132- mAnimatorSet = animatorSet ;
133- animatorSet .start ();
134141 } catch (Exception ex ) {
135142 ex .printStackTrace ();
136143 }
@@ -146,6 +153,11 @@ public void addOnFocusListener(FocusListener focusListener) {
146153 this .mFocusListener .add (focusListener );
147154 }
148155
156+ public void addAnimatorListener (Animator .AnimatorListener animatorListener ) {
157+ this .mAnimatorListener .add (animatorListener );
158+ }
159+
160+
149161 @ Override
150162 public void onFocusChanged (View target , View oldFocus , View newFocus ) {
151163 try {
@@ -171,7 +183,8 @@ public void onScrollChanged(View target, View attachView) {
171183 if (attachView instanceof AbsListView ) {
172184
173185 } else {
174-
186+ if (mAnimatorSet != null ) ;
187+ mAnimatorSet .end ();
175188 }
176189 }
177190
@@ -203,11 +216,6 @@ public void onAttach(View target, View attachView) {
203216 }
204217
205218
206-
207-
208-
209-
210-
211219 public boolean isScalable () {
212220 return mScalable ;
213221 }
0 commit comments