0

Iam using universal image loader in my app and my app contains alot of images in ListView

I created a method for the confg and iam using this method in my adapter

First: some times this make my app stop by OutOfMemeory Error. Second : My ListView is so slow when scrolling it.

dose my config correct or i have to change it

and its wrong to use this config in a method like this

and calling this method from 5 different ListView

this is my method

 public final static DisplayImageOptions imageLoaderConfig(Context context) {

    DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
            .bitmapConfig(Bitmap.Config.RGB_565)
            .resetViewBeforeLoading(true)
            .showImageForEmptyUri(R.drawable.shadow)
            .cacheInMemory(true).cacheOnDisc(true).build();

    File cacheDir = StorageUtils.getCacheDirectory(context);
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
            context)
            .memoryCacheExtraOptions(480, 800)


            .taskExecutor(null).taskExecutorForCachedImages(null)
            .threadPoolSize(5)

            .threadPriority(Thread.NORM_PRIORITY)

            .denyCacheImageMultipleSizesInMemory()

            .memoryCacheSize(15 * 1024 * 1024)

            .imageDownloader(new BaseImageDownloader(context)) 
            .imageDecoder(new BaseImageDecoder(true)) 
            .defaultDisplayImageOptions(defaultOptions)
            .writeDebugLogs().build();

    ImageLoader.getInstance().init(config);
    return defaultOptions;

}

and this is my costume list

 public class CustomListViewWallPost extends
    ArrayAdapter<getterssetters.Items_WallPost> {

getterssetters.Items_WallPost postItem;
private int mLastFirstVisibleItem = 0;
static Context context;
List<getterssetters.Items_WallPost> objects_;
int width_;
DisplayImageOptions defaultOptions;
ImageLoader imageLoader;

public CustomListViewWallPost(Context context, int textViewResourceId,
        List<getterssetters.Items_WallPost> objects, int width_) {
    super(context, textViewResourceId, objects);

    this.context = context;

    this.width_ = width_;
    this.objects_ = objects;
    defaultOptions = PublicMethods
            .imageLoaderConfig(context);
    imageLoader = ImageLoader.getInstance();

}
Jehad
  • 472
  • 2
  • 10
  • 24
  • http://stackoverflow.com/questions/13194098/universal-image-loader-outofmemory-error?lq=1 – Shayan Pourvatan Jun 22 '14 at 08:43
  • http://developer.android.com/training/displaying-bitmaps/load-bitmap.html Try to check the size of bitmap before actually loading, and compress it for less memory consumption – Hemant Patel Jun 22 '14 at 08:45

0 Answers0