Search in sources :

Example 41 with TransitionDrawable

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));
    }
}
Also used : TransitionDrawable(android.graphics.drawable.TransitionDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable)

Example 42 with TransitionDrawable

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);
    }
}
Also used : TransitionDrawable(android.graphics.drawable.TransitionDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable)

Example 43 with TransitionDrawable

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);
    }
}
Also used : TransitionDrawable(android.graphics.drawable.TransitionDrawable)

Example 44 with TransitionDrawable

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);
}
Also used : Bitmap(android.graphics.Bitmap) TransitionDrawable(android.graphics.drawable.TransitionDrawable) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) TransitionDrawable(android.graphics.drawable.TransitionDrawable) Resources(android.content.res.Resources) BitmapDrawable(android.graphics.drawable.BitmapDrawable) SuppressLint(android.annotation.SuppressLint)

Example 45 with TransitionDrawable

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();
        }
    }
}
Also used : TransitionDrawable(android.graphics.drawable.TransitionDrawable) Animation(android.view.animation.Animation) AnimationListener(android.view.animation.Animation.AnimationListener)

Aggregations

TransitionDrawable (android.graphics.drawable.TransitionDrawable)61 Drawable (android.graphics.drawable.Drawable)45 View (android.view.View)23 ColorDrawable (android.graphics.drawable.ColorDrawable)22 BitmapDrawable (android.graphics.drawable.BitmapDrawable)21 VelocityTracker (android.view.VelocityTracker)10 Rect (android.graphics.Rect)9 Handler (android.os.Handler)8 LayerDrawable (android.graphics.drawable.LayerDrawable)5 RippleDrawable (android.graphics.drawable.RippleDrawable)3 Animation (android.view.animation.Animation)3 ImageView (android.widget.ImageView)3 SuppressLint (android.annotation.SuppressLint)2 Intent (android.content.Intent)2 ColorStateList (android.content.res.ColorStateList)2 ContentObserver (android.database.ContentObserver)2 Bitmap (android.graphics.Bitmap)2 Canvas (android.graphics.Canvas)2 GradientDrawable (android.graphics.drawable.GradientDrawable)2 StateListDrawable (android.graphics.drawable.StateListDrawable)2