Created
June 9, 2014 17:39
-
-
Save nqbao/957b46269f71f57433cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (current != null) { | |
Log.i("DEBUG", "top before: " + mProfileView.getTop()); | |
current.cancel(); | |
Log.i("DEBUG", "top after: " + mProfileView.getTop()); | |
current = null; | |
} | |
TranslateAnimation anim; | |
if (isTop) { | |
anim = new TranslateAnimation(0, 0, 0, -mProfileView.getTop()); | |
} | |
else { | |
anim = new TranslateAnimation(0, 0, mProfileView.getTop(), -mProfileView.getHeight()); | |
} | |
current = anim; | |
anim.setDuration(500); | |
//anim.setFillAfter(true); | |
//anim.setFillBefore(true); | |
//anim.setFillEnabled(true); | |
anim.setAnimationListener(new AnimationListener() { | |
@Override | |
public void onAnimationStart(Animation arg0) { | |
// TODO Auto-generated method stub | |
} | |
@Override | |
public void onAnimationRepeat(Animation arg0) { | |
// TODO Auto-generated method stub | |
} | |
@Override | |
public void onAnimationEnd(Animation arg0) { | |
Log.i("DEBUG", "is end " + current.hasEnded()); | |
Transformation trans = new Transformation(); | |
// startTime + duration = end of animation | |
long endTime = AnimationUtils.currentAnimationTimeMillis(); | |
current.getTransformation(endTime, trans); | |
float[] values = new float[9]; | |
trans.getMatrix().getValues(values); | |
mProfileView.setTop(mProfileView.getTop() + (int) values[Matrix.MTRANS_Y]); | |
Log.i("DEBUG", "set top: " + mProfileView.getTop()); | |
} | |
}); | |
anim.setInterpolator(AnimationUtils.loadInterpolator(this, android.R.anim.accelerate_interpolator)); | |
mProfileView.startAnimation(anim); | |
isTop = !isTop; | |
if (1 != 0) return; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment