Example usage for android.graphics.drawable TransitionDrawable startTransition

List of usage examples for android.graphics.drawable TransitionDrawable startTransition

Introduction

In this page you can find the example usage for android.graphics.drawable TransitionDrawable startTransition.

Prototype

public void startTransition(int durationMillis) 

Source Link

Document

Begin the second layer on top of the first layer.

Usage

From source file:com.ruoogle.base.imgload.ImageWorker.java

/**
 * Called when the processing is complete and the final bitmap should be set on the ImageView.
 *
 * @param imageView/*w  w w . j av a 2  s. c  o  m*/
 * @param bitmap
 */
private void setImageBitmap(ImageView imageView, Drawable aDrawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drwabale and the final bitmap
        final TransitionDrawable td = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(android.R.color.transparent), aDrawable });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));
        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {

        /*aDrawable??*/
        if (aDrawable == null) {
            imageView.setImageBitmap(mLoadingBitmap);
        } else {
            imageView.setImageDrawable(aDrawable);
        }
    }
}

From source file:com.androidpi.bricks.gallery.lru.cache.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be set on the ImageView.
 *
 * @param imageView//w  ww .j a v  a 2 s. co  m
 * @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(imageView.getResources().getColor(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);
    }
}

From source file:com.yuedu.image.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be
 * set on the ImageView./*from   www .j  a v a 2 s .c o  m*/
 * 
 * @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);
    }
}

From source file:com.example.photoutil.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView.//from w  w  w. j a  v  a 2 s  .co  m
 *
 * @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
        // *****Bo doan nay*****
        //imageView.setBackgroundDrawable(
        //       new BitmapDrawable(mResources, mLoadingBitmap));

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

From source file:gr.unfold.android.tsibato.images.ImageWorker.java

@TargetApi(16)
@SuppressWarnings("deprecation")
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
        if (Utils.hasJellyBean()) {
            imageView.setBackground(new BitmapDrawable(mResources, mLoadingBitmap));
        } else {//from w  w w. j  a  v a  2 s.co  m
            imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));
        }

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

From source file:com.example.image.ImageWorker.java

/**
 * Called when the processing is complete and the final bitmap should be set on the ImageView.
 *
 * @param imageView//from  w  w  w  . jav  a  2s. c  om
 * @param bitmap
 */
private void setImageBitmap(final ImageView imageView, final Bitmap bitmap) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drwabale and the final bitmap
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                mLoadingBitmap != null ? getLoadingDrawable() : new ColorDrawable(android.R.color.transparent),
                new BitmapDrawable(mResources, bitmap) });
        // Set background to loading bitmap
        //imageView.setBackgroundDrawable(getLoadingDrawable());

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
        imageView.postDelayed(new Runnable() {

            @Override
            public void run() {
                imageView.setImageBitmap(bitmap);
            }

        }, FADE_IN_TIME);
    } else {
        imageView.setImageBitmap(bitmap);
    }
}

From source file:com.abcs.sociax.gimgutil.ImageWorker.java

/**
 * Called when the processing is complete and the final bitmap should be set
 * on the ImageView./*from   w  w w .j a  v a 2s  .  c  o m*/
 * 
 * @param imageView
 * @param bitmap
 */
private void setImageBitmap(ImageView imageView, Bitmap bitmap) {
    if (mFadeInBitmap) {
        // 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(mResources, bitmap) });
        // Set background to loading bitmap
        imageView.setImageDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

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

From source file:com.xxjwd.chat.util.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView./*from  w  w  w  .  ja  va2 s . com*/
 *
 * @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);
    }
}

From source file:org.mrchen.commlib.bitmapfun.ImageWorker.java

/**
 * Called when the processing is complete and the final bitmap should be set
 * on the ImageView. ?Bitmap?ImageView/*from   w  w w  . j a  v  a2 s. c o m*/
 * 
 * @param imageView
 * @param bitmap
 */
private void setImageBitmap(ImageView imageView, Bitmap bitmap) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drwabale and the final
        // bitmap
        // Drawablenew ColorDrawable(android.R.color.transparent)
        // -> new BitmapDrawable(mResources, bitmap)
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                new ColorDrawable(android.R.color.transparent), new BitmapDrawable(mResources, bitmap) });
        // Set background to loading bitmap TODO ??
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

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

From source file:com.androguide.apkreator.MainActivity.java

/**
 * Method to set the color scheme according to the color defined in
 * config.xml//from   w  w w.  j a  v a  2  s.  c  o m
 *
 * @param newColor : the color retrieved from config.xml
 */
public void changeColor(int newColor) {
    tabs.setIndicatorColor(newColor);
    Drawable colorDrawable = new ColorDrawable(newColor);
    Drawable bottomDrawable = getResources().getDrawable(R.drawable.actionbar_bottom);
    LayerDrawable ld = new LayerDrawable(new Drawable[] { colorDrawable, bottomDrawable });

    if (oldBackground == null) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)
            ld.setCallback(drawableCallback);
        else
            getSupportActionBar().setBackgroundDrawable(ld);

    } else {
        TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, ld });
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)
            td.setCallback(drawableCallback);
        else
            getSupportActionBar().setBackgroundDrawable(td);
        td.startTransition(200);
    }
    oldBackground = ld;
    currentColor = newColor;

    /**
     * The following is a work-around to avoid NPE, see the following
     * thread:
     *
     * @see http://stackoverflow.com/questions/11002691/actionbar-
     *      setbackgrounddrawable-nulling-background-from-thread-handler
     */
    try {
        getSupportActionBar().setDisplayShowTitleEnabled(false);
        getSupportActionBar().setDisplayShowTitleEnabled(true);
    } catch (NullPointerException e) {
        Log.e("NPE", e.getMessage());
    }

}