|
|
@ -58,6 +58,8 @@ import java.security.MessageDigest;
|
|
|
|
import java.security.NoSuchAlgorithmException;
|
|
|
|
import java.security.NoSuchAlgorithmException;
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
|
|
|
import java.util.concurrent.Semaphore;
|
|
|
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
|
|
class ImageHelper {
|
|
|
|
class ImageHelper {
|
|
|
|
private static final float MIN_LUMINANCE = 0.33f;
|
|
|
|
private static final float MIN_LUMINANCE = 0.33f;
|
|
|
@ -369,7 +371,12 @@ class ImageHelper {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static void fitDrawable(final Drawable d, AnnotatedSource a, final View view) {
|
|
|
|
private static void fitDrawable(final Drawable d, final AnnotatedSource a, final View view) {
|
|
|
|
|
|
|
|
Semaphore semaphore = new Semaphore(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new Handler(view.getContext().getMainLooper()).post(new Runnable() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
Rect bounds = d.getBounds();
|
|
|
|
Rect bounds = d.getBounds();
|
|
|
|
int w = bounds.width();
|
|
|
|
int w = bounds.width();
|
|
|
|
int h = bounds.height();
|
|
|
|
int h = bounds.height();
|
|
|
@ -392,6 +399,17 @@ class ImageHelper {
|
|
|
|
h = Math.round(h * scale);
|
|
|
|
h = Math.round(h * scale);
|
|
|
|
d.setBounds(0, 0, w, h);
|
|
|
|
d.setBounds(0, 0, w, h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
semaphore.release();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (!semaphore.tryAcquire(1500, TimeUnit.MILLISECONDS))
|
|
|
|
|
|
|
|
Log.e("fitDrawable failed");
|
|
|
|
|
|
|
|
} catch (InterruptedException ex) {
|
|
|
|
|
|
|
|
Log.w(ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static Drawable getDataDrawable(Context context, String source) {
|
|
|
|
private static Drawable getDataDrawable(Context context, String source) {
|
|
|
|