use of android.view.animation.Animation.AnimationListener in project Fairphone by Kwamecorp.
the class PeaceOfMindActivity method scrollEnded.
@Override
public synchronized void scrollEnded(float percentage) {
if (mTotalTimeText.getVisibility() == View.VISIBLE) {
Animation fadeOut = AnimationUtils.loadAnimation(this, R.anim.fade_out_fast);
mTotalTimeText.startAnimation(fadeOut);
fadeOut.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
mTotalTimeText.setVisibility(View.INVISIBLE);
updateScreenTexts();
}
});
}
long targetTime = roundToInterval((long) (percentage * PeaceOfMindStats.MAX_TIME));
Intent intent = new Intent(getApplicationContext(), PeaceOfMindBroadCastReceiver.class);
intent.setAction(PeaceOfMindActivity.UPDATE_PEACE_OF_MIND);
intent.putExtra(PeaceOfMindActivity.BROADCAST_TARGET_PEACE_OF_MIND, targetTime);
FlurryAgent.logEvent(FlurryHelper.PEACE_OF_MIND_SET_TIME, FlurryHelper.getInstance().setFlurryParams("Target Time", "" + targetTime, true));
sendBroadcast(intent);
}
use of android.view.animation.Animation.AnimationListener in project Fairphone by Kwamecorp.
the class PeaceOfMindActivity method stopPeaceOfMindVideo.
private void stopPeaceOfMindVideo() {
mVideo.removeCallbacks(null);
if (mVideo.getVisibility() != View.VISIBLE) {
mVideo.setVisibility(View.VISIBLE);
}
Animation fadeOut = AnimationUtils.loadAnimation(this, R.anim.fade_out_fast);
mVideo.startAnimation(fadeOut);
updateBackground(false);
fadeOut.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
mVideo.setVisibility(View.INVISIBLE);
mVideo.stopPlayback();
}
});
}
use of android.view.animation.Animation.AnimationListener in project Fairphone by Kwamecorp.
the class PeaceOfMindActivity method peaceOfMindEnded.
@Override
public synchronized void peaceOfMindEnded() {
try {
mSemaphore.tryAcquire(1, TimeUnit.SECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
}
Animation fadeIn = AnimationUtils.loadAnimation(this, R.anim.fade_in_fast);
mSeekbarBackgroundOff.startAnimation(fadeIn);
Animation fadeOut = AnimationUtils.loadAnimation(this, R.anim.fade_out_fast);
mSeekbarBackgroundOn.startAnimation(fadeOut);
fadeIn.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
mSeekbarBackgroundOff.setVisibility(View.VISIBLE);
mSeekbarBackgroundOn.setVisibility(View.GONE);
updateScreenTexts();
stopPeaceOfMindVideo();
mSemaphore.release();
}
});
updateScreenTexts();
mVerticalSeekBar.setThumb(getResources().getDrawable(R.drawable.seekbar_thumb_off));
mVerticalSeekBar.setThumbOffset(0);
mVerticalSeekBar.setInvertedProgress(0);
updateTextForNewTime(0, 0);
updateTimeTextLabel(0);
mTotalTimeText.setVisibility(View.INVISIBLE);
}
use of android.view.animation.Animation.AnimationListener in project KeepScore by nolanlawson.
the class PlayerView method fadeOutBadge.
private void fadeOutBadge(final Runnable onAnimationComplete) {
synchronized (lock) {
if (// animation is already running, so shouldn't
!animationRunning.get() && // start a new one
lastIncremented.get() != // counter was reset, in which
0 && // to fade
badgeTextView.getVisibility() == View.VISIBLE) {
// animation isn't already showing, and the badge is visible
animationRunning.set(true);
animationWasCanceled.set(false);
badgeLinearLayout.setVisibility(View.VISIBLE);
// show an animation for the badge with the textview and the
// background linearlayout fading out
Animation fadeOutAnimation = AnimationUtils.loadAnimation(context, android.R.anim.fade_out);
fadeOutAnimation.setDuration(ANIMATION_TIME);
fadeOutAnimation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
synchronized (lock) {
log.d("onAnimationEnd, setting visiblity to invisible");
if (!animationWasCanceled.get()) {
badgeTextView.setVisibility(View.INVISIBLE);
}
// necessary to update again to set the history text
// view correctly
onAnimationComplete.run();
animationRunning.set(false);
}
}
});
badgeTextView.setAnimation(fadeOutAnimation);
fadeOutAnimation.start();
TransitionDrawable transitionDrawable = (TransitionDrawable) badgeLinearLayout.getBackground();
transitionDrawable.setCrossFadeEnabled(true);
transitionDrawable.startTransition(ANIMATION_TIME);
} else {
// just don't show it - the animation might already be showing,
// or maybe the badge is
// already invisible
badgeLinearLayout.setVisibility(View.INVISIBLE);
badgeTextView.setVisibility(View.INVISIBLE);
// this ensures that the history text view gets updated
// properly, even if the user
// exits the activity while the animation is in progress (e.g.
// by going to the Settings)
onAnimationComplete.run();
}
}
}
use of android.view.animation.Animation.AnimationListener in project KeepScore by nolanlawson.
the class MainActivity method startShowButtonRowAnimation.
private void startShowButtonRowAnimation() {
Animation animation = AnimationUtils.loadAnimation(this, R.anim.slide_bottom_to_top);
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
// propertly shrink the scroll view
spacerView.setVisibility(View.VISIBLE);
}
});
buttonRow.setAnimation(animation);
buttonRow.setVisibility(View.VISIBLE);
buttonRow.startAnimation(animation);
}
Aggregations