aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2013-09-14 13:49:38 +0200
committerSamuel Tardieu <sam@rfc1149.net>2013-09-14 13:49:38 +0200
commit46afb0c59b54b1c1d102ea3e71fa7834e07728e3 (patch)
tree31dd687582aa487e1d705743892c220ee0102169
parent3eb1eeb963b55021e857501881478f607958bb11 (diff)
parentfa4234853e9f3afb641fb7a0e1fb7b15ef266262 (diff)
downloadcgeo-46afb0c59b54b1c1d102ea3e71fa7834e07728e3.zip
cgeo-46afb0c59b54b1c1d102ea3e71fa7834e07728e3.tar.gz
cgeo-46afb0c59b54b1c1d102ea3e71fa7834e07728e3.tar.bz2
Merge branch 'release' into upstream
-rw-r--r--main/src/cgeo/geocaching/utils/ImageUtils.java16
1 files changed, 13 insertions, 3 deletions
diff --git a/main/src/cgeo/geocaching/utils/ImageUtils.java b/main/src/cgeo/geocaching/utils/ImageUtils.java
index 1bbe70c..401ab1a 100644
--- a/main/src/cgeo/geocaching/utils/ImageUtils.java
+++ b/main/src/cgeo/geocaching/utils/ImageUtils.java
@@ -94,7 +94,7 @@ public final class ImageUtils {
* Image to read
* @param maxXY
* boundings
- * @return String filename and path, NULL if something fails
+ * @return filename and path, <tt>null</tt> if something fails
*/
public static String readScaleAndWriteImage(final String filePath, final int maxXY) {
if (maxXY <= 0) {
@@ -117,12 +117,21 @@ public final class ImageUtils {
return null;
}
final BitmapDrawable scaledImage = scaleBitmapTo(image, maxXY, maxXY);
- final String uploadFilename = ImageUtils.getOutputImageFile().getPath();
+ final File tempImageFile = ImageUtils.getOutputImageFile();
+ if (tempImageFile == null) {
+ Log.e("ImageUtils.readScaleAndWriteImage: unable to write scaled image");
+ return null;
+ }
+ final String uploadFilename = tempImageFile.getPath();
storeBitmap(scaledImage.getBitmap(), Bitmap.CompressFormat.JPEG, 75, uploadFilename);
return uploadFilename;
}
- /** Create a File for saving an image or video */
+ /** Create a File for saving an image or video
+ *
+ * @return the temporary image file to use, or <tt>null</tt> if the media directory could
+ * not be created.
+ * */
public static File getOutputImageFile() {
// To be safe, you should check that the SDCard is mounted
// using Environment.getExternalStorageState() before doing this.
@@ -134,6 +143,7 @@ public final class ImageUtils {
// Create the storage directory if it does not exist
if (!mediaStorageDir.exists()) {
if (!FileUtils.mkdirs(mediaStorageDir)) {
+ Log.e("ImageUtils.getOutputImageFile: cannot create media storage directory");
return null;
}
}