سؤال

I'm using Universal Image Loader in a ListView, It works perfectly the first time, but the rest of the time, the image has no rounded corners. Only if I scroll the image has rounded borders again.

This is my code:

ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
            context).threadPriority(Thread.NORM_PRIORITY - 2)
            .denyCacheImageMultipleSizesInMemory()
            .discCacheFileNameGenerator(new Md5FileNameGenerator())
            .tasksProcessingOrder(QueueProcessingType.LIFO).enableLogging() 
            .build();
    // Initialize ImageLoader with configuration.
    ImageLoader.getInstance().init(config);


DisplayImageOptions options = new DisplayImageOptions.Builder()
    .displayer(new RoundedBitmapDisplayer(50))
    .showStubImage(R.drawable.ic_app)
    .showImageForEmptyUri(R.drawable.camera)
    .showImageOnFail(R.drawable.ic_error).cacheInMemory().cacheOnDisc()
    .build();


public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.listmessages_row, null);
    }//End if


    ImageView avatar = (ImageView) convertView.findViewById(R.id.ImageView_MessageRow);
    ImageView avatarEmpty = (ImageView) convertView.findViewById(R.id.ImageView_PhotoProfileEmpty);
    final int positionAux = position; 

    if (listItems.get(position).avatar.equals("no_avatar")){
        avatarEmpty.setVisibility(View.VISIBLE);
        avatar.setVisibility(View.GONE);
    }else{
        avatarEmpty.setVisibility(View.GONE);
        avatar.setVisibility(View.VISIBLE);
        imageLoader.displayImage(IMAGES + listItems.get(position).avatar, avatar, options);
    }//End if-else

    return convertView;
}//End getView
هل كانت مفيدة؟

المحلول

I answer myserlf, I modified the options of displayImageOtions and it works perfectly all the times. I only deleted this line: cacheInMemory()

Now my display image options are:

options = new DisplayImageOptions.Builder()
        .displayer(new RoundedBitmapDisplayer(50))
        .showStubImage(R.drawable.ic_app)
        .showImageForEmptyUri(R.drawable.camera)
        .showImageOnFail(R.drawable.ic_error)
        .cacheOnDisc()
        .build();
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top