fix very rare NPE (race condition)

This commit is contained in:
Daniel Gultsch 2022-08-30 08:21:32 +02:00
parent 8f76084a43
commit 3fac7d4992
2 changed files with 20 additions and 13 deletions

View file

@ -102,18 +102,25 @@ public class PublishProfilePictureActivity extends XmppActivity implements XmppC
xmppConnectionService.publishAvatar(account, avatarUri, this); xmppConnectionService.publishAvatar(account, avatarUri, this);
} }
}); });
this.cancelButton.setOnClickListener(v -> { this.cancelButton.setOnClickListener(
if (mInitialAccountSetup) { v -> {
final Intent intent = new Intent(getApplicationContext(), StartConversationActivity.class); if (mInitialAccountSetup) {
if (xmppConnectionService != null && xmppConnectionService.getAccounts().size() == 1) { final Intent intent =
intent.putExtra("init", true); new Intent(
} getApplicationContext(), StartConversationActivity.class);
StartConversationActivity.addInviteUri(intent, getIntent()); if (xmppConnectionService != null
intent.putExtra(EXTRA_ACCOUNT, account.getJid().asBareJid().toEscapedString()); && xmppConnectionService.getAccounts().size() == 1) {
startActivity(intent); intent.putExtra("init", true);
} }
finish(); StartConversationActivity.addInviteUri(intent, getIntent());
}); if (account != null) {
intent.putExtra(
EXTRA_ACCOUNT, account.getJid().asBareJid().toEscapedString());
}
startActivity(intent);
}
finish();
});
this.avatar.setOnClickListener(v -> chooseAvatar(this)); this.avatar.setOnClickListener(v -> chooseAvatar(this));
this.defaultUri = PhoneHelper.getProfilePictureUri(getApplicationContext()); this.defaultUri = PhoneHelper.getProfilePictureUri(getApplicationContext());
if (savedInstanceState != null) { if (savedInstanceState != null) {

View file

@ -1080,7 +1080,7 @@ public class XmppConnection implements Runnable {
tagWriter.writeElement(authenticate); tagWriter.writeElement(authenticate);
} }
private List<String> extractMechanisms(final Element stream) { private static List<String> extractMechanisms(final Element stream) {
final ArrayList<String> mechanisms = new ArrayList<>(stream final ArrayList<String> mechanisms = new ArrayList<>(stream
.getChildren().size()); .getChildren().size());
for (final Element child : stream.getChildren()) { for (final Element child : stream.getChildren()) {