use of android.graphics.drawable.TransitionDrawable in project Ushahidi_Android by ushahidi.
the class ImageSwitchWorker method setImageBitmap.
/**
* Called when the processing is complete and the final bitmap should be set
* on the ImageSwitcher.
*
* @param ImageSwitcher
* @param bitmap
*/
@SuppressWarnings("deprecation")
private void setImageBitmap(ImageSwitcher imageSwitcher, Bitmap bitmap) {
if (fadeIn) {
// Transition drawable with a transparent drwabale and the final
// bitmap
final TransitionDrawable td = new TransitionDrawable(new Drawable[] { new ColorDrawable(android.R.color.transparent), new BitmapDrawable(context.getResources(), bitmap) });
// Set background to loading bitmap
imageSwitcher.setBackgroundDrawable(new BitmapDrawable(context.getResources(), loadingBitmap));
imageSwitcher.setImageDrawable(td);
td.startTransition(FADE_IN_TIME);
} else {
imageSwitcher.setImageDrawable(new BitmapDrawable(context.getResources(), bitmap));
}
}
use of android.graphics.drawable.TransitionDrawable in project Ushahidi_Android by ushahidi.
the class ImageViewWorker method setImageBitmap.
/**
* Called when the processing is complete and the final bitmap should be set
* on the ImageView.
*
* @param imageView
* @param bitmap
*/
@SuppressWarnings("deprecation")
private void setImageBitmap(ImageView imageView, Bitmap bitmap) {
if (fadeIn) {
// Transition drawable with a transparent drwabale and the final
// bitmap
final TransitionDrawable td = new TransitionDrawable(new Drawable[] { new ColorDrawable(android.R.color.transparent), new BitmapDrawable(context.getResources(), bitmap) });
// Set background to loading bitmap
imageView.setBackgroundDrawable(new BitmapDrawable(context.getResources(), loadingBitmap));
imageView.setImageDrawable(td);
td.startTransition(FADE_IN_TIME);
} else {
imageView.setImageBitmap(bitmap);
}
}
use of android.graphics.drawable.TransitionDrawable in project AndroidChromium by JackyAndroid.
the class ToolbarPhone method onUrlFocusChange.
@Override
public void onUrlFocusChange(final boolean hasFocus) {
super.onUrlFocusChange(hasFocus);
triggerUrlFocusAnimation(hasFocus);
TransitionDrawable shadowDrawable = (TransitionDrawable) mToolbarShadow.getDrawable();
if (hasFocus) {
dismissTabSwitcherCallout();
shadowDrawable.startTransition(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS);
} else {
shadowDrawable.reverseTransition(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS);
}
}
use of android.graphics.drawable.TransitionDrawable in project AndroidChromium by JackyAndroid.
the class SnippetArticleViewHolder method fadeThumbnailIn.
private void fadeThumbnailIn(SnippetArticle snippet, Bitmap thumbnail) {
mImageCallback = null;
// Nothing to do, we keep the placeholder.
if (thumbnail == null)
return;
// We need to crop and scale the downloaded bitmap, as the ImageView we set it on won't be
// able to do so when using a TransitionDrawable (as opposed to the straight bitmap).
// That's a limitation of TransitionDrawable, which doesn't handle layers of varying sizes.
Resources res = mThumbnailView.getResources();
int targetSize = res.getDimensionPixelSize(R.dimen.snippets_thumbnail_size);
Bitmap scaledThumbnail = ThumbnailUtils.extractThumbnail(thumbnail, targetSize, targetSize, ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
// Store the bitmap to skip the download task next time we display this snippet.
snippet.setThumbnailBitmap(scaledThumbnail);
// Cross-fade between the placeholder and the thumbnail.
Drawable[] layers = { mThumbnailView.getDrawable(), new BitmapDrawable(mThumbnailView.getResources(), scaledThumbnail) };
TransitionDrawable transitionDrawable = new TransitionDrawable(layers);
mThumbnailView.setImageDrawable(transitionDrawable);
transitionDrawable.startTransition(FADE_IN_ANIMATION_TIME_MS);
}
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