mirror of https://github.com/M66B/FairEmail.git
Cleanup
This commit is contained in:
parent
c6d38bf032
commit
3249068a8a
|
@ -39,7 +39,6 @@ import android.graphics.drawable.Drawable;
|
|||
import android.graphics.drawable.LevelListDrawable;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Base64;
|
||||
import android.util.DisplayMetrics;
|
||||
|
@ -392,30 +391,11 @@ class ImageHelper {
|
|||
}
|
||||
|
||||
private static void fitDrawable(final Drawable d, final AnnotatedSource a, final View view) {
|
||||
if (Looper.getMainLooper().getThread() == Thread.currentThread()) {
|
||||
Log.w("fitDrawable UI thread");
|
||||
_fitDrawble(d, a, view);
|
||||
} else {
|
||||
Semaphore semaphore = new Semaphore(0);
|
||||
|
||||
view.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
_fitDrawble(d, a, view);
|
||||
semaphore.release();
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
if (!semaphore.tryAcquire(FIT_DRAWABLE_TIMEOUT, TimeUnit.MILLISECONDS))
|
||||
Log.e("fitDrawable failed timeout=" + FIT_DRAWABLE_TIMEOUT);
|
||||
} catch (InterruptedException ex) {
|
||||
Log.w(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void _fitDrawble(Drawable d, AnnotatedSource a, View view) {
|
||||
Rect bounds = d.getBounds();
|
||||
int w = bounds.width();
|
||||
int h = bounds.height();
|
||||
|
@ -438,6 +418,17 @@ class ImageHelper {
|
|||
h = Math.round(h * scale);
|
||||
d.setBounds(0, 0, w, h);
|
||||
}
|
||||
|
||||
semaphore.release();
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
if (!semaphore.tryAcquire(FIT_DRAWABLE_TIMEOUT, TimeUnit.MILLISECONDS))
|
||||
Log.e("fitDrawable failed timeout=" + FIT_DRAWABLE_TIMEOUT);
|
||||
} catch (InterruptedException ex) {
|
||||
Log.w(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static Drawable getDataDrawable(Context context, String source) {
|
||||
|
|
Loading…
Reference in New Issue