Add no items found placeholder when searching

This commit is contained in:
Ensar Sarajčić 2023-07-18 08:32:10 +02:00
parent 43d5e2031a
commit dffca7823c
2 changed files with 23 additions and 0 deletions

View File

@ -182,9 +182,15 @@ class AllAppsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
search_bar.onSearchTextChangedListener = {
(all_apps_grid.adapter as? LaunchersAdapter)?.updateSearchQuery(it)
showNoResultsPlaceholderIfNeeded()
}
}
private fun showNoResultsPlaceholderIfNeeded() {
val itemCount = all_apps_grid.adapter?.itemCount
no_results_placeholder.beVisibleIf(itemCount != null && itemCount == 0)
}
override fun onAppLauncherLongPressed(x: Float, y: Float, appLauncher: AppLauncher) {
val gridItem = HomeScreenGridItem(
null,

View File

@ -26,4 +26,21 @@
app:spanCount="@integer/portrait_column_count" />
</com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/no_results_placeholder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/search_bar"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/bigger_margin"
android:alpha="0.8"
android:gravity="center"
android:paddingLeft="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin"
android:text="@string/no_items_found"
android:textSize="@dimen/bigger_text_size"
android:textStyle="italic"
android:visibility="gone" />
</com.simplemobiletools.launcher.fragments.AllAppsFragment>