Refactoring

pull/162/head
M66B 6 years ago
parent 96d557f68d
commit d0b02d85ed

@ -1428,10 +1428,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
args.putBoolean("show_quotes", show_quotes);
args.putInt("zoom", zoom);
// Run task after measure
new Handler().post(new Runnable() {
@Override
public void run() {
new SimpleTask<Object>() {
@Override
protected Object onExecute(final Context context, final Bundle args) throws IOException {
@ -1599,8 +1595,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
}.execute(context, owner, args, "message:body");
}
});
}
private void bindAttachments(final TupleMessageEx message, @Nullable List<EntityAttachment> attachments) {
if (attachments == null)

@ -58,6 +58,8 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
class ImageHelper {
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();
int w = bounds.width();
int h = bounds.height();
@ -392,6 +399,17 @@ class ImageHelper {
h = Math.round(h * scale);
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) {

Loading…
Cancel
Save