Java 类android.graphics.drawable.TransitionDrawable 实例源码

项目:SuperSelector    文件:ImageWorker.java   
/**
 * 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);
    }
}
项目:DisplayingBitmaps    文件:ImageWorker.java   
/**
 * 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);
    }
}
项目:GCSApp    文件:ImageWorker.java   
/**
 * 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(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);
    }
}
项目:Android-Practice    文件:ImageWorker.java   
/**
 * 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);
    }
}
项目:Plus1s    文件:SearchResultActivity.java   
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search_result);

        final TextView search_result_back = (TextView) findViewById(R.id.search_result_back);
        final ListView search_result_list = (ListView) findViewById(R.id.search_result_list);
        img = (ImageView) findViewById(R.id.imageView3);
        ArrayAdapter<String> adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, Item.searchList);
        search_result_list.setAdapter(adapter);
        TransitionDrawable animation = (TransitionDrawable)img.getDrawable();
        animation.startTransition(3000);
        animation.reverseTransition(3000);
//        img.setBackgroundResource(R.drawable.trans);
//        AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();
//        frameAnimation.start();
        search_result_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Item.searchList.clear();
                goToSearch();
            }
        });
    }
项目:GitHub    文件:DrawableCrossFadeTransition.java   
/**
 * 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) {
    TransitionDrawable transitionDrawable =
        new TransitionDrawable(new Drawable[] { previous, current });
    transitionDrawable.setCrossFadeEnabled(isCrossFadeEnabled);
    transitionDrawable.startTransition(duration);
    adapter.setDrawable(transitionDrawable);
    return true;
  } else {
    defaultAnimation.transition(current, adapter);
    return false;
  }
}
项目:Pluto-Android    文件:SimpleDisplayer.java   
private void fadeInDisplay(ImageView imageView,Bitmap bitmap){
    final TransitionDrawable td =
               new TransitionDrawable(new Drawable[] {
                       new ColorDrawable(android.R.color.transparent),
                       new BitmapDrawable(imageView.getResources(), bitmap)
               });
       imageView.setImageDrawable(td);
       td.startTransition(300);
}
项目:android-training-2017    文件:Malevich.java   
private void processImageResult(ImageResult imageResult) {
        if (imageResult != null) {
            ImageRequest request = imageResult.getRequest();
            ImageView imageView = request.target.get();
            if (imageView != null) {
                Object tag = imageView.getTag();
                if (tag != null && tag.equals(request.url)) {
                    TransitionDrawable drawable = new TransitionDrawable(new Drawable[]{EMPTY_DRAWABLE, new BitmapDrawable(imageResult.getBitmap())});
                    imageView.setImageDrawable(drawable);
                    drawable.startTransition(1000);
//                    imageView.setImageBitmap(imageResult.getBitmap());
                }
            }
        }
    }
项目:easyfilemanager    文件:DocumentsActivity.java   
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();
    }
项目:easyfilemanager    文件:SettingsActivity.java   
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;
    }
项目:Hello-Music-droid    文件:QuickControlsFragment.java   
@Override
protected void onPostExecute(Drawable result) {
    if (result != null) {
        if (mBlurredArt.getDrawable() != null) {
            final TransitionDrawable td =
                    new TransitionDrawable(new Drawable[]{
                            mBlurredArt.getDrawable(),
                            result
                    });
            mBlurredArt.setImageDrawable(td);
            td.startTransition(400);

        } else {
            mBlurredArt.setImageDrawable(result);
        }
    }
}
项目:Hello-Music-droid    文件:Timber2.java   
@Override
protected void onPostExecute(Drawable result) {
    if (result != null) {
        if (mBlurredArt.getDrawable() != null) {
            final TransitionDrawable td =
                    new TransitionDrawable(new Drawable[]{
                            mBlurredArt.getDrawable(),
                            result
                    });
            mBlurredArt.setImageDrawable(td);
            td.startTransition(200);

        } else {
            mBlurredArt.setImageDrawable(result);
        }
    }
}
项目:Hello-Music-droid    文件:Timber4.java   
@Override
protected void onPostExecute(Drawable result) {
    if (result != null) {
        if (mBlurredArt.getDrawable() != null) {
            final TransitionDrawable td =
                    new TransitionDrawable(new Drawable[]{
                            mBlurredArt.getDrawable(),
                            result
                    });
            mBlurredArt.setImageDrawable(td);
            td.startTransition(200);

        } else {
            mBlurredArt.setImageDrawable(result);
        }
    }
}
项目:Hello-Music-droid    文件:Timber5.java   
@Override
protected void onPostExecute(Drawable result) {
    if (result != null) {
        if (mBlurredArt.getDrawable() != null) {
            final TransitionDrawable td =
                    new TransitionDrawable(new Drawable[]{
                            mBlurredArt.getDrawable(),
                            result
                    });
            mBlurredArt.setImageDrawable(td);
            td.startTransition(200);

        } else {
            mBlurredArt.setImageDrawable(result);
        }
    }
}
项目:ArtOfAndroid    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    findViewById(R.id.tv_transition).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            TransitionDrawable drawable = (TransitionDrawable) v.getBackground();
            drawable.startTransition(3000);
        }
    });

    ScaleDrawable scaleDrawable = (ScaleDrawable) findViewById(R.id.v_scale).getBackground();
    scaleDrawable.setLevel(10);      //lever默认为0,无法显示。level范围为0~10000。level越大,显示的越大

    ClipDrawable clipDrawable = (ClipDrawable) findViewById(R.id.v_clip).getBackground();
    clipDrawable.setLevel(5000);

    View vCustom = findViewById(R.id.v_custom);
    CustomDrawable customDrawable = new CustomDrawable(getResources().getColor(R.color.colorAccent));
    vCustom.setBackground(customDrawable);
}
项目:chromium-for-android-56-debug-video    文件:SnippetArticleViewHolder.java   
private void fadeThumbnailIn(SnippetArticle snippet, Bitmap thumbnail) {
    mImageCallback = null;
    if (thumbnail == null) return; // Nothing to do, we keep the placeholder.

    // 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);
}
项目:letv    文件:AbsHListView.java   
protected void keyPressed() {
    if (isEnabled() && isClickable()) {
        Drawable selector = this.mSelector;
        Rect selectorRect = this.mSelectorRect;
        if (selector == null) {
            return;
        }
        if ((isFocused() || touchModeDrawsInPressedState()) && !selectorRect.isEmpty()) {
            View v = getChildAt(this.mSelectedPosition - this.mFirstPosition);
            if (v != null) {
                if (!v.hasFocusable()) {
                    v.setPressed(true);
                } else {
                    return;
                }
            }
            setPressed(true);
            boolean longClickable = isLongClickable();
            Drawable d = selector.getCurrent();
            if (d != null && (d instanceof TransitionDrawable)) {
                if (longClickable) {
                    ((TransitionDrawable) d).startTransition(ViewConfiguration.getLongPressTimeout());
                } else {
                    ((TransitionDrawable) d).resetTransition();
                }
            }
            if (longClickable && !this.mDataChanged) {
                if (this.mPendingCheckForKeyLongPress == null) {
                    this.mPendingCheckForKeyLongPress = new CheckForKeyLongPress(this, null);
                }
                this.mPendingCheckForKeyLongPress.rememberWindowAttachCount();
                postDelayed(this.mPendingCheckForKeyLongPress, (long) ViewConfiguration.getLongPressTimeout());
            }
        }
    }
}
项目:NeteaseCloudMusic    文件:PlayerActivity.java   
private void setBlurBackground(Bitmap background) {
        Observable.just(background).map(new Function<Bitmap, TransitionDrawable>() {
            @Override
            public TransitionDrawable apply(Bitmap bitmap) throws Exception {
                return new TransitionDrawable(new Drawable[]{rootView.getBackground(),BlurUtil.createBlurredImageFromBitmap(bitmap, PlayerActivity.this, 20) });
            }
        }).subscribeOn(Schedulers.computation()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<TransitionDrawable>() {
            @Override
            public void accept(TransitionDrawable drawable) throws Exception {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    rootView.setBackground(drawable);
                } else {
                    rootView.setBackgroundDrawable(drawable);
                }
                drawable.startTransition(300);
            }
        });
//        Drawable blurredImageFromBitmap = BlurUtil.createBlurredImageFromBitmap(background, this, 20);

    }
项目:exciting-app    文件:AbsHListView.java   
/**
 * Sets the selector state to "pressed" and posts a CheckForKeyLongPress to
 * see if this is a long press.
 */
