refresh ui after device list update only if list has changed

This commit is contained in:
Daniel Gultsch 2018-10-03 11:53:02 +02:00
parent b2cbd60f94
commit 7fa8811f64
3 changed files with 13 additions and 6 deletions

View File

@ -483,9 +483,18 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
publishOwnDeviceId(deviceIds); publishOwnDeviceId(deviceIds);
} }
} }
final Set<Integer> oldSet = this.deviceIds.get(jid);
final boolean changed = oldSet == null || oldSet.hashCode() != hash;
this.deviceIds.put(jid, deviceIds); this.deviceIds.put(jid, deviceIds);
mXmppConnectionService.updateConversationUi(); //update the lock icon if (changed) {
mXmppConnectionService.keyStatusUpdated(null); 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() { public void wipeOtherPepDevices() {

View File

@ -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... "); Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account) + "Received PEP device list " + deviceIds + " update from " + from + ", processing... ");
AxolotlService axolotlService = account.getAxolotlService(); AxolotlService axolotlService = account.getAxolotlService();
axolotlService.registerDevices(from, deviceIds); axolotlService.registerDevices(from, deviceIds);
mXmppConnectionService.updateAccountUi();
} else if (Namespace.BOOKMARKS.equals(node)) { } else if (Namespace.BOOKMARKS.equals(node)) {
Log.d(Config.LOGTAG,"received bookmarks from "+from); Log.d(Config.LOGTAG,"received bookmarks from "+from);
if (account.getJid().asBareJid().equals(from)) { if (account.getJid().asBareJid().equals(from)) {

View File

@ -1110,13 +1110,13 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
@Override @Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) { public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
assert (0 <= position && position < fragments.length);
FragmentTransaction trans = fragmentManager.beginTransaction(); FragmentTransaction trans = fragmentManager.beginTransaction();
trans.remove(fragments[position]); trans.remove(fragments[position]);
trans.commit(); trans.commit();
fragments[position] = null; fragments[position] = null;
} }
@NonNull
@Override @Override
public Fragment instantiateItem(@NonNull ViewGroup container, int position) { public Fragment instantiateItem(@NonNull ViewGroup container, int position) {
Fragment fragment = getItem(position); Fragment fragment = getItem(position);
@ -1149,8 +1149,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
} }
} }
public Fragment getItem(int position) { Fragment getItem(int position) {
assert (0 <= position && position < fragments.length);
if (fragments[position] == null) { if (fragments[position] == null) {
final MyListFragment listFragment = new MyListFragment(); final MyListFragment listFragment = new MyListFragment();
if (position == 1) { if (position == 1) {