diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2013-02-10 16:19:25 +0100 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2013-02-10 16:19:25 +0100 |
commit | d85b90f56e75ea33a3fcd93d03aa37501c357807 (patch) | |
tree | cd31c14f52536b90b269ba3084756f635423e8fc /src/de/danoeh/antennapod/util | |
parent | d297b5125520f653c485dee9687433e8b2d0d6ff (diff) | |
download | AntennaPod-d85b90f56e75ea33a3fcd93d03aa37501c357807.zip |
Added expandable notifications to PlaybackService
Diffstat (limited to 'src/de/danoeh/antennapod/util')
-rw-r--r-- | src/de/danoeh/antennapod/util/BitmapDecoder.java | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/src/de/danoeh/antennapod/util/BitmapDecoder.java b/src/de/danoeh/antennapod/util/BitmapDecoder.java index 270cff0c9..8dd4953c6 100644 --- a/src/de/danoeh/antennapod/util/BitmapDecoder.java +++ b/src/de/danoeh/antennapod/util/BitmapDecoder.java @@ -1,5 +1,10 @@ package de.danoeh.antennapod.util; +import java.io.File; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.FilenameUtils; + import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.util.Log; @@ -17,26 +22,30 @@ 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 srcWidth = options.outWidth; - int srcHeight = options.outHeight; - int length = Math.max(srcWidth, srcHeight); - int sampleSize = calculateSampleSize(preferredLength, length); - if (AppConfig.DEBUG) - Log.d(TAG, "Using samplesize " + sampleSize); - options.inJustDecodeBounds = false; - options.inSampleSize = sampleSize; - options.inPreferredConfig = Bitmap.Config.ARGB_8888; + if (fileUrl != null && new File(fileUrl).exists()) { + BitmapFactory.Options options = new BitmapFactory.Options(); + options.inJustDecodeBounds = true; + BitmapFactory.decodeFile(fileUrl, options); + int srcWidth = options.outWidth; + int srcHeight = options.outHeight; + int length = Math.max(srcWidth, srcHeight); + int sampleSize = calculateSampleSize(preferredLength, length); + if (AppConfig.DEBUG) + Log.d(TAG, "Using samplesize " + sampleSize); + options.inJustDecodeBounds = false; + options.inSampleSize = sampleSize; + options.inPreferredConfig = Bitmap.Config.ARGB_8888; - 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 " - + fileUrl + ")"); - decodedBitmap = BitmapFactory.decodeFile(fileUrl); + 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 " + + fileUrl + ")"); + decodedBitmap = BitmapFactory.decodeFile(fileUrl); + } + return decodedBitmap; + } else { + return null; } - return decodedBitmap; } } |