diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-03-24 23:04:13 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-03-24 23:04:13 +0100 |
commit | 134c299ab23fe94af9581f8f3ef13a3c8d0c1f25 (patch) | |
tree | a96ad4618aa522fd8f4573ee0283c048fff0a0c9 /src/main/java | |
parent | 4c109297087f194e34a3e86b18285112fbec33fc (diff) |
made refresh work
Diffstat (limited to 'src/main/java')
3 files changed, 37 insertions, 17 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java index 27512a3d1..cb3356c82 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java @@ -942,7 +942,7 @@ public class ConversationActivity extends XmppActivity if (getSelectedConversation() == null) { reInitLatestConversation(); } else { - ConversationActivity.this.mConversationFragment.updateMessages(); + ConversationActivity.this.mConversationFragment.refresh(); updateActionBarTitle(); invalidateOptionsMenu(); } diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 710c8d4cc..37924a0ea 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -1488,7 +1488,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke this.activity.onConversationArchived(conversation); } else { activity.onConversationsListItemUpdated(); - updateMessages(); + refresh(); } }); builder.create().show(); @@ -1633,7 +1633,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke if (activity.xmppConnectionService.getFileBackend().deleteFile(message)) { message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED)); activity.onConversationsListItemUpdated(); - updateMessages(); + refresh(); } } @@ -1656,7 +1656,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke Toast.makeText(activity, R.string.file_deleted, Toast.LENGTH_SHORT).show(); message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED)); activity.onConversationsListItemUpdated(); - updateMessages(); + refresh(); return; } } @@ -1701,7 +1701,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke private void retryDecryption(Message message) { message.setEncryption(Message.ENCRYPTION_PGP); activity.onConversationsListItemUpdated(); - updateMessages(); + refresh(); conversation.getAccount().getPgpDecryptionService().decrypt(message, false); } @@ -1847,7 +1847,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke activity.onBackPressed(); } }); - updateMessages(); + refresh(); this.conversation.messagesLoaded.set(true); synchronized (this.messageList) { final Message first = conversation.getFirstUnreadMessage(); @@ -1990,11 +1990,9 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } } - public void updateMessages() { + @Override + public void refresh() { synchronized (this.messageList) { - if (getView() == null) { - return; - } if (this.conversation != null) { conversation.populateWithMessages(ConversationFragment.this.messageList); updateSnackBar(conversation); @@ -2550,11 +2548,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } } - @Override - void refresh() { - - } - public void clearPending() { if (postponedActivityResult.pop() != null) { Log.d(Config.LOGTAG, "cleared pending intent with unhandled result left"); diff --git a/src/main/java/de/pixart/messenger/ui/ConversationsMainActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationsMainActivity.java index 9d2f491d8..57b2e8948 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationsMainActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationsMainActivity.java @@ -51,14 +51,17 @@ import de.pixart.messenger.R; import de.pixart.messenger.databinding.ActivityConversationsBinding; import de.pixart.messenger.entities.Conversation; import de.pixart.messenger.services.EmojiService; +import de.pixart.messenger.services.XmppConnectionService; import de.pixart.messenger.ui.interfaces.OnConversationArchived; import de.pixart.messenger.ui.interfaces.OnConversationRead; import de.pixart.messenger.ui.interfaces.OnConversationSelected; import de.pixart.messenger.ui.interfaces.OnConversationsListItemUpdated; +import de.pixart.messenger.xmpp.OnUpdateBlocklist; import static de.pixart.messenger.ui.SettingsActivity.USE_BUNDLED_EMOJIS; -public class ConversationsMainActivity extends XmppActivity implements OnConversationSelected, OnConversationArchived, OnConversationsListItemUpdated, OnConversationRead { +public class ConversationsMainActivity extends XmppActivity implements OnConversationSelected, OnConversationArchived, OnConversationsListItemUpdated, OnConversationRead, XmppConnectionService.OnAccountUpdate, XmppConnectionService.OnConversationUpdate, XmppConnectionService.OnRosterUpdate, OnUpdateBlocklist, XmppConnectionService.OnShowErrorToast { + //secondary fragment (when holding the conversation, must be initialized before refreshing the overview fragment private static final @IdRes @@ -182,7 +185,6 @@ public class ConversationsMainActivity extends XmppActivity implements OnConvers transaction.replace(R.id.main_fragment, new ConversationsOverviewFragment()); } - //TODO, do this in backendConnected so we can actually decide what to display if (binding.secondaryFragment != null) { transaction.replace(R.id.secondary_fragment, new ConversationFragment()); } @@ -262,4 +264,29 @@ public class ConversationsMainActivity extends XmppActivity implements OnConvers public void onConversationRead(Conversation conversation) { Log.d(Config.LOGTAG, "read event for " + conversation.getName() + " received"); } + + @Override + public void onAccountUpdate() { + this.refreshUi(); + } + + @Override + public void onConversationUpdate() { + this.refreshUi(); + } + + @Override + public void onRosterUpdate() { + this.refreshUi(); + } + + @Override + public void OnUpdateBlocklist(OnUpdateBlocklist.Status status) { + this.refreshUi(); + } + + @Override + public void onShowErrorToast(int resId) { + runOnUiThread(() -> Toast.makeText(this, resId, Toast.LENGTH_SHORT).show()); + } }
\ No newline at end of file |