From c4a1d97c85791ea104075c83436de033e022d40f Mon Sep 17 00:00:00 2001 From: swurl Date: Sat, 24 May 2025 18:17:59 -0400 Subject: [PATCH] improved search/filter performance It applied every time you typed before lmao Signed-off-by: swurl --- .../org/yuzu/yuzu_emu/dialogs/LobbyBrowser.kt | 20 +++- .../main/res/layout/dialog_lobby_browser.xml | 95 +++++++++++-------- .../app/src/main/res/values/strings.xml | 2 +- 3 files changed, 76 insertions(+), 41 deletions(-) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/dialogs/LobbyBrowser.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/dialogs/LobbyBrowser.kt index bb15aee8b0..ae588bdfa8 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/dialogs/LobbyBrowser.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/dialogs/LobbyBrowser.kt @@ -12,6 +12,9 @@ import android.os.Looper import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.view.inputmethod.EditorInfo +import android.view.inputmethod.InputMethodManager +import androidx.core.content.getSystemService import androidx.core.widget.doOnTextChanged import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager @@ -82,9 +85,24 @@ class LobbyBrowser(context: Context) : BottomSheetDialog(context) { } else { binding.clearButton.visibility = View.INVISIBLE } - adapter.filterAndSearch() } + binding.searchText.setOnEditorActionListener { v, action, _ -> + if (action == EditorInfo.IME_ACTION_DONE) { + v.clearFocus() + + val imm = context.getSystemService() + imm?.hideSoftInputFromWindow(v.windowToken, 0) + + adapter.filterAndSearch() + true + } else { + false + } + } + + binding.btnSubmit.setOnClickListener { adapter.filterAndSearch() } + binding.clearButton.setOnClickListener { binding.searchText.setText("") adapter.updateRooms(NetPlayManager.getPublicRooms()) diff --git a/src/android/app/src/main/res/layout/dialog_lobby_browser.xml b/src/android/app/src/main/res/layout/dialog_lobby_browser.xml index a1a42b2d65..a016e48823 100644 --- a/src/android/app/src/main/res/layout/dialog_lobby_browser.xml +++ b/src/android/app/src/main/res/layout/dialog_lobby_browser.xml @@ -62,54 +62,71 @@ - + android:layout_height="match_parent" + android:orientation="horizontal"> - + android:layout_marginTop="12dp" + app:cardCornerRadius="24dp"> + + + + + + + + - - - + android:background="?attr/selectableItemBackground" + android:src="@drawable/ic_clear" + android:visibility="invisible" + app:tint="?attr/colorOnSurfaceVariant" + tools:visibility="visible" /> + + + + + - - Hide Full Rooms Hide Empty Rooms Tap refresh to check again - Search Public Lobbies… + Search Lobbies… Multiplayer Preferred Games Preferred Game