show a placeholder at using Search whenever appropriate

This commit is contained in:
tibbi 2019-07-09 22:25:18 +02:00
parent ee929a9d1b
commit 7f0d5f9300
2 changed files with 10 additions and 5 deletions

View file

@ -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 {
runOnUiThread {
if (textToSearch.isNotEmpty()) {
dirsToShow = dirsToShow.filter { it.name.contains(textToSearch, true) }.sortedBy { !it.name.startsWith(textToSearch, true) }.toMutableList() as ArrayList
}
runOnUiThread {
checkPlaceholderVisibility(dirsToShow)
(directories_grid.adapter as? DirectoryAdapter)?.updateDirs(dirsToShow)
measureRecyclerViewContent(dirsToShow)
}

View file

@ -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"