aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java30
-rw-r--r--src/main/java/de/pixart/messenger/ui/ShareWithActivity.java5
2 files changed, 30 insertions, 5 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index e123e8cff..43fd2f875 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -1852,10 +1852,23 @@ public class XmppConnectionService extends Service {
}
public void populateWithOrderedConversations(final List<Conversation> list) {
- populateWithOrderedConversations(list, true);
+ populateWithOrderedConversations(list, true, true);
}
- public void populateWithOrderedConversations(final List<Conversation> list, boolean includeNoFileUpload) {
+ public void populateWithOrderedConversations(final List<Conversation> list, final boolean includeNoFileUpload) {
+ populateWithOrderedConversations(list, includeNoFileUpload, true);
+ }
+
+ public void populateWithOrderedConversations(final List<Conversation> list, final boolean includeNoFileUpload, final boolean sort) {
+ final List<String> orderedUuids;
+ if (sort) {
+ orderedUuids = null;
+ } else {
+ orderedUuids = new ArrayList<>();
+ for (Conversation conversation : list) {
+ orderedUuids.add(conversation.getUuid());
+ }
+ }
list.clear();
if (includeNoFileUpload) {
list.addAll(getConversations());
@@ -1868,7 +1881,18 @@ public class XmppConnectionService extends Service {
}
}
try {
- Collections.sort(list);
+ if (orderedUuids != null) {
+ Collections.sort(list, (a, b) -> {
+ final int indexA = orderedUuids.indexOf(a.getUuid());
+ final int indexB = orderedUuids.indexOf(b.getUuid());
+ if (indexA == -1 || indexB == -1 || indexA == indexB) {
+ return a.compareTo(b);
+ }
+ return indexA - indexB;
+ });
+ } else {
+ Collections.sort(list);
+ }
} catch (IllegalArgumentException e) {
//ignore
}
diff --git a/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java b/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java
index 0d1a3286d..8e80208d0 100644
--- a/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java
@@ -130,7 +130,7 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer
this.share.uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
}
if (xmppConnectionServiceBound) {
- xmppConnectionService.populateWithOrderedConversations(mConversations, this.share.uris.size() == 0);
+ xmppConnectionService.populateWithOrderedConversations(mConversations, this.share.uris.size() == 0, false);
}
}
@@ -182,7 +182,8 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer
}
public void refreshUiReal() {
- xmppConnectionService.populateWithOrderedConversations(mConversations, this.share != null && this.share.uris.size() == 0);
+ //TODO inject desired order to not resort on refresh
+ xmppConnectionService.populateWithOrderedConversations(mConversations, this.share != null && this.share.uris.size() == 0, false);
mAdapter.notifyDataSetChanged();
}