Search in sources :

Example 71 with TransitionDrawable

use of android.graphics.drawable.TransitionDrawable in project firefox-tv by mozilla-mobile.

the class TransitionDrawableGroupTest method testStartIsCalledOnAllItems.

@Test
public void testStartIsCalledOnAllItems() {
    final TransitionDrawable transitionDrawable1 = mock(TransitionDrawable.class);
    final TransitionDrawable transitionDrawable2 = mock(TransitionDrawable.class);
    final TransitionDrawableGroup group = new TransitionDrawableGroup(transitionDrawable1, transitionDrawable2);
    group.startTransition(2500);
    verify(transitionDrawable1).startTransition(2500);
    verify(transitionDrawable2).startTransition(2500);
}
Also used : TransitionDrawable(android.graphics.drawable.TransitionDrawable) Test(org.junit.Test)

Example 72 with TransitionDrawable

use of android.graphics.drawable.TransitionDrawable in project remusic by aa112901.

the class PlayingActivity method setDrawable.

private void setDrawable(Drawable result) {
    if (result != null) {
        if (mBackAlbum.getDrawable() != null) {
            final TransitionDrawable td = new TransitionDrawable(new Drawable[] { mBackAlbum.getDrawable(), result });
            mBackAlbum.setImageDrawable(td);
            // 去除过度绘制
            td.setCrossFadeEnabled(true);
            td.startTransition(200);
        } else {
            mBackAlbum.setImageDrawable(result);
        }
    }
}
Also used : TransitionDrawable(android.graphics.drawable.TransitionDrawable)

Example 73 with TransitionDrawable

use of android.graphics.drawable.TransitionDrawable in project AnExplorer by 1hakr.

the class DocumentsActivity method changeActionBarColor.

private void changeActionBarColor() {
    int color = SettingsActivity.getPrimaryColor(this);
    Drawable colorDrawable = new ColorDrawable(color);
    if (oldBackground == null) {
        getSupportActionBar().setBackgroundDrawable(colorDrawable);
    } else {
        TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, colorDrawable });
        getSupportActionBar().setBackgroundDrawable(td);
        td.startTransition(200);
    }
    oldBackground = colorDrawable;
    setUpStatusBar();
}
Also used : TransitionDrawable(android.graphics.drawable.TransitionDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) TransitionDrawable(android.graphics.drawable.TransitionDrawable)

Example 74 with TransitionDrawable

use of android.graphics.drawable.TransitionDrawable in project android_packages_apps_Snap by LineageOS.

the class RotateImageView method setBitmap.

public void setBitmap(Bitmap bitmap) {
    // non-null.
    if (bitmap == null) {
        mThumb = null;
        mThumbs = null;
        setImageDrawable(null);
        setVisibility(GONE);
        return;
    }
    LayoutParams param = getLayoutParams();
    final int miniThumbWidth = param.width - getPaddingLeft() - getPaddingRight();
    final int miniThumbHeight = param.height - getPaddingTop() - getPaddingBottom();
    mThumb = ThumbnailUtils.extractThumbnail(bitmap, miniThumbWidth, miniThumbHeight);
    Drawable drawable;
    if (mThumbs == null || !mEnableAnimation) {
        mThumbs = new Drawable[2];
        mThumbs[1] = new BitmapDrawable(getContext().getResources(), mThumb);
        setImageDrawable(mThumbs[1]);
    } else {
        mThumbs[0] = mThumbs[1];
        mThumbs[1] = new BitmapDrawable(getContext().getResources(), mThumb);
        mThumbTransition = new TransitionDrawable(mThumbs);
        setImageDrawable(mThumbTransition);
        mThumbTransition.startTransition(500);
    }
    setVisibility(VISIBLE);
}
Also used : TransitionDrawable(android.graphics.drawable.TransitionDrawable) LayoutParams(android.view.ViewGroup.LayoutParams) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Drawable(android.graphics.drawable.Drawable) TransitionDrawable(android.graphics.drawable.TransitionDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable)

Example 75 with TransitionDrawable

use of android.graphics.drawable.TransitionDrawable in project Rocket by mozilla-tw.

the class DrawableCrossFadeTransition method transition.

/**
 * Animates from the previous drawable to the current drawable in one of two ways.
 *
 * <ol> <li>Using the default animation provided in the constructor if the previous drawable is
 * null</li> <li>Using the cross fade animation with the duration provided in the constructor if
 * the previous drawable is non null</li> </ol>
 *
 * @param current {@inheritDoc}
 * @param adapter {@inheritDoc}
 * @return {@inheritDoc}
 */
@Override
public boolean transition(Drawable current, ViewAdapter adapter) {
    Drawable previous = adapter.getCurrentDrawable();
    if (previous == null) {
        previous = new ColorDrawable(Color.TRANSPARENT);
    }
    TransitionDrawable transitionDrawable = new TransitionDrawable(new Drawable[] { previous, current });
    transitionDrawable.setCrossFadeEnabled(isCrossFadeEnabled);
    transitionDrawable.startTransition(duration);
    adapter.setDrawable(transitionDrawable);
    return true;
}
Also used : TransitionDrawable(android.graphics.drawable.TransitionDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) TransitionDrawable(android.graphics.drawable.TransitionDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable)

Aggregations

TransitionDrawable (android.graphics.drawable.TransitionDrawable)96 Drawable (android.graphics.drawable.Drawable)61 ColorDrawable (android.graphics.drawable.ColorDrawable)35 BitmapDrawable (android.graphics.drawable.BitmapDrawable)31 View (android.view.View)28 VelocityTracker (android.view.VelocityTracker)11 ImageView (android.widget.ImageView)10 Rect (android.graphics.Rect)9 Handler (android.os.Handler)8 Test (org.junit.Test)6 Bitmap (android.graphics.Bitmap)5 LayerDrawable (android.graphics.drawable.LayerDrawable)5 GradientDrawable (android.graphics.drawable.GradientDrawable)3 RippleDrawable (android.graphics.drawable.RippleDrawable)3 SuppressLint (android.annotation.SuppressLint)2 Intent (android.content.Intent)2 ColorStateList (android.content.res.ColorStateList)2 Resources (android.content.res.Resources)2 ContentObserver (android.database.ContentObserver)2 Canvas (android.graphics.Canvas)2