aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2016-09-03 22:13:06 +0200
committerChristian Schneppe <christian@pix-art.de>2016-09-03 22:13:06 +0200
commita309b764ec3fab32ae51023b0fdb62bed7ac2cb7 (patch)
treec00b1e49d023d600f29e97c77cdbd0374d3e317c /src/main/java/de/pixart
parent969ba03a74654c54decdd5e919da84d26a992ba9 (diff)
fix crash on take photo
Diffstat (limited to 'src/main/java/de/pixart')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationActivity.java44
1 files changed, 42 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
index 00baaa6a4..5217d1be2 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
@@ -110,6 +110,7 @@ public class ConversationActivity extends XmppActivity
private static final String STATE_PANEL_OPEN = "state_panel_open";
private static final String STATE_PENDING_URI = "state_pending_uri";
final private List<Uri> mPendingImageUris = new ArrayList<>();
+ final private List<Uri> mPendingPhotoUris = new ArrayList<>();
final private List<Uri> mPendingFileUris = new ArrayList<>();
final private List<Uri> mPendingVideoUris = new ArrayList<>();
private String mOpenConverstaion = null;
@@ -619,8 +620,8 @@ public class ConversationActivity extends XmppActivity
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
- mPendingImageUris.clear();
- mPendingImageUris.add(uri);
+ mPendingPhotoUris.clear();
+ mPendingPhotoUris.add(uri);
break;
case ATTACHMENT_CHOICE_CHOOSE_FILE:
chooser = true;
@@ -1298,6 +1299,8 @@ public class ConversationActivity extends XmppActivity
private void clearPending() {
mPendingImageUris.clear();
mPendingFileUris.clear();
+ mPendingVideoUris.clear();
+ mPendingPhotoUris.clear();
mPendingGeoUri = null;
mPostponedActivityResult = null;
}
@@ -1415,6 +1418,10 @@ public class ConversationActivity extends XmppActivity
}
}
+ for (Iterator<Uri> i = mPendingPhotoUris.iterator(); i.hasNext(); i.remove()) {
+ attachPhotoToConversation(getSelectedConversation(), i.next());
+ }
+
for (Iterator<Uri> i = mPendingVideoUris.iterator(); i.hasNext(); i.remove()) {
attachVideoToConversation(getSelectedConversation(), i.next());
}
@@ -1784,6 +1791,39 @@ public class ConversationActivity extends XmppActivity
});
}
+ private void attachPhotoToConversation(Conversation conversation, Uri uri) {
+ if (conversation == null) {
+ return;
+ }
+ final Toast prepareFileToast = Toast.makeText(getApplicationContext(),getText(R.string.preparing_image), Toast.LENGTH_LONG);
+ prepareFileToast.show();
+ xmppConnectionService.attachImageToConversation(conversation, uri,
+ new UiCallback<Message>() {
+
+ @Override
+ public void userInputRequried(PendingIntent pi, Message object) {
+ hidePrepareFileToast(prepareFileToast);
+ }
+
+ @Override
+ public void success(Message message) {
+ hidePrepareFileToast(prepareFileToast);
+ xmppConnectionService.sendMessage(message);
+ }
+
+ @Override
+ public void error(final int error, Message message) {
+ hidePrepareFileToast(prepareFileToast);
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ replaceToast(getString(error));
+ }
+ });
+ }
+ });
+ }
+
private void attachImagesToConversation(Conversation conversation, Uri uri) {
if (conversation == null) {
return;