From 7fa8811f644b4cb7bd611b0a60bc926c7caee690 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 3 Oct 2018 11:53:02 +0200 Subject: [PATCH] refresh ui after device list update only if list has changed --- .../crypto/axolotl/AxolotlService.java | 13 +++++++++++-- .../siacs/conversations/parser/MessageParser.java | 1 - .../conversations/ui/StartConversationActivity.java | 5 ++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java index 99353ed30..93626e634 100644 --- a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java +++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java @@ -483,9 +483,18 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded { publishOwnDeviceId(deviceIds); } } + final Set oldSet = this.deviceIds.get(jid); + final boolean changed = oldSet == null || oldSet.hashCode() != hash; this.deviceIds.put(jid, deviceIds); - mXmppConnectionService.updateConversationUi(); //update the lock icon - mXmppConnectionService.keyStatusUpdated(null); + if (changed) { + mXmppConnectionService.updateConversationUi(); //update the lock icon + mXmppConnectionService.keyStatusUpdated(null); + if (me) { + mXmppConnectionService.updateAccountUi(); + } + } else { + Log.d(Config.LOGTAG,"skipped device list update because it hasn't changed"); + } } public void wipeOtherPepDevices() { diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index 621ea7276..9b2636703 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -211,7 +211,6 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account) + "Received PEP device list " + deviceIds + " update from " + from + ", processing... "); AxolotlService axolotlService = account.getAxolotlService(); axolotlService.registerDevices(from, deviceIds); - mXmppConnectionService.updateAccountUi(); } else if (Namespace.BOOKMARKS.equals(node)) { Log.d(Config.LOGTAG,"received bookmarks from "+from); if (account.getJid().asBareJid().equals(from)) { diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index d5f09b86c..9b148f131 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -1110,13 +1110,13 @@ public class StartConversationActivity extends XmppActivity implements XmppConne @Override public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) { - assert (0 <= position && position < fragments.length); FragmentTransaction trans = fragmentManager.beginTransaction(); trans.remove(fragments[position]); trans.commit(); fragments[position] = null; } + @NonNull @Override public Fragment instantiateItem(@NonNull ViewGroup container, int position) { Fragment fragment = getItem(position); @@ -1149,8 +1149,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne } } - public Fragment getItem(int position) { - assert (0 <= position && position < fragments.length); + Fragment getItem(int position) { if (fragments[position] == null) { final MyListFragment listFragment = new MyListFragment(); if (position == 1) {