From efe638fa872830dc03fc1305ce9b4a29f9f9683b Mon Sep 17 00:00:00 2001 From: Daniel Oeh Date: Sat, 14 Apr 2012 15:30:14 +0200 Subject: [PATCH] Bitmap of FeedImage is now saved globally --- src/de/podfetcher/activity/ItemviewActivity.java | 2 +- src/de/podfetcher/adapter/FeedlistAdapter.java | 2 +- src/de/podfetcher/feed/FeedImage.java | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/de/podfetcher/activity/ItemviewActivity.java b/src/de/podfetcher/activity/ItemviewActivity.java index c0c81bb63..c2d1a5564 100644 --- a/src/de/podfetcher/activity/ItemviewActivity.java +++ b/src/de/podfetcher/activity/ItemviewActivity.java @@ -65,7 +65,7 @@ public class ItemviewActivity extends SherlockActivity { txtvPublished.setText(item.getPubDate()); txtvTitle.setText(item.getTitle()); if(item.getFeed().getImage() != null) { - imgvImage.setImageBitmap(BitmapFactory.decodeFile(item.getFeed().getImage().getFile_url())); + imgvImage.setImageBitmap(item.getFeed().getImage().getImageBitmap()); } } } diff --git a/src/de/podfetcher/adapter/FeedlistAdapter.java b/src/de/podfetcher/adapter/FeedlistAdapter.java index 0b6a144d5..7c654f010 100644 --- a/src/de/podfetcher/adapter/FeedlistAdapter.java +++ b/src/de/podfetcher/adapter/FeedlistAdapter.java @@ -47,7 +47,7 @@ public class FeedlistAdapter extends ArrayAdapter { holder.title.setText(feed.getTitle()); if(feed.getImage() != null) { - holder.image.setImageBitmap(BitmapFactory.decodeFile(feed.getImage().getFile_url())); // TODO select default picture when no image downloaded + holder.image.setImageBitmap(feed.getImage().getImageBitmap()); // TODO select default picture when no image downloaded } // TODO find new Episodes txtvNewEpisodes.setText(feed) return convertView; diff --git a/src/de/podfetcher/feed/FeedImage.java b/src/de/podfetcher/feed/FeedImage.java index c3457533c..02d83b5ae 100644 --- a/src/de/podfetcher/feed/FeedImage.java +++ b/src/de/podfetcher/feed/FeedImage.java @@ -1,7 +1,11 @@ package de.podfetcher.feed; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; + public class FeedImage extends FeedFile { protected String title; + protected Bitmap image_bitmap; public FeedImage(String download_url, String title) { super(); @@ -23,6 +27,13 @@ public class FeedImage extends FeedFile { public String getTitle() { return title; } + + public Bitmap getImageBitmap() { + if(image_bitmap == null) { + image_bitmap = BitmapFactory.decodeFile(getFile_url()); + } + return image_bitmap; + }