clear parent activities pending view intent before calling startAcitvityForResult()
This commit is contained in:
parent
febd9cc3e0
commit
b8474941c7
|
@ -902,7 +902,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1761,6 +1765,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);
|
||||
|
@ -1872,6 +1885,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);
|
||||
|
@ -2662,11 +2676,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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -418,6 +418,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;
|
||||
|
@ -425,6 +426,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());
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue