mirror of https://github.com/M66B/FairEmail.git
Added fit drawable warning
This commit is contained in:
parent
3249068a8a
commit
48c3207a76
|
@ -63,6 +63,7 @@ import java.net.URLDecoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Semaphore;
|
import java.util.concurrent.Semaphore;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -73,7 +74,8 @@ class ImageHelper {
|
||||||
|
|
||||||
private static final int DOWNLOAD_TIMEOUT = 15 * 1000; // milliseconds
|
private static final int DOWNLOAD_TIMEOUT = 15 * 1000; // milliseconds
|
||||||
private static final int MAX_REDIRECTS = 10;
|
private static final int MAX_REDIRECTS = 10;
|
||||||
private static final long FIT_DRAWABLE_TIMEOUT = 10 * 1000L; // milliseconds
|
private static final long FIT_DRAWABLE_WARNING = 10 * 1000L; // milliseconds
|
||||||
|
private static final long FIT_DRAWABLE_TIMEOUT = 20 * 1000L; // milliseconds
|
||||||
|
|
||||||
static Bitmap generateIdenticon(@NonNull String email, int size, int pixels, Context context) {
|
static Bitmap generateIdenticon(@NonNull String email, int size, int pixels, Context context) {
|
||||||
byte[] hash = getHash(email);
|
byte[] hash = getHash(email);
|
||||||
|
@ -393,6 +395,8 @@ class ImageHelper {
|
||||||
private static void fitDrawable(final Drawable d, final AnnotatedSource a, final View view) {
|
private static void fitDrawable(final Drawable d, final AnnotatedSource a, final View view) {
|
||||||
Semaphore semaphore = new Semaphore(0);
|
Semaphore semaphore = new Semaphore(0);
|
||||||
|
|
||||||
|
long start = new Date().getTime();
|
||||||
|
|
||||||
view.post(new Runnable() {
|
view.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -424,7 +428,11 @@ class ImageHelper {
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!semaphore.tryAcquire(FIT_DRAWABLE_TIMEOUT, TimeUnit.MILLISECONDS))
|
if (semaphore.tryAcquire(FIT_DRAWABLE_TIMEOUT, TimeUnit.MILLISECONDS)) {
|
||||||
|
long elapsed = new Date().getTime() - start;
|
||||||
|
if (elapsed > FIT_DRAWABLE_WARNING)
|
||||||
|
Log.e("fitDrawable failed elapsed=" + elapsed);
|
||||||
|
} else
|
||||||
Log.e("fitDrawable failed timeout=" + FIT_DRAWABLE_TIMEOUT);
|
Log.e("fitDrawable failed timeout=" + FIT_DRAWABLE_TIMEOUT);
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
Log.w(ex);
|
Log.w(ex);
|
||||||
|
|
Loading…
Reference in New Issue