Combining CoverFlow and Universal Image Loader

自作多情 提交于 2019-12-01 16:24:08

The problem is that you have 2 separate instances of imageview floating around. 1 is created in getView, and the second is created in createReflectedImage. So basically, when the image finishes downloading, a new imageview has already replaced it and the downloaded image is loaded into one that is no longer visible (or possibly even exists). The reason why it loads correctly the second time (after scrolling offscreen) is that the latency is much lower since it is being loaded from memory not off the web or wherever, so when RoundedDrawable drawable = (RoundedDrawable) image.getDrawable(); it actually has the image that you want, rather than just the placeholder!

public View getView(int position, View view, ViewGroup parent) {


    RoundedImageView photo = (RoundedImageView) view;
    ...
        /*
         *Passing first instance of photo into ImageLoaderHelper
         */

    ImageLoaderHelper.configureCacheableImage(mContext, photo, latestBook.get(position).getImageUrl(),
                R.drawable.avatar_issue, null);
    ...
    //
    //Returns the new instance of RoundedImageView that ImageLoader is not aware of to the adapter
    //
    return createReflectedImages(photo);
}

public ImageView createReflectedImages(RoundedImageView image) {
    ...

    RoundedImageView imageView = new RoundedImageView(mContext);
    imageView.setImageBitmap(bitmapWithReflection);
    imageView.setLayoutParams(new ImageGallery3D.LayoutParams(GeneralHelper.dp(180), GeneralHelper.dp(240)));//width and height of Image

    //Returning a new instance of imageView
    return imageView;
}

Instead of returning imageView in createReflectedImages, return "image". Then implement a callback that you pass in to ImageLoaderHelper that calls createReflectedImages after the image has successfully been loaded to apply your effect.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!