Android cache webview images? - android

I've Listview activity each row content webview and the webview content article html code with images.
So far everything is perfect, but my problem is if the listview scrolled the webview lost images and reopen them again, and the listview become crazy.
I want to cachewebview images to prevent it to reopen or download the images again. How?
I am new in Android and sorry for my English.
Any advice?
This is my webview settings:
holder.message.addJavascriptInterface(new test_js(context), "Android");
holder.message.getSettings().setJavaScriptEnabled(true);
// holder.message.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
holder.message.getSettings().setTextSize(WebSettings.TextSize.NORMAL);
//test
holder.message.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
holder.message.getSettings().setAppCacheMaxSize( 8 * 1024 * 1024 ); // 8MB
holder.message.getSettings().setAppCachePath(context.getApplicationContext().getCacheDir().getAbsolutePath());
holder.message.getSettings().setAllowFileAccess(true);
holder.message.getSettings().setAppCacheEnabled(true);
but it won't cache the images it's redownloading them again when I scroll the listview!

I recommend you to use Universal-Image-Loader for loading and caching images when working with listview or recyclerview. The Universal-Image-Loader has option delayBeforeLoading(time) to prevent listview's scroll issues when there is item with images. And to cache other content just write the body of response to file and extract it to your listview.

Related

Load asynchronous images in listView only on scroll

So I've got this ListView and its adapter. It's using lazy loading of images with a transition effect from previous image to new.
It works great, but I have a problem and it's that my only reason to use a lazy load is to make scroll smooth. If I need to resort the listview I don't want images to lazy load as the transition is completely unnecessary.
I really don't know how to know inside the adapter whether the user is scrolling or the listview has been resorted. Any help is welcome, I found similar questions but none addressed this issue.
The concept of LazyLoading is that it loads the images for the first transition only and the images are cached. If the user again scrolls or if the ListView restores, it never downloads it again, images are taken from the local cache present on the device.
There are many Libraries that provide this feature :
Lazy List
Universal Loader
Volley
Picasso
Tutorial

Prefetch & cache dynamically created jqueryMobile+PhoneGap pages

I have a PhoneGap app (with jqueryMobile) which uses several listviews, sometimes with pictures included.
On some devices this can take 1-2 seconds to load. I have tried to use the cache-
<div data-role="page" class="listpage" data-dom-cache="true">
and prefetch-
<a href="listview_1.html" rel="external" data-prefetch>Listview 1</a>
options, but neither would work / make any difference.
The pages are almost completely dynamically created from a sqlite database - maybe this is the actual issue...?
Any hints greatly appreciated, Thanks!
I think cache will not solve your problem. cache stores temporarily pages and images, and also mainly for second time load only. Other choice is reduce the list view count for example 8 or 10 with load more button or scroll to append new list values use pagination concept to load list view. If your using cache concept you can't load new list values so that's not dynamic list view.
Best choice for cache is list view to navigate detailed view. Because after user clicks back button or link to retain list view.

Android ListView smooth navigation while images from SDCard

I saw a lot of implementations of smooth downloading images from web and showing them in listView with cache. Now I have the following situation: I'm storing images to SDCard and sometimes my listView shows them instead of images from web resource. In this case navigation in listView is not smooth. Do you know any good implementation of listView with image from sdCard?
Multithreading is the answer!
http://android-developers.blogspot.com/2010/07/multithreading-for-performance.html
Just ignore the the sections for downloading, but idea is the same!
Then check this code :
Lazy load of images in ListView

Android Show Blob Images in listview when scroll.

Hi I want to show the images in listview when user scroll the list.
I retrieved the image from database(blob) not from web service.
for example
I have an 40 items in the list view and in my mobile screen 10 item is visible. when i scroll the list it load the next images. i don't want to load the 40 images concurrently.
list will show images between Fisrt Visible Position and Last Visible Position.
Like in a twitter app the images first blank when user scroll then it load in the listview
Thanks in advance.
The solution you finding is called Lazy Loading Adapter, this tutorial will work as you want check this link, this loads images in lazy manner.

Loading pictures in Android

What is the best practice for loading images from the Web into a ListView?
Do I have to load them first into SQLite database or should I load them directly into a ListView?
And also after clicking an item in the ListView I have to show the same image in another activity. Is it the right way to pass this image to another activity or it is better to load it from Web / SQLite once again?
Look here Lazy loading of images
Loading them directly into the listview will make scrolling in it slow, as it will reload them everytime they get visible.
do that Google recommended http://developer.android.com/training/displaying-bitmaps/index.html

Categories

Resources