Skip to content

Commit

Permalink
Search: sort bookmarks by name/JID
Browse files Browse the repository at this point in the history
  • Loading branch information
ge0rg committed Oct 22, 2019
1 parent b28e961 commit f396fa9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/org/yaxim/androidclient/list/EntityListLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
import org.yaxim.androidclient.util.StatusMode;
import org.yaxim.androidclient.util.XMPPHelper;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.EnumSet;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -53,6 +56,19 @@ void loadBookmarksOrThrow(XMPPConnection c) throws Exception {
List<BookmarkedConference> list = BookmarkManager.getBookmarkManager(c).getBookmarkedConferences();
if (isCancelled())
return;
/* make a mutable array of the response, sort by name */
list = new ArrayList<>(list);
Collections.sort(list, new Comparator<BookmarkedConference>() {
private String sortableName(BookmarkedConference bc) {
if (!TextUtils.isEmpty(bc.getName()))
return bc.getName();
return bc.getJid().toString();
}
@Override
public int compare(BookmarkedConference bookmarkedConference, BookmarkedConference with) {
return sortableName(bookmarkedConference).compareToIgnoreCase(sortableName(with));
}
});
for (BookmarkedConference conf : list) {
StatusMode sm = conf.isAutoJoin() ? StatusMode.available : StatusMode.offline;
String name = conf.getName();
Expand Down

0 comments on commit f396fa9

Please sign in to comment.