show search result placeholder when no results are shown

This commit is contained in:
tibbi 2018-01-19 14:56:35 +01:00
parent c777967d7e
commit 7fe64f4c81
3 changed files with 56 additions and 6 deletions

View File

@ -43,7 +43,7 @@ ext {
}
dependencies {
implementation 'com.simplemobiletools:commons:3.7.7'
implementation 'com.simplemobiletools:commons:3.7.9'
implementation 'joda-time:joda-time:2.9.9'
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'com.android.support:multidex:1.0.2'

View File

@ -6,6 +6,7 @@ import android.content.Intent
import android.content.pm.ActivityInfo
import android.database.ContentObserver
import android.database.Cursor
import android.graphics.drawable.ColorDrawable
import android.net.Uri
import android.os.Bundle
import android.os.Handler
@ -147,6 +148,7 @@ class MainActivity : SimpleActivity(), NavigationListener {
updateWidgets()
updateTextColors(calendar_coordinator)
search_holder.background = ColorDrawable(config.backgroundColor)
}
override fun onPause() {
@ -221,7 +223,7 @@ class MainActivity : SimpleActivity(), NavigationListener {
override fun onQueryTextSubmit(query: String) = false
override fun onQueryTextChange(newText: String): Boolean {
if (mIsSearchOpen && newText.length >= 3) {
if (mIsSearchOpen) {
searchQueryChanged(newText)
}
return true
@ -232,11 +234,16 @@ class MainActivity : SimpleActivity(), NavigationListener {
MenuItemCompat.setOnActionExpandListener(mSearchMenuItem, object : MenuItemCompat.OnActionExpandListener {
override fun onMenuItemActionExpand(item: MenuItem?): Boolean {
mIsSearchOpen = true
search_holder.beVisible()
calendar_fab.beGone()
searchQueryChanged("")
return true
}
override fun onMenuItemActionCollapse(item: MenuItem?): Boolean {
mIsSearchOpen = false
search_holder.beGone()
calendar_fab.beVisible()
return true
}
})
@ -772,9 +779,12 @@ class MainActivity : SimpleActivity(), NavigationListener {
private fun searchQueryChanged(text: String) {
mLatestSearchQuery = text
dbHelper.getEventsWithSearchQuery(text) { searchedText, events ->
if (searchedText == mLatestSearchQuery) {
search_placeholder_2.beGoneIf(text.length >= 2)
if (text.length >= 2) {
dbHelper.getEventsWithSearchQuery(text) { searchedText, events ->
if (searchedText == mLatestSearchQuery) {
}
}
}
}

View File

@ -23,9 +23,9 @@
android:id="@+id/week_view_hours_divider"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:importantForAccessibility="no"
android:layout_alignRight="@+id/week_view_hours_scrollview"
android:background="@drawable/stroke_bottom_right"/>
android:background="@drawable/stroke_bottom_right"
android:importantForAccessibility="no"/>
<com.simplemobiletools.calendar.views.MyScrollView
android:id="@+id/week_view_hours_scrollview"
@ -76,4 +76,44 @@
app:backgroundTint="@color/color_primary"
app:rippleColor="@color/pressed_item_foreground"/>
<RelativeLayout
android:id="@+id/search_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:visibility="gone">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/search_placeholder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/activity_margin"
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"/>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/search_placeholder_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/search_placeholder"
android:layout_centerHorizontal="true"
android:gravity="center"
android:paddingBottom="@dimen/medium_margin"
android:paddingLeft="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin"
android:paddingTop="@dimen/medium_margin"
android:text="@string/type_2_characters"
android:textSize="@dimen/bigger_text_size"/>
<com.simplemobiletools.commons.views.MyRecyclerView
android:id="@+id/search_results"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>