diff options
author | Christian Schneppe <christian@pix-art.de> | 2019-06-17 21:30:07 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2019-06-17 21:30:07 +0200 |
commit | 19d75a0e1c2a17f691bce1e461d8c52b7ea06434 (patch) | |
tree | 1eda7cfb2703259c5026c9068334f8ab2a5c8414 /src/main/java/de/pixart/messenger/ui | |
parent | f15a0b055045d7fa3dc824be729981e05d776716 (diff) |
handle some rare npe
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/util/SendButtonAction.java | 5 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/util/SendButtonTool.java | 13 |
2 files changed, 12 insertions, 6 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/util/SendButtonAction.java b/src/main/java/de/pixart/messenger/ui/util/SendButtonAction.java index 825ca3f17..00e82fd92 100644 --- a/src/main/java/de/pixart/messenger/ui/util/SendButtonAction.java +++ b/src/main/java/de/pixart/messenger/ui/util/SendButtonAction.java @@ -39,7 +39,10 @@ import static de.pixart.messenger.ui.ConversationFragment.ATTACHMENT_CHOICE_TAKE public enum SendButtonAction { TEXT, TAKE_PHOTO, SEND_LOCATION, RECORD_VOICE, CANCEL, CHOOSE_PICTURE, RECORD_VIDEO, CHOOSE_ATTACHMENT; - public static SendButtonAction valueOfOrDefault(String setting, SendButtonAction text) { + public static SendButtonAction valueOfOrDefault(final String setting) { + if (setting == null) { + return TEXT; + } try { return valueOf(setting); } catch (IllegalArgumentException e) { diff --git a/src/main/java/de/pixart/messenger/ui/util/SendButtonTool.java b/src/main/java/de/pixart/messenger/ui/util/SendButtonTool.java index 96bcad183..2c9307323 100644 --- a/src/main/java/de/pixart/messenger/ui/util/SendButtonTool.java +++ b/src/main/java/de/pixart/messenger/ui/util/SendButtonTool.java @@ -43,7 +43,10 @@ import de.pixart.messenger.utils.UIHelper; public class SendButtonTool { - public static SendButtonAction getAction(Activity activity, Conversation c, String text) { + public static SendButtonAction getAction(final Activity activity, final Conversation c, final String text) { + if (activity == null) { + return SendButtonAction.TEXT; + } final boolean empty = text.length() == 0; final boolean conference = c.getMode() == Conversation.MODE_MULTI; if (c.getCorrectingMessage() != null && (empty || text.equals(c.getCorrectingMessage().getBody()))) { @@ -66,14 +69,14 @@ public class SendButtonTool { } else if (quickShareChoice(activity) && !AttachmentsVisible(c)) { return SendButtonAction.TEXT; } else { - if (!setting.equals("none") && UIHelper.receivedLocationQuestion(c.getLatestMessage())) { + if (!"none".equals(setting) && UIHelper.receivedLocationQuestion(c.getLatestMessage())) { return SendButtonAction.SEND_LOCATION; } else { - if (setting.equals("recent")) { + if ("recent".equals(setting)) { setting = preferences.getString(ConversationFragment.RECENTLY_USED_QUICK_ACTION, SendButtonAction.TEXT.toString()); - return SendButtonAction.valueOfOrDefault(setting, SendButtonAction.TEXT); + return SendButtonAction.valueOfOrDefault(setting); } else { - return SendButtonAction.valueOfOrDefault(setting, SendButtonAction.TEXT); + return SendButtonAction.valueOfOrDefault(setting); } } } |