git://git.nikiroo.be
/
nikiroo-utils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
e8aa5bf
)
Auto cache cleaning + better err in ImageUtilsAnd
author
Niki Roo
<niki@nikiroo.be>
Sun, 10 Dec 2017 17:47:35 +0000
(18:47 +0100)
committer
Niki Roo
<niki@nikiroo.be>
Sun, 10 Dec 2017 17:47:35 +0000
(18:47 +0100)
src/be/nikiroo/utils/Cache.java
patch
|
blob
|
blame
|
history
src/be/nikiroo/utils/android/ImageUtilsAndroid.java
patch
|
blob
|
blame
|
history
src/be/nikiroo/utils/ui/ImageUtilsAwt.java
patch
|
blob
|
blame
|
history
diff --git
a/src/be/nikiroo/utils/Cache.java
b/src/be/nikiroo/utils/Cache.java
index 2b32d78d67c03d20ba94148b8f92b2f7bdabda23..bba88bb4b48f7e970039002393a72a47d50081cf 100644
(file)
--- a/
src/be/nikiroo/utils/Cache.java
+++ b/
src/be/nikiroo/utils/Cache.java
@@
-135,7
+135,12
@@
public class Cache {
*/
private boolean check(File cached, boolean allowTooOld, boolean stable) {
if (cached.exists() && cached.isFile()) {
*/
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;
}
}
return true;
}
}
diff --git
a/src/be/nikiroo/utils/android/ImageUtilsAndroid.java
b/src/be/nikiroo/utils/android/ImageUtilsAndroid.java
index 483c44ff144ec8f705412e85c2c9b428e973999f..b2359e66338d9d0d7959b6fae56fa3ea6b0c7b72 100644
(file)
--- a/
src/be/nikiroo/utils/android/ImageUtilsAndroid.java
+++ b/
src/be/nikiroo/utils/android/ImageUtilsAndroid.java
@@
-2,15
+2,17
@@
package be.nikiroo.utils.android;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
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 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
*/
*
* @author niki
*/
@@
-62,7
+64,22
@@
public class ImageUtilsAndroid extends ImageUtils {
Bitmap image = BitmapFactory.decodeByteArray(img.getData(), 0,
img.getData().length);
if (image == null) {
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;
}
return image;
diff --git
a/src/be/nikiroo/utils/ui/ImageUtilsAwt.java
b/src/be/nikiroo/utils/ui/ImageUtilsAwt.java
index 26d14aaba2bf4ec30e30aac10992fa06efc9a468..0c69dc4482938ae02608be704167e23a8add13e0 100644
(file)
--- a/
src/be/nikiroo/utils/ui/ImageUtilsAwt.java
+++ b/
src/be/nikiroo/utils/ui/ImageUtilsAwt.java
@@
-61,7
+61,7
@@
public class ImageUtilsAwt extends ImageUtils {
* @throws IOException
* in case of IO error
*/
* @throws IOException
* in case of IO error
*/
-
static publ
ic BufferedImage fromImage(Image img) throws IOException {
+
public stat
ic BufferedImage fromImage(Image img) throws IOException {
InputStream in = new ByteArrayInputStream(img.getData());
int orientation;
InputStream in = new ByteArrayInputStream(img.getData());
int orientation;