Search in sources :

Example 1 with RoundedDrawable

use of in.srain.cube.image.drawable.RoundedDrawable 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);
        }
    }
}
Also used : RoundedDrawable(in.srain.cube.image.drawable.RoundedDrawable) TransitionDrawable(android.graphics.drawable.TransitionDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) ViewGroup(android.view.ViewGroup) ColorDrawable(android.graphics.drawable.ColorDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Drawable(android.graphics.drawable.Drawable) RoundedDrawable(in.srain.cube.image.drawable.RoundedDrawable) TransitionDrawable(android.graphics.drawable.TransitionDrawable)

Aggregations

BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Drawable (android.graphics.drawable.Drawable)1 TransitionDrawable (android.graphics.drawable.TransitionDrawable)1 ViewGroup (android.view.ViewGroup)1 RoundedDrawable (in.srain.cube.image.drawable.RoundedDrawable)1