prevent null pointer when checking http upload max size

Daniel Gultsch created

Change summary

src/main/java/eu/siacs/conversations/ui/ConversationActivity.java | 12 
1 file changed, 6 insertions(+), 6 deletions(-)

Detailed changes

src/main/java/eu/siacs/conversations/ui/ConversationActivity.java 🔗

@@ -1301,10 +1301,6 @@ public class ConversationActivity extends XmppActivity
 			} else if (requestCode == ATTACHMENT_CHOICE_CHOOSE_FILE || requestCode == ATTACHMENT_CHOICE_RECORD_VOICE) {
 				final List<Uri> uris = extractUriFromIntent(data);
 				final Conversation c = getSelectedConversation();
-				final long max = c.getAccount()
-						.getXmppConnection()
-						.getFeatures()
-						.getMaxHttpUploadSize();
 				final OnPresenceSelected callback = new OnPresenceSelected() {
 					@Override
 					public void onPresenceSelected() {
@@ -1317,8 +1313,8 @@ public class ConversationActivity extends XmppActivity
 						}
 					}
 				};
-				if (c.getMode() == Conversation.MODE_MULTI
-						|| FileBackend.allFilesUnderSize(this, uris, max)
+				if (c == null || c.getMode() == Conversation.MODE_MULTI
+						|| FileBackend.allFilesUnderSize(this, uris, getMaxHttpUploadSize(c))
 						|| c.getNextEncryption() == Message.ENCRYPTION_OTR) {
 					callback.onPresenceSelected();
 				} else {
@@ -1367,6 +1363,10 @@ public class ConversationActivity extends XmppActivity
 		}
 	}
 
+	private long getMaxHttpUploadSize(Conversation conversation) {
+		return conversation.getAccount().getXmppConnection().getFeatures().getMaxHttpUploadSize();
+	}
+
 	private void setNeverAskForBatteryOptimizationsAgain() {
 		getPreferences().edit().putBoolean("show_battery_optimization", false).commit();
 	}