*/
private boolean check(File cached, boolean allowTooOld, boolean stable) {
if (cached.exists() && cached.isFile()) {
- if (allowTooOld || !isOld(cached, stable)) {
+ if (!allowTooOld && isOld(cached, stable)) {
+ if (!cached.delete()) {
+ tracer.error("Cannot delete temporary file: "
+ + cached.getAbsolutePath());
+ }
+ } else {
return true;
}
}
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
-import be.nikiroo.utils.Image;
-import be.nikiroo.utils.ImageUtils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import be.nikiroo.utils.Image;
+import be.nikiroo.utils.ImageUtils;
+
/**
- * This class offer some utilities based around images and uses the Android framework.
+ * This class offer some utilities based around images and uses the Android
+ * framework.
*
* @author niki
*/
Bitmap image = BitmapFactory.decodeByteArray(img.getData(), 0,
img.getData().length);
if (image == null) {
- throw new IOException("Failed to convert input to image");
+ int size = img.getData().length;
+ String ssize = size + " byte";
+ if (size > 1) {
+ ssize = size + " bytes";
+ if (size >= 1000) {
+ size = size / 1000;
+ ssize = size + " kb";
+ if (size > 1000) {
+ size = size / 1000;
+ ssize = size + " MB";
+ }
+ }
+ }
+
+ throw new IOException(
+ "Failed to convert input to image, size was: " + ssize);
}
return image;