From 7f0d5f9300c5656694a366211cc401729b415a7a Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 9 Jul 2019 22:25:18 +0200 Subject: [PATCH] show a placeholder at using Search whenever appropriate --- .../gallery/pro/activities/MainActivity.kt | 13 +++++++++---- app/src/main/res/layout/activity_main.xml | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index ade0db791..7eb21535f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -1018,7 +1018,10 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { directories_empty_text_label.beVisibleIf(dirs.isEmpty() && mLoadedInitialPhotos) directories_empty_text.beVisibleIf(dirs.isEmpty() && mLoadedInitialPhotos) - if (dirs.isEmpty() && config.filterMedia == TYPE_DEFAULT_FILTER) { + if (mIsSearchOpen) { + directories_empty_text_label.text = getString(R.string.no_items_found) + directories_empty_text.beGone() + } else if (dirs.isEmpty() && config.filterMedia == TYPE_DEFAULT_FILTER) { directories_empty_text_label.text = getString(R.string.no_media_add_included) directories_empty_text.text = getString(R.string.add_folder) @@ -1070,10 +1073,12 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } measureRecyclerViewContent(dirsToShow) } else { - if (textToSearch.isNotEmpty()) { - dirsToShow = dirsToShow.filter { it.name.contains(textToSearch, true) }.sortedBy { !it.name.startsWith(textToSearch, true) }.toMutableList() as ArrayList - } runOnUiThread { + if (textToSearch.isNotEmpty()) { + dirsToShow = dirsToShow.filter { it.name.contains(textToSearch, true) }.sortedBy { !it.name.startsWith(textToSearch, true) }.toMutableList() as ArrayList + } + checkPlaceholderVisibility(dirsToShow) + (directories_grid.adapter as? DirectoryAdapter)?.updateDirs(dirsToShow) measureRecyclerViewContent(dirsToShow) } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 6b728133f..1d2d25731 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -15,7 +15,7 @@ android:id="@+id/directories_switch_searching" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="?attr/selectableItemBackgroundBorderless" + android:background="?attr/selectableItemBackground" android:gravity="center" android:padding="@dimen/activity_margin" android:text="@string/switch_to_file_search"