java类android.graphics.drawable.TransitionDrawable的实例源码

DocumentsActivity.java 文件源码 项目:simple-share-android 阅读 31 收藏 0 点赞 0 评论 0
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();
    }
SettingsActivity.java 文件源码 项目:simple-share-android 阅读 49 收藏 0 点赞 0 评论 0
public void changeActionBarColor(int newColor) {

        int color = newColor != 0 ? newColor : 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;
    }
AboutDevelopers.java 文件源码 项目:FindX 阅读 23 收藏 0 点赞 0 评论 0
void open()
{
    ColorDrawable[] color = {new ColorDrawable(Color.parseColor("#00ffffff")), new ColorDrawable(Color.parseColor("#CC000000"))};
    TransitionDrawable trans = new TransitionDrawable(color);
    //This will work also on old devices. The latest API says you have to use setBackground instead.
    rel.setBackgroundDrawable(trans);
    trans.startTransition(100);


    //rel.setBackgroundColor(Color.parseColor("#CC000000"));
    web.setVisibility(View.VISIBLE);
    fb.setVisibility(View.VISIBLE);
    email.setVisibility(View.VISIBLE);
    webtxt.setVisibility(View.VISIBLE);
    fbtxt.setVisibility(View.VISIBLE);
    emailtxt.setVisibility(View.VISIBLE);

}
BitmapPalette.java 文件源码 项目:MusicX-music-player 阅读 24 收藏 0 点赞 0 评论 0
private void crossfadeTargetBackground(PaletteTarget target, Pair<View, Integer> t, int newColor) {

        final Drawable oldColor = t.first.getBackground();
        final Drawable[] drawables = new Drawable[2];

        drawables[0] = oldColor != null ? oldColor : new ColorDrawable(t.first.getSolidColor());
        drawables[1] = new ColorDrawable(newColor);
        TransitionDrawable transitionDrawable = new TransitionDrawable(drawables);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            t.first.setBackground(transitionDrawable);
        } else {
            //noinspection deprecation
            t.first.setBackgroundDrawable(transitionDrawable);
        }
        transitionDrawable.startTransition(target.targetCrossfadeSpeed);
    }
RImageView.java 文件源码 项目:RLibrary 阅读 20 收藏 0 点赞 0 评论 0
public void setImageBitmap(@Nullable final Drawable fromDrawable, @Nullable final Bitmap toBitmap) {
    final int width = getMeasuredWidth();
    final int height = getMeasuredHeight();

    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            final TransitionDrawable td = new TransitionDrawable(new Drawable[]{
                    fromDrawable, new BitmapDrawable(getResources(),
                    getScaleType() == ScaleType.CENTER_CROP ?
                            centerCrop(getResources(), toBitmap, width, height) :
                            toBitmap)});
            RImageView.super.setImageDrawable(td);
            td.startTransition(300);
        }
    };

    if (width == 0 || height == 0) {
        post(runnable);
    } else {
        runnable.run();
    }
}
PLA_AbsListView.java 文件源码 项目:Swap 阅读 33 收藏 0 点赞 0 评论 0
public void run() {
    if (mTouchMode == TOUCH_MODE_DOWN) {
        mTouchMode = TOUCH_MODE_TAP;
        final View child = getChildAt(mMotionPosition - mFirstPosition);
        if (child != null && !child.hasFocusable()) {
            mLayoutMode = LAYOUT_NORMAL;

            if (!mDataChanged) {
                layoutChildren();
                child.setPressed(true);
                positionSelector(child);
                setPressed(true);

                final int longPressTimeout = ViewConfiguration.getLongPressTimeout();
                final boolean longClickable = isLongClickable();

                if (mSelector != null) {
                    Drawable d = mSelector.getCurrent();
                    if (d != null && d instanceof TransitionDrawable) {
                        if (longClickable) {
                            ((TransitionDrawable) d).startTransition(longPressTimeout);
                        } else {
                            ((TransitionDrawable) d).resetTransition();
                        }
                    }
                }

                if (longClickable) {
                } else {
                    mTouchMode = TOUCH_MODE_DONE_WAITING;
                }
            } else {
                mTouchMode = TOUCH_MODE_DONE_WAITING;
            }
        }
    }
}
ImageWorker.java 文件源码 项目:APK 阅读 30 收藏 0 点赞 0 评论 0
/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView.
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td =
                new TransitionDrawable(new Drawable[] {
                        new ColorDrawable(android.R.color.transparent),
                        drawable
                });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(
                new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}
GameItemView.java 文件源码 项目:recycler-view-optimization 阅读 21 收藏 0 点赞 0 评论 0
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
    final Drawable resultDrawable;

    if (from == Picasso.LoadedFrom.MEMORY) {
        resultDrawable = new BitmapDrawable(getResources(), bitmap);
    } else {
        TransitionDrawable transitionDrawable = new TransitionDrawable(
                new Drawable[]{iconDrawable, new BitmapDrawable(getResources(), bitmap)});
        transitionDrawable.startTransition(300);

        resultDrawable = transitionDrawable;
    }

    resultDrawable.setCallback(this);
    resultDrawable.setBounds(iconDrawable.getBounds());

    iconDrawable = resultDrawable;
    invalidate();
}
DrawableFadeDisplayer.java 文件源码 项目:Gank-Meizi 阅读 20 收藏 0 点赞 0 评论 0
/**
 * @param bitmap
 * @param imageView
 */
public void display(Bitmap bitmap, ImageView imageView) {
    Drawable oldDrawable = imageView.getDrawable();
    Drawable oldBitmapDrawable = null;
    //如果原先的imageView没drawable就创建一个透明的drawable
    if (null == oldDrawable) {
        oldBitmapDrawable = new ColorDrawable(Color.TRANSPARENT);
    }
    //如果原先就是TransitionDrawable,就获得第二张图片
    else if (oldDrawable instanceof TransitionDrawable) {
        oldBitmapDrawable = ((TransitionDrawable) oldDrawable).getDrawable(1);
    } else {
        oldBitmapDrawable = oldDrawable;
    }
    TransitionDrawable td = new TransitionDrawable(new Drawable[]{
            oldBitmapDrawable,
            new BitmapDrawable(Resources.getSystem(), bitmap)
    });
    imageView.setImageDrawable(td);
    td.startTransition(durationMillis);
}
ImageWorker.java 文件源码 项目:TAG 阅读 29 收藏 0 点赞 0 评论 0
/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView.
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td =
                new TransitionDrawable(new Drawable[] {
                        new ColorDrawable(android.R.color.transparent),
                        drawable
                });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(
                new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号