fix some more NPE

This commit is contained in:
Christian Schneppe 2019-02-22 17:25:32 +01:00
parent 2dba8c1d90
commit 9b4fcd7e1f
2 changed files with 22 additions and 15 deletions

View file

@ -625,10 +625,15 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
private void onEditYourNameClicked(View view) {
String nick;
if (mAccount.getDisplayName() != null) {
nick = mAccount.getDisplayName();
} else {
nick = mAccount.getJid().getLocal();
try {
if (mAccount.getDisplayName() != null) {
nick = mAccount.getDisplayName();
} else {
nick = mAccount.getJid().getLocal();
}
} catch (Exception e) {
e.printStackTrace();
nick = "";
}
quickEdit(nick, R.string.your_name, value -> {
final String displayName = value.trim();

View file

@ -264,15 +264,19 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
if (Message.ERROR_MESSAGE_CANCELLED.equals(errorMessage)) {
info = getContext().getString(R.string.cancelled);
} else {
final String[] errorParts = errorMessage.split("\\u001f", 2);
if (errorParts.length == 2) {
switch (errorParts[0]) {
case "file-too-large":
info = getContext().getString(R.string.file_too_large);
break;
default:
info = getContext().getString(R.string.send_failed);
break;
if (errorMessage != null) {
final String[] errorParts = errorMessage.split("\\u001f", 2);
if (errorParts.length == 2) {
switch (errorParts[0]) {
case "file-too-large":
info = getContext().getString(R.string.file_too_large);
break;
default:
info = getContext().getString(R.string.send_failed);
break;
}
} else {
info = getContext().getString(R.string.send_failed);
}
} else {
info = getContext().getString(R.string.send_failed);
@ -1091,9 +1095,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
if (type == SENT) {
viewHolder.message_box.setBackgroundResource(activity.isDarkTheme() ? R.drawable.message_bubble_sent_dark : R.drawable.message_bubble_sent);
}
displayStatus(viewHolder, message, type, darkBackground);
return view;
}