Answer the question
In order to leave comments, you need to log in
Late rearrangement of images in ListView via ImageLoader, How to fix?
There is a list based on ImageLoader, its config in custom adapter looks like
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getContext())
.memoryCacheExtraOptions(480, 800) // width, height
.threadPoolSize(5)
.threadPriority(Thread.MIN_PRIORITY + 2)
.denyCacheImageMultipleSizesInMemory()
.memoryCache(new UsingFreqLimitedMemoryCache(2 * 1024 * 1024)) // 2 Mb
.defaultDisplayImageOptions(DisplayImageOptions.createSimple())
.build();
imageLoader.init(config);
imageLoader.displayImage(models.getImg(), holder.imageView);
@Override
protected void onCreate(Bundle savedInstanceState) {
StrictMode.enableDefaults();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tv = (TextView) findViewById(R.id.answer);
ListView lv = (ListView) findViewById(R.id.list);
data = request.doInBackground();
try {
JSONArray json = new JSONArray(data);
for(int i=0; i < json.length(); i++){
modelrow = new Models(
json.getJSONObject(i).getString("id").toString(),
json.getJSONObject(i).getString("model").toString(),
"http://example.com"+json.getJSONObject(i).getString("preview").toString()
);
fetch.add(modelrow);
}
adapter = new ModelAdapter(MainActivity.this, R.id.list, fetch);
lv.setAdapter(adapter);
} catch (JSONException e) {
e.printStackTrace();
}
08-01 00:20:54.287: D/dalvikvm(1291): GC_FOR_ALLOC freed 316K, 15% free 4004K/4708K, paused 22ms, total 24ms
08-01 00:20:54.687: W/ImageLoader(1291): Try to initialize ImageLoader which had already been initialized before. To re-init ImageLoader with new configuration call ImageLoader.destroy() at first.
08-01 00:20:54.697: W/ImageLoader(1291): Try to initialize ImageLoader which had already been initialized before. To re-init ImageLoader with new configuration call ImageLoader.destroy() at first.
08-01 00:20:54.717: W/ImageLoader(1291): Try to initialize ImageLoader which had already been initialized before. To re-init ImageLoader with new configuration call ImageLoader.destroy() at first.
08-01 00:20:55.287: D/dalvikvm(1291): GC_FOR_ALLOC freed 298K, 16% free 3996K/4708K, paused 24ms, total 24ms
08-01 00:20:55.587: D/dalvikvm(1291): GC_FOR_ALLOC freed 307K, 19% free 3854K/4708K, paused 24ms, total 25ms
08-01 00:20:55.597: I/Choreographer(1291): Skipped 62 frames! The application may be doing too much work on its main thread.
08-01 00:20:55.817: I/Choreographer(1291): Skipped 46 frames! The application may be doing too much work on its main thread.
Answer the question
In order to leave comments, you need to log in
I have the same problem... The only solution I've found so far (not the best for me) is resetting the view before loading (.resetViewBeforeLoading(true)) and adding a stub image (.showImageOnLoading())
What about: in-memory cache, resource usage shown during download?
(as far as I know, it is disabled on the memory cache account and .memoryCache(new UsingFreqLimitedMemoryCache(2 * 1024 * 1024)) will not enable it, you need to set .cacheInMemory(true).cacheOnDisk(true)) in the
options since it takes some time to work with bitmaps.
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder must be moved to Application#onCreate (because these are global settings)
Try adding .resetViewBeforeLoading(true) to the options builder.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question