Be more explicit with running on main thread

// FREEBIE
This commit is contained in:
Moxie Marlinspike 2017-10-04 14:56:31 -07:00
parent 99b2149deb
commit 42f613e722
4 changed files with 19 additions and 28 deletions

View File

@ -1262,9 +1262,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
@Override
public void onModified(final Recipient recipient) {
titleView.post(new Runnable() {
@Override
public void run() {
Util.runOnMain(() -> {
titleView.setTitle(recipient);
titleView.setVerified(identityRecords.isVerified());
setBlockedUserState(recipient, isSecureText, isDefaultSms);
@ -1274,7 +1272,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
updateDefaultSubscriptionId(recipient.getDefaultSubscriptionId());
initializeSecurity(isSecureText, isDefaultSms);
invalidateOptionsMenu();
}
});
}

View File

@ -69,6 +69,7 @@ import org.thoughtcrime.securesms.sms.OutgoingTextMessage;
import org.thoughtcrime.securesms.util.SaveAttachmentTask;
import org.thoughtcrime.securesms.util.SaveAttachmentTask.Attachment;
import org.thoughtcrime.securesms.util.StickyHeaderDecoration;
import org.thoughtcrime.securesms.util.Util;
import org.thoughtcrime.securesms.util.ViewUtil;
import org.thoughtcrime.securesms.util.task.ProgressDialogAsyncTask;
@ -491,12 +492,7 @@ public class ConversationFragment extends Fragment
private void scrollToLastSeenPosition(final int lastSeenPosition) {
if (lastSeenPosition > 0) {
list.post(new Runnable() {
@Override
public void run() {
((LinearLayoutManager)list.getLayoutManager()).scrollToPositionWithOffset(lastSeenPosition, list.getHeight());
}
});
Util.runOnMain(() -> ((LinearLayoutManager)list.getLayoutManager()).scrollToPositionWithOffset(lastSeenPosition, list.getHeight()));
}
}

View File

@ -223,7 +223,7 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity
}
expiresContainer.setVisibility(View.VISIBLE);
expiresInText.post(new Runnable() {
Util.runOnMain(new Runnable() {
@Override
public void run() {
long elapsed = System.currentTimeMillis() - messageRecord.getExpireStarted();
@ -233,7 +233,7 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity
expiresInText.setText(duration);
if (running) {
expiresInText.postDelayed(this, 500);
Util.runOnMainDelayed(this, 500);
}
}
});

View File

@ -29,6 +29,7 @@ import org.thoughtcrime.securesms.scribbles.widget.entity.ImageEntity;
import org.thoughtcrime.securesms.scribbles.widget.entity.MotionEntity;
import org.thoughtcrime.securesms.scribbles.widget.entity.TextEntity;
import org.thoughtcrime.securesms.util.MediaUtil;
import org.thoughtcrime.securesms.util.Util;
import org.thoughtcrime.securesms.util.concurrent.ListenableFuture;
import java.io.ByteArrayOutputStream;
@ -74,14 +75,11 @@ public class ScribbleActivity extends PassphraseRequiredActionBarActivity implem
}
private void addSticker(final Bitmap pica) {
scribbleView.post(new Runnable() {
@Override
public void run() {
Util.runOnMain(() -> {
Layer layer = new Layer();
ImageEntity entity = new ImageEntity(layer, pica, scribbleView.getWidth(), scribbleView.getHeight());
scribbleView.addEntityAndPosition(entity);
}
});
}