I'm writing app with ActionBar Tabs and ViewPager. I have two tabs and two pages. First page is just Fragmet and second is ListFragment.
In first page i'm inverting infromations about plat like name, interval between water, photo etc. I can add default photo (from resources) and take photo of plant. Then i save photo's data in database like String in two ways: id of image from resources or path to saved photo.
In second page (ListFragment) is ListView with custom adapter and there is the problem. One row of list contains two TextViews, CheckBox and ImageView.
In method getView of my custom adapter every line works fine, but decoding file to bitmap takes lot of time and it makes my app alowly, even after decoding all photos.
It's my code to set up an image in each list row:
private void setUpImage(int position, ImageView photo)
{
if(plants.get(position).getPhoto().contains("jpg"))
{
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 10;
Bitmap bitmap = BitmapFactory.decodeFile(plants.get(position).getPhoto(), options);
photo.setImageBitmap(bitmap);
}
else
{
photo.setImageResource(Integer.parseInt(plants.get(position).getPhoto()));
}
}
Do anyone know how to improve speed of decoding and seting image in each list row of my ListView?