From e170605ebc8c6cc1574054074481bb778902b409 Mon Sep 17 00:00:00 2001 From: daniel oeh Date: Fri, 3 Aug 2012 19:48:59 +0200 Subject: Thumbnail download is now partly working --- res/layout/miroguide_channellist_item.xml | 7 +-- .../antennapod/asynctask/FeedImageLoader.java | 5 ++ .../asynctask/MiroGuideThumbnailDownloader.java | 66 ++++++++++++---------- .../fragment/MiroGuideChannellistFragment.java | 2 +- .../miroguide/con/MiroGuideConnector.java | 6 +- .../antennapod/miroguide/con/MiroGuideService.java | 2 + .../antennapod/miroguide/model/MiroChannel.java | 8 +-- src/de/danoeh/antennapod/util/BitmapDecoder.java | 28 ++++++--- 8 files changed, 73 insertions(+), 51 deletions(-) diff --git a/res/layout/miroguide_channellist_item.xml b/res/layout/miroguide_channellist_item.xml index e5f444ebd..1d52ff695 100644 --- a/res/layout/miroguide_channellist_item.xml +++ b/res/layout/miroguide_channellist_item.xml @@ -6,14 +6,13 @@ + android:src="@drawable/default_cover" /> getItems() { return items; } - - + + public void setThumbnailUrl(String thumbnailUrl) { + this.thumbnailUrl = thumbnailUrl; + } } diff --git a/src/de/danoeh/antennapod/util/BitmapDecoder.java b/src/de/danoeh/antennapod/util/BitmapDecoder.java index 8cd0bd910..f4b902c6f 100644 --- a/src/de/danoeh/antennapod/util/BitmapDecoder.java +++ b/src/de/danoeh/antennapod/util/BitmapDecoder.java @@ -6,8 +6,9 @@ import android.util.Log; public class BitmapDecoder { private static final String TAG = "BitmapDecoder"; - - private static int calculateSampleSize(int preferredLength, int width, int height) { + + private static int calculateSampleSize(int preferredLength, int width, + int height) { int max = Math.max(width, height); if (max < preferredLength) { return 1; @@ -27,18 +28,23 @@ public class BitmapDecoder { } } } - + public static Bitmap decodeBitmap(int preferredLength, String fileUrl) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(fileUrl, options); - int sampleSize = calculateSampleSize(preferredLength, options.outWidth, - options.outHeight); + int srcWidth = options.outWidth; + int srcHeight = options.outHeight; + int sampleSize = calculateSampleSize(preferredLength, srcWidth, + srcHeight); options.inJustDecodeBounds = false; options.inSampleSize = sampleSize; - Bitmap decodedBitmap = BitmapFactory.decodeFile(fileUrl, - options); + options.inPreferredConfig = Bitmap.Config.ARGB_8888; + options.inDither = false; + options.inScaled = false; + + Bitmap decodedBitmap = BitmapFactory.decodeFile(fileUrl, options); if (decodedBitmap == null) { Log.i(TAG, "Bitmap could not be decoded in custom sample size. Trying default sample size (path was " @@ -46,8 +52,12 @@ public class BitmapDecoder { decodedBitmap = BitmapFactory.decodeFile(fileUrl); } if (decodedBitmap != null) { - return Bitmap.createScaledBitmap(decodedBitmap, - preferredLength, preferredLength, false); + if (preferredLength > srcWidth || preferredLength > srcHeight) { + return decodedBitmap; + } else { + return Bitmap.createScaledBitmap(decodedBitmap, + preferredLength, preferredLength, false); + } } else { return null; } -- cgit v1.2.3