protected void keyPressed() {
    if (!isEnabled() || !isClickable()) {
        return;
    }

    Drawable selector = mSelector;
    Rect selectorRect = mSelectorRect;
    if (selector != null && (isFocused() || touchModeDrawsInPressedState())
            && !selectorRect.isEmpty()) {

        final View v = getChildAt(mSelectedPosition - mFirstPosition);

        if (v != null) {
            if (v.hasFocusable())
                return;
            v.setPressed(true);
        }
        setPressed(true);

        final boolean longClickable = isLongClickable();
        Drawable d = selector.getCurrent();
        if (d != null && d instanceof TransitionDrawable) {
            if (longClickable) {
                ((TransitionDrawable) d).startTransition(ViewConfiguration
                        .getLongPressTimeout());
            } else {
                ((TransitionDrawable) d).resetTransition();
            }
        }
        if (longClickable && !mDataChanged) {
            if (mPendingCheckForKeyLongPress == null) {
                mPendingCheckForKeyLongPress = new CheckForKeyLongPress();
            }
            mPendingCheckForKeyLongPress.rememberWindowAttachCount();
            postDelayed(mPendingCheckForKeyLongPress,
                    ViewConfiguration.getLongPressTimeout());
        }
    }
}
项目:aos-Video    文件:BrowserByShow.java   
@Override
protected void setColor(int color) {

    int darkColor = VideoInfoCommonClass.getDarkerColor(color);
    ColorDrawable[] colord = {new ColorDrawable(mLastColor), new ColorDrawable(darkColor)};
    TransitionDrawable trans = new TransitionDrawable(colord);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
        mApplicationFrameLayout.setBackground(trans);
    else
        mApplicationFrameLayout.setBackgroundDrawable(trans);
    trans.startTransition(200);
    mLastColor = darkColor;
    if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP) {
        getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        getActivity().getWindow().setStatusBarColor(VideoInfoCommonClass.getAlphaColor(darkColor, 160));
    }

}
项目:aos-Video    文件:BrowserListOfEpisodes.java   
@Override
protected void setColor(int color) {

    int darkColor = VideoInfoCommonClass.getDarkerColor(color);
    ColorDrawable[] colord = {new ColorDrawable(mLastColor), new ColorDrawable(darkColor)};
    TransitionDrawable trans = new TransitionDrawable(colord);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
        mApplicationFrameLayout.setBackground(trans);
    else
        mApplicationFrameLayout.setBackgroundDrawable(trans);
    trans.startTransition(200);
    mLastColor = darkColor;
    if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP) {
        getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        getActivity().getWindow().setStatusBarColor(VideoInfoCommonClass.getAlphaColor(darkColor, 160));
    }

}
项目:FantaF1    文件:LoginActivity.java   
private void setContent() {
    setContentView(R.layout.activity_login);
    screen = (RelativeLayout)findViewById(R.id.rl);
    ColorDrawable[] color = {new ColorDrawable(getResources().getColor(R.color.colorAccent)), new ColorDrawable(getResources().getColor(R.color.colorPrimary)) };
    TransitionDrawable trans = new TransitionDrawable(color);
    screen.setBackgroundDrawable(trans);
    trans.startTransition(1800);

    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(getString(R.string.default_web_client_id)).requestEmail().build();
    mGoogleApiClient = new GoogleApiClient.Builder(getBaseContext())
            .enableAutoManage(this, this) .addApi(Auth.GOOGLE_SIGN_IN_API, gso).build();
    mAuth = FirebaseAuth.getInstance();

    FirebaseDatabase database = FirebaseDatabase.getInstance();
    root= database.getReference("room_names");
    loadRooms();
    new CountDownTimer(2500, 1000) {
        public void onTick(long millisUntilDone) { }
        public void onFinish() {
            currentUser = mAuth.getCurrentUser();
            updateUI(currentUser);
        }
    }.start();
}
项目:ECardFlow    文件:ECardFlowLayout.java   
private void startTrans(int targetPosition, ImageView targetImage, RecyclingBitmapDrawable startBp, RecyclingBitmapDrawable endBp) {
    if (endBp == null)
        endBp = loadBitmap(targetPosition);
    TransitionDrawable td = new TransitionDrawable(new Drawable[] {startBp, endBp});
    targetImage.setImageDrawable(td);
    td.setCrossFadeEnabled(true);
    td.startTransition(mSwitchAnimTime);
}
项目:MyAnimeViewer    文件:BitmapPalette.java   
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);
    }
项目:Pocket-Plays-for-Twitch    文件:AnimationService.java   
public static void setPicassoShowImageAnimationTwo(final ImageView aImageView, final Bitmap toImage, Context context) {
    if (toImage == null) {
        return;
    }

    if (isImageViewValidForTransition(aImageView)) {
        Bitmap newBitmap = Bitmap.createBitmap(toImage.getWidth(), toImage.getHeight(), toImage.getConfig()); //ToDo: Out of memory exception here
        Canvas canvas = new Canvas(newBitmap);
        canvas.drawColor(Service.getColorAttribute(R.attr.cardBackgroundColor, R.color.white, context));
        canvas.drawBitmap(toImage, 0, 0, null);

        // create the transition layers
        Drawable[] layers = new Drawable[2];
        layers[0] = aImageView.getDrawable();
        layers[1] = new BitmapDrawable(context.getResources(), newBitmap);

        TransitionDrawable transitionDrawable = new TransitionDrawable(layers);
        aImageView.setImageDrawable(transitionDrawable);
        transitionDrawable.startTransition(300);
    } else {
        aImageView.setImageBitmap(toImage);
    }
}
项目:InstagramGradientLibrary    文件:AnimateActivity.java   
void repeatTransition(final TransitionDrawable trans, final int timeInterval) {
        r = new Runnable() {
            @Override
            public void run() {
                if (flag) {
//                    Log.d("tagg", "straight");
                    trans.startTransition(timeInterval);
                    flag = false;
                } else {
//                    Log.d("tagg", "reverse");
                    trans.reverseTransition(timeInterval);
                    flag = true;
                }
                hand.postDelayed(this, (2*timeInterval));
            }
        };
        hand.post(r);
    }
