use of android.graphics.drawable.TransitionDrawable in project glide by bumptech.
the class GifDrawableTest method onFrameReady_whenAttachedtoDrawableCallbackWithViewCallbackParent_doesNotStop.
@Test
public void onFrameReady_whenAttachedtoDrawableCallbackWithViewCallbackParent_doesNotStop() {
TransitionDrawable topLevel = new TransitionDrawable(new Drawable[] { drawable });
drawable.setCallback(topLevel);
topLevel.setCallback(new View(context));
drawable.start();
drawable.onFrameReady();
assertThat(drawable.isRunning()).isTrue();
}
use of android.graphics.drawable.TransitionDrawable in project ultrasonic by ultrasonic.
the class ImageLoader method setImageBitmap.
private void setImageBitmap(View view, MusicDirectory.Entry entry, Bitmap bitmap, boolean crossFade) {
if (view instanceof ImageView) {
ImageView imageView = (ImageView) view;
MusicDirectory.Entry tagEntry = (MusicDirectory.Entry) view.getTag();
// Only apply image to the view if the view is intended for this entry
if (entry != null && tagEntry != null && !entry.equals(tagEntry)) {
Log.i(TAG, "View is no longer valid, not setting ImageBitmap");
return;
}
if (crossFade) {
Drawable existingDrawable = imageView.getDrawable();
Drawable newDrawable = Util.createDrawableFromBitmap(this.context, bitmap);
if (existingDrawable == null) {
Bitmap emptyImage = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
existingDrawable = new BitmapDrawable(context.getResources(), emptyImage);
}
Drawable[] layers = new Drawable[] { existingDrawable, newDrawable };
TransitionDrawable transitionDrawable = new TransitionDrawable(layers);
imageView.setImageDrawable(transitionDrawable);
transitionDrawable.startTransition(250);
} else {
imageView.setImageBitmap(bitmap);
}
}
}
use of android.graphics.drawable.TransitionDrawable in project ButterRemote-Android by se-bastiaan.
the class ActionBarBackground method fadeBackground.
/**
* Fade the ActionBar background from oldDrawable to newDrawable
* @param oldDrawable Drawable to be faded from
* @param newDrawable Drawable to be faded to
* @return Instance of this class
*/
private ActionBarBackground fadeBackground(Drawable oldDrawable, Drawable newDrawable) {
if (oldDrawable == null) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
newDrawable.setCallback(drawableCallback);
} else {
mActionBar.setBackgroundDrawable(newDrawable);
}
} else {
TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldDrawable, newDrawable });
td.setCrossFadeEnabled(true);
// https://github.com/android/platform_frameworks_base/commit/a7cc06d82e45918c37429a59b14545c6a57db4e4
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
td.setCallback(drawableCallback);
} else {
int paddingTop = mToolbar.getPaddingTop();
mActionBar.setBackgroundDrawable(td);
// fix for fitSystemWindows
mToolbar.setPadding(0, paddingTop, 0, 0);
}
td.startTransition(500);
}
mOldBackground = newDrawable;
return this;
}
use of android.graphics.drawable.TransitionDrawable in project KeepScore by nolanlawson.
the class PlayerView method makeBadgeVisible.
private void makeBadgeVisible() {
synchronized (lock) {
// show the badge, canceling the "fade out" animation if necessary
TransitionDrawable transitionDrawable = (TransitionDrawable) badgeLinearLayout.getBackground();
transitionDrawable.resetTransition();
log.d("reset transition");
if (badgeTextView.getAnimation() != null) {
log.d("cleared animation");
badgeTextView.clearAnimation();
animationWasCanceled.set(true);
}
badgeTextView.setVisibility(View.VISIBLE);
badgeLinearLayout.setVisibility(View.VISIBLE);
}
}
use of android.graphics.drawable.TransitionDrawable 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();
}
}
}
Aggregations