Commit f2e8ba00 authored by Yusuke Iwaki's avatar Yusuke Iwaki

fix NPE

parent 3f049ecb
......@@ -13,21 +13,21 @@ public enum MessageType {
@Override
public String getString(Context context, Message message) {
return context.getString(R.string.message_room_name_changed,
message.getMessage(), message.getUser().getUsername());
message.getMessage(), getUsername(message));
}
},
USER_ADDED("au") {
@Override
public String getString(Context context, Message message) {
return context.getString(R.string.message_user_added_by,
message.getMessage(), message.getUser().getUsername());
message.getMessage(), getUsername(message));
}
},
USER_REMOVED("ru") {
@Override
public String getString(Context context, Message message) {
return context.getString(R.string.message_user_removed_by,
message.getMessage(), message.getUser().getUsername());
message.getMessage(), getUsername(message));
}
},
USER_JOINED("uj") {
......@@ -45,7 +45,7 @@ public enum MessageType {
WELCOME("wm") {
@Override
public String getString(Context context, Message message) {
return context.getString(R.string.message_welcome, message.getUser().getUsername());
return context.getString(R.string.message_welcome, getUsername(message));
}
},
MESSAGE_REMOVED("rm") {
......@@ -77,4 +77,12 @@ public enum MessageType {
public String getString(Context context, Message message) {
return "";
}
private static String getUsername(Message message) {
if (message != null && message.getUser() != null) {
return message.getUser().getUsername();
} else {
return "";
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment