diff options
Diffstat (limited to 'src/main')
3 files changed, 33 insertions, 4 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index c2e2902ac..7e07d251b 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -1080,7 +1080,11 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke private void handleNegativeActivityResult(int requestCode) { switch (requestCode) { - //nothing to do for now + case ATTACHMENT_CHOICE_TAKE_PHOTO: + if (pendingTakePhotoUri.clear()) { + Log.d(Config.LOGTAG, "cleared pending photo uri after negative activity result"); + } + break; } } @@ -2013,6 +2017,15 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } @Override + public void startActivityForResult(Intent intent, int requestCode) { + final Activity activity = getActivity(); + if (activity instanceof ConversationsActivity) { + ((ConversationsActivity) activity).clearPendingViewIntent(); + } + super.startActivityForResult(intent, requestCode); + } + + @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (conversation != null) { @@ -2123,6 +2136,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke public void reInit(Conversation conversation, Bundle extras) { QuickLoader.set(conversation.getUuid()); this.saveMessageDraftStopAudioPlayer(); + this.clearPending(); if (this.reInit(conversation, extras != null)) { if (extras != null) { processExtras(extras); @@ -3055,11 +3069,13 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } private void clearPending() { - if (postponedActivityResult.pop() != null) { + if (postponedActivityResult.clear()) { Log.e(Config.LOGTAG, "cleared pending intent with unhandled result left"); } - pendingScrollState.pop(); - if (pendingTakePhotoUri.pop() != null) { + if (pendingScrollState.clear()) { + Log.e(Config.LOGTAG,"cleared scroll state"); + } + if (pendingTakePhotoUri.clear()) { Log.e(Config.LOGTAG, "cleared pending photo uri"); } } diff --git a/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java index 05cfe3ab4..8d8e5386a 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java @@ -490,6 +490,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio @Override public void onConversationSelected(Conversation conversation) { + clearPendingViewIntent(); if (ConversationFragment.getConversation(this) == conversation) { Log.d(Config.LOGTAG, "ignore onConversationSelected() because conversation is already open"); return; @@ -497,6 +498,12 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio openConversation(conversation, null); } + public void clearPendingViewIntent() { + if (pendingViewIntent.clear()) { + Log.e(Config.LOGTAG, "cleared pending view intent"); + } + } + private void displayToast(final String msg) { runOnUiThread(() -> Toast.makeText(ConversationsActivity.this, msg, Toast.LENGTH_SHORT).show()); } diff --git a/src/main/java/de/pixart/messenger/ui/util/PendingItem.java b/src/main/java/de/pixart/messenger/ui/util/PendingItem.java index eaddf3a8c..d06f5bfc9 100644 --- a/src/main/java/de/pixart/messenger/ui/util/PendingItem.java +++ b/src/main/java/de/pixart/messenger/ui/util/PendingItem.java @@ -46,4 +46,10 @@ public class PendingItem<T> { public synchronized T peek() { return item; } + + public synchronized boolean clear() { + boolean notNull = this.item != null; + this.item = null; + return notNull; + } }
\ No newline at end of file |