From 41558f4df31d13e658e0191b994d075a306bc0fd Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 1 Sep 2020 12:03:59 +1000 Subject: [PATCH] Android: Sort game list by title --- .../java/com/github/stenzek/duckstation/GameList.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/android/app/src/main/java/com/github/stenzek/duckstation/GameList.java b/android/app/src/main/java/com/github/stenzek/duckstation/GameList.java index 75d15487b..ec23b9c56 100644 --- a/android/app/src/main/java/com/github/stenzek/duckstation/GameList.java +++ b/android/app/src/main/java/com/github/stenzek/duckstation/GameList.java @@ -12,6 +12,8 @@ import android.widget.TextView; import androidx.preference.PreferenceManager; +import java.util.Arrays; +import java.util.Comparator; import java.util.Set; public class GameList { @@ -25,10 +27,19 @@ public class GameList { mEntries = new GameListEntry[0]; } + private class GameListEntryComparator implements Comparator { + @Override + public int compare(GameListEntry left, GameListEntry right) { + return left.getTitle().compareTo(right.getTitle()); + } + } + + public void refresh(boolean invalidateCache, boolean invalidateDatabase) { // Search and get entries from native code AndroidHostInterface.getInstance().refreshGameList(invalidateCache, invalidateDatabase); mEntries = AndroidHostInterface.getInstance().getGameListEntries(); + Arrays.sort(mEntries, new GameListEntryComparator()); mAdapter.notifyDataSetChanged(); }