diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-03-09 20:01:20 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-03-09 20:01:20 +0100 |
commit | 5b41c0da43d7c2f18fd96aa81cd70ffe8f5970f6 (patch) | |
tree | 1dc6659b8bfd15416b2b88958e1f588c51ffc4f4 /src/main/java/de/pixart/messenger/ui/ConversationActivity.java | |
parent | cc7c118cc5c43aa7a3ebf49198b540e519fee0d6 (diff) |
closing the corresponding conversations after blocking a contact
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui/ConversationActivity.java')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConversationActivity.java | 72 |
1 files changed, 46 insertions, 26 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java index e8d61d1df..d60fbcbe4 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java @@ -837,10 +837,10 @@ public class ConversationActivity extends XmppActivity clearHistoryDialog(getSelectedConversation()); break; case R.id.action_block: - BlockContactDialog.show(this, xmppConnectionService, getSelectedConversation()); + BlockContactDialog.show(this, getSelectedConversation()); break; case R.id.action_unblock: - BlockContactDialog.show(this, xmppConnectionService, getSelectedConversation()); + BlockContactDialog.show(this, getSelectedConversation()); break; default: break; @@ -1281,6 +1281,18 @@ public class ConversationActivity extends XmppActivity mPostponedActivityResult = null; } + private void redirectToStartConversationActivity() { + Account pendingAccount = xmppConnectionService.getPendingAccount(); + if (pendingAccount == null) { + Intent startConversationActivity = new Intent(this, StartConversationActivity.class); + startConversationActivity.putExtra("init", true); + startActivity(startConversationActivity); + } else { + switchToAccount(pendingAccount, true); + } + finish(); + } + @Override void onBackendConnected() { this.xmppConnectionService.getNotificationService().setIsInForeground(true); @@ -1338,15 +1350,7 @@ public class ConversationActivity extends XmppActivity } } else if (conversationList.size() <= 0) { if (mRedirected.compareAndSet(false, true)) { - Account pendingAccount = xmppConnectionService.getPendingAccount(); - if (pendingAccount == null) { - Intent startConversationActivity = new Intent(this, StartConversationActivity.class); - intent.putExtra("init", true); - startActivity(startConversationActivity); - } else { - switchToAccount(pendingAccount, true); - } - finish(); + redirectToStartConversationActivity(); } } else if (selectConversationByUuid(mOpenConversation)) { if (mPanelOpen) { @@ -1367,10 +1371,7 @@ public class ConversationActivity extends XmppActivity handleViewConversationIntent(intent); intent.setAction(Intent.ACTION_MAIN); } else if (getSelectedConversation() == null) { - showConversationsOverview(); - clearPending(); - setSelectedConversation(conversationList.get(0)); - this.mConversationFragment.reInit(getSelectedConversation()); + reInitLatestConversation(); } else { this.mConversationFragment.messageListAdapter.updatePreferences(); this.mConversationFragment.messagesView.invalidateViews(); @@ -1388,12 +1389,7 @@ public class ConversationActivity extends XmppActivity this.onActivityResult(mPostponedActivityResult.first, RESULT_OK, mPostponedActivityResult.second); } - final boolean stopping; - if (Build.VERSION.SDK_INT >= 17) { - stopping = isFinishing() || isDestroyed(); - } else { - stopping = isFinishing(); - } + final boolean stopping = isStopping(); if (!forbidProcessingPendings) { int ImageUrisCount = mPendingImageUris.size(); @@ -1436,6 +1432,21 @@ public class ConversationActivity extends XmppActivity } } + private boolean isStopping() { + if (Build.VERSION.SDK_INT >= 17) { + return isFinishing() || isDestroyed(); + } else { + return isFinishing(); + } + } + + private void reInitLatestConversation() { + showConversationsOverview(); + clearPending(); + setSelectedConversation(conversationList.get(0)); + this.mConversationFragment.reInit(getSelectedConversation()); + } + private void handleViewConversationIntent(final Intent intent) { final String uuid = intent.getStringExtra(CONVERSATION); final String downloadUuid = intent.getStringExtra(EXTRA_DOWNLOAD_UUID); @@ -1939,8 +1950,10 @@ public class ConversationActivity extends XmppActivity } public void updateConversationList() { - xmppConnectionService - .populateWithOrderedConversations(conversationList); + xmppConnectionService.populateWithOrderedConversations(conversationList); + if (!conversationList.contains(mSelectedConversation)) { + mSelectedConversation = null; + } if (swipedConversation != null) { if (swipedConversation.isRead()) { conversationList.remove(swipedConversation); @@ -2044,10 +2057,17 @@ public class ConversationActivity extends XmppActivity if (!this.mConversationFragment.isAdded()) { Log.d(Config.LOGTAG, "fragment NOT added to activity. detached=" + Boolean.toString(mConversationFragment.isDetached())); } - ConversationActivity.this.mConversationFragment.updateMessages(); - updateActionBarTitle(); - invalidateOptionsMenu(); + if (getSelectedConversation() == null) { + reInitLatestConversation(); + } else { + ConversationActivity.this.mConversationFragment.updateMessages(); + updateActionBarTitle(); + invalidateOptionsMenu(); + } } else { + if (!isStopping() && mRedirected.compareAndSet(false, true)) { + redirectToStartConversationActivity(); + } Log.d(Config.LOGTAG, "not updating conversations fragment because conversations list size was 0"); } } |