项目:Rey-MusicPlayer    文件:MusicUtils.java   
public static void animate(final ImageView imageView, Drawable drawable1, Drawable drawable2) {
    Drawable[] layers = new Drawable[2];
    layers[0] = drawable1;
    layers[1] = drawable2;

    TransitionDrawable transitionDrawable = new TransitionDrawable(layers);
    imageView.setImageDrawable(transitionDrawable);
    transitionDrawable.startTransition(5000);
}
项目:FireFiles    文件:DocumentsActivity.java   
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();
    }
项目:FireFiles    文件:SettingsActivity.java   
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;
    }
项目:boohee_v5.6    文件:PLA_AbsListView$CheckForTap.java   
public void run() {
    if (this.this$0.mTouchMode == 0) {
        this.this$0.mTouchMode = 1;
        View child = this.this$0.getChildAt(this.this$0.mMotionPosition - this.this$0
                .mFirstPosition);
        if (child != null && !child.hasFocusable()) {
            this.this$0.mLayoutMode = 0;
            if (this.this$0.mDataChanged) {
                this.this$0.mTouchMode = 2;
                return;
            }
            this.this$0.layoutChildren();
            child.setPressed(true);
            this.this$0.positionSelector(child);
            this.this$0.setPressed(true);
            int longPressTimeout = ViewConfiguration.getLongPressTimeout();
            boolean longClickable = this.this$0.isLongClickable();
            if (this.this$0.mSelector != null) {
                Drawable d = this.this$0.mSelector.getCurrent();
                if (d != null && (d instanceof TransitionDrawable)) {
                    if (longClickable) {
                        ((TransitionDrawable) d).startTransition(longPressTimeout);
                    } else {
                        ((TransitionDrawable) d).resetTransition();
                    }
                }
            }
            if (!longClickable) {
                this.this$0.mTouchMode = 2;
            }
        }
    }
}
项目:simple-share-android    文件:DocumentsActivity.java   
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();
    }
项目:simple-share-android    文件:SettingsActivity.java   
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;
    }
项目:FindX    文件:AboutDevelopers.java   
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);

}
项目:MusicX-music-player    文件:BitmapPalette.java   
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);
    }
项目:RLibrary    文件:RImageView.java   
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();
    }
}
项目:Swap    文件:PLA_AbsListView.java   
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;
            }
        }
    }
}
项目:APK    文件:ImageWorker.java   
/**
 * 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);
    }
}
项目:recycler-view-optimization    文件:GameItemView.java   
@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();
}
项目:Gank-Meizi    文件:DrawableFadeDisplayer.java   
/**
 * @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);
}
项目:TAG    文件:ImageWorker.java   
/**
 * 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);
    }
}