use of android.graphics.drawable.TransitionDrawable in project cube-sdk by liaohuqiu.
the class DefaultImageLoadHandler method onLoadFinish.
@Override
public void onLoadFinish(ImageTask imageTask, CubeImageView imageView, BitmapDrawable drawable) {
if (imageView == null) {
return;
}
Drawable d = drawable;
if (drawable != null) {
if (mResizeImageViewAfterLoad) {
int w = drawable.getBitmap().getWidth();
int h = drawable.getBitmap().getHeight();
if (w > 0 && h > 0) {
ViewGroup.LayoutParams lyp = imageView.getLayoutParams();
if (lyp != null) {
lyp.width = w;
lyp.height = h;
imageView.setLayoutParams(lyp);
}
}
}
// RoundedDrawable will not recycle automatically when API level is lower than 11
if ((mDisplayTag & DISPLAY_ROUNDED) == DISPLAY_ROUNDED && Version.hasHoneycomb()) {
d = new RoundedDrawable(drawable.getBitmap(), mCornerRadius);
}
if ((mDisplayTag & DISPLAY_FADE_IN) == DISPLAY_FADE_IN) {
int loadingColor = android.R.color.transparent;
if (mLoadingColor != -1 && (mDisplayTag & DISPLAY_ROUNDED) != DISPLAY_ROUNDED) {
loadingColor = mLoadingColor;
}
final TransitionDrawable td = new TransitionDrawable(new Drawable[] { new ColorDrawable(loadingColor), d });
imageView.setImageDrawable(td);
td.startTransition(200);
} else {
if (DEBUG) {
Drawable oldDrawable = imageView.getDrawable();
int w = 0, h = 0;
if (oldDrawable != null) {
w = oldDrawable.getIntrinsicWidth();
h = oldDrawable.getIntrinsicHeight();
}
CLog.d(LOG_TAG, MSG_LOAD_FINISH, imageTask, imageView, w, h, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
}
imageView.setImageDrawable(drawable);
}
}
}
use of android.graphics.drawable.TransitionDrawable in project NotificationPeekPort by lzanita09.
the class AppearanceSettingsFragment method initPreviewBackgroundDrawable.
/**
* Create a new {@link android.graphics.drawable.TransitionDrawable} object with correct order
* of Drawables based on user selection.
*
* @return TransitionDrawable object created.
*/
private TransitionDrawable initPreviewBackgroundDrawable() {
boolean isWallpaperSelected = WallpaperFactory.isWallpaperThemeSelected(getActivity());
Drawable black = new ColorDrawable(Color.BLACK);
Drawable wallpaper = mUseLiveWallpaper ? new ColorDrawable(Color.TRANSPARENT) : new BitmapDrawable(getResources(), mWallpaperFactory.getPrefSystemWallpaper());
mChangeDrawables = !isWallpaperSelected ? new Drawable[] { black, wallpaper } : new Drawable[] { wallpaper, black };
mBlackDrawableIndex = !isWallpaperSelected ? 0 : 1;
return new TransitionDrawable(mChangeDrawables);
}
use of android.graphics.drawable.TransitionDrawable in project 9GAG by stormzhang.
the class ImageCacheManager method getImageListener.
public static ImageLoader.ImageListener getImageListener(final ImageView view, final Drawable defaultImageDrawable, final Drawable errorImageDrawable) {
return new ImageLoader.ImageListener() {
@Override
public void onErrorResponse(VolleyError error) {
if (errorImageDrawable != null) {
view.setImageDrawable(errorImageDrawable);
}
}
@Override
public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
if (response.getBitmap() != null) {
if (!isImmediate && defaultImageDrawable != null) {
TransitionDrawable transitionDrawable = new TransitionDrawable(new Drawable[] { defaultImageDrawable, new BitmapDrawable(App.getContext().getResources(), response.getBitmap()) });
transitionDrawable.setCrossFadeEnabled(true);
view.setImageDrawable(transitionDrawable);
transitionDrawable.startTransition(100);
} else {
view.setImageBitmap(response.getBitmap());
}
} else if (defaultImageDrawable != null) {
view.setImageDrawable(defaultImageDrawable);
}
}
};
}
use of android.graphics.drawable.TransitionDrawable in project glide by bumptech.
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) {
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;
}
}
use of android.graphics.drawable.TransitionDrawable in project coursera-android by aporter.
the class TransitionDrawableActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TransitionDrawable transition = (TransitionDrawable) getResources().getDrawable(R.drawable.shape_transition);
transition.setCrossFadeEnabled(true);
((ImageView) findViewById(R.id.image_view)).setImageDrawable(transition);
transition.startTransition(5000);
}
Aggregations