slight refactoring in MessageAdapter

This commit is contained in:
Daniel Gultsch 2017-09-27 10:21:00 +02:00
parent a95fe08780
commit acd4b149f5

View file

@ -108,7 +108,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
} }
}; };
private ConversationActivity activity; private final ConversationActivity activity;
private DisplayMetrics metrics; private DisplayMetrics metrics;
@ -669,8 +669,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
viewHolder.load_more_messages = (Button) view.findViewById(R.id.load_more_messages); viewHolder.load_more_messages = (Button) view.findViewById(R.id.load_more_messages);
break; break;
default: default:
viewHolder = null; throw new AssertionError("Unknown view type");
break;
} }
if (viewHolder.messageBody != null) { if (viewHolder.messageBody != null) {
listSelectionManager.onCreate(viewHolder.messageBody, listSelectionManager.onCreate(viewHolder.messageBody,
@ -790,16 +789,13 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
} }
} else { } else {
displayInfoMessage(viewHolder,activity.getString(R.string.install_openkeychain),darkBackground); displayInfoMessage(viewHolder,activity.getString(R.string.install_openkeychain),darkBackground);
if (viewHolder != null) { viewHolder.message_box.setOnClickListener(new OnClickListener() {
viewHolder.message_box
.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
activity.showInstallPgpDialog(); activity.showInstallPgpDialog();
} }
}); });
}
} }
} else if (message.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) { } else if (message.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) {
displayDecryptionFailed(viewHolder,darkBackground); displayDecryptionFailed(viewHolder,darkBackground);