List of usage examples for android.graphics.drawable TransitionDrawable startTransition
public void startTransition(int durationMillis)
From source file:haipeng.myalbum.imageload.ImageWorker.java
/** * Called when the processing is complete and the final bitmap should be set * on the ImageView./*from w ww. j av a 2s . co m*/ * * @param imageView * @param bitmap */ @SuppressWarnings("deprecation") 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(Color.TRANSPARENT), new BitmapDrawable(mResources, bitmap) }); // Set background to loading bitmap imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap)); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageBitmap(bitmap); } }
From source file:net.kjmaster.cookiemom.MainActivity.java
private void changeColor(int newColor) { tabs.setIndicatorColor(newColor);//from w w w. j a va2 s. c om // change ActionBar color just if an ActionBar is available if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { 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 { getActionBar().setBackgroundDrawable(ld); } } else { TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, ld }); // workaround for broken ActionBarContainer drawable handling on // pre-API 17 builds // https://github.com/android/platform_frameworks_base/commit/a7cc06d82e45918c37429a59b14545c6a57db4e4 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { td.setCallback(drawableCallback); } else { getActionBar().setBackgroundDrawable(td); } td.startTransition(200); } oldBackground = ld; // http://stackoverflow.com/questions/11002691/actionbar-setbackgrounddrawable-nulling-background-from-thread-handler getActionBar().setDisplayShowTitleEnabled(false); getActionBar().setDisplayShowTitleEnabled(true); } currentColor = newColor; }
From source file:image_cache.ImageWorker.java
/** * Called when the processing is complete and the final bitmap should be set * on the ImageView.//www .j a va 2 s. c o m * * @param imageView * @param bitmap */ @SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.JELLY_BEAN) 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 if (Utils.hasJellyBean()) imageView.setBackground(new BitmapDrawable(mResources, mLoadingBitmap)); else imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap)); imageView.setBackgroundColor(0); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setBackgroundColor(0); imageView.setImageBitmap(bitmap); } }
From source file:com.alex.develop.cache.ImageWorker.java
/** * Called when the processing is complete and the final drawable should be * set on the ImageView.//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[] { // Edit by alex // before new ColorDrawable(android.R.color.transparent), // after // new ColorDrawable(Color.parseColor("#00000000")), // end 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:uk.org.ngo.squeezer.util.ImageWorker.java
/** * Called when the processing is complete and the final bitmap should be set on the ImageView. * * @param imageView/*from w w w. ja va 2s . c o m*/ * @param bitmap */ private void setImageBitmap(ImageView imageView, Bitmap bitmap) { if (mFadeInBitmap) { // Transition drawable between the pending image and the final bitmap. final TransitionDrawable td = new TransitionDrawable( new Drawable[] { imageView.getDrawable(), new BitmapDrawable(mResources, bitmap) }); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageDrawable(new BitmapDrawable(mResources, bitmap)); } }
From source file:kuta.adrian.cv.displayingbitmaps.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 .com * * @param imageView * @param drawable */ private void setImageDrawable(ImageView imageView, Drawable drawable) { try { ViewGroup viewGroup = (ViewGroup) imageView.getParent(); if (viewGroup instanceof FrameLayout) { FrameLayout parent = (FrameLayout) viewGroup; View view; if ((view = parent.getChildAt(0)) instanceof ProgressBar) parent.removeView(view); } } catch (Exception e) { Log.e(getClass().getSimpleName(), "onPostExecute, progressBar not found", e); } if (mFadeInBitmap) { // Transition drawable with a transparent drawable and the final drawable final TransitionDrawable td = new TransitionDrawable(new Drawable[] { new ColorDrawable(ContextCompat.getColor(imageView.getContext(), android.R.color.transparent)), drawable }); // Set background to loading bitmap if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap)); else imageView.setBackground(new BitmapDrawable(mResources, mLoadingBitmap)); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageDrawable(drawable); } }
From source file:com.ksharkapps.musicnow.ui.activities.BaseActivity.java
public void changeActionBarColor(int newColor) { int color = newColor != 0 ? newColor : SettingsActivity.getActionBarColor(this); Drawable colorDrawable = new ColorDrawable(color); Drawable bottomDrawable = getResources().getDrawable(R.drawable.transparent_overlay); 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 {//from w w w .ja va 2s . c o m actBar.setBackgroundDrawable(colorDrawable); } } else { TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, ld }); // workaround for broken ActionBarContainer drawable handling on // pre-API 17 builds // https://github.com/android/platform_frameworks_base/commit/a7cc06d82e45918c37429a59b14545c6a57db4e4 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { td.setCallback(drawableCallback); } else { actBar.setBackgroundDrawable(td); } td.startTransition(200); } oldBackground = ld; // http://stackoverflow.com/questions/11002691/actionbar-setbackgrounddrawable-nulling-background-from-thread-handler actBar.setDisplayShowTitleEnabled(false); actBar.setDisplayShowTitleEnabled(true); if (Utils.hasKitKat()) { if (SettingsActivity.getTranslucentMode(this)) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintColor(getResources().getColor(R.color.contextual_actionbar_color)); } } }
From source file:cn.com.wo.bitmap.ImageWorker.java
/** * Called when the processing is complete and the final drawable should be * set on the ImageView.// w ww. jav a 2s . c o m * * @param imageView * @param drawable */ private void setImageDrawable(ImageView imageView, Drawable drawable, boolean isBackground) { if (mFadeInBitmap && !isBackground) { // 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 int index = 0; if (imageView.getTag() != null) index = (Integer) imageView.getTag(); imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap[index])); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); if (ImageFetcher.isDebug) Log.i(ImageFetcher.TAG, "setImageDrawable src"); } else { if (isBackground) { if (ImageFetcher.isDebug) Log.i(ImageFetcher.TAG, "setImageDrawable isBackground"); imageView.setBackgroundDrawable(null); imageView.setBackgroundDrawable(drawable); } else { if (ImageFetcher.isDebug) Log.i(ImageFetcher.TAG, "setImageDrawable src"); imageView.setImageDrawable(drawable); } } }
From source file:cz.appvision.ebookreader.image.ImageWorker.java
/** * Called when the processing is complete and the final drawable should be * set on the ImageView.//w ww.j ava 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 Drawable currentDrawable = imageView.getDrawable(); if (currentDrawable.getClass().equals(AsyncDrawable.class)) { String placeholderKey = ((AsyncDrawable) currentDrawable).getPlaceholderKey(); imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap.get(placeholderKey))); } imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageDrawable(drawable); } }
From source file:org.android.framework.engine.image.util.ImageWorker.java
/** * Called when the processing is complete and the final drawable should be * set on the ImageView./*from w w w. j ava2s . c om*/ * * @param imageViewObject * @param drawable */ private void setImageDrawable(ImageTask.ImageViewObject imageViewObject, 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 imageViewObject.view.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap)); if (imageViewObject.view instanceof ImageView) { ((ImageView) imageViewObject.view).setImageDrawable(td); imageViewObject.view.setBackgroundDrawable(null); } else { imageViewObject.view.setBackgroundDrawable(td); } td.startTransition(FADE_IN_TIME); } else { if (imageViewObject.view instanceof ImageView) { ((ImageView) imageViewObject.view).setImageDrawable(drawable); imageViewObject.view.setBackgroundDrawable(null); } else { imageViewObject.view.setBackgroundDrawable(drawable); } } }