Bimba.git

commit b1c524a5a5dc820a6efca558c43cf6a6cf688ecc

Author: Adam Evyčędo <git@apiote.xyz>

remove phantom search results

%!v(PANIC=String method: strings: negative Repeat count)


diff --git a/app/src/main/java/xyz/apiote/bimba/czwek/dashboard/ui/home/HomeFragment.kt b/app/src/main/java/xyz/apiote/bimba/czwek/dashboard/ui/home/HomeFragment.kt
index 3089cee929f485486c900ebe1234828452685a44..6e29e6b47a85f9f90535ab1bce25b0fe086fb11d 100644
--- a/app/src/main/java/xyz/apiote/bimba/czwek/dashboard/ui/home/HomeFragment.kt
+++ b/app/src/main/java/xyz/apiote/bimba/czwek/dashboard/ui/home/HomeFragment.kt
@@ -18,7 +18,7 @@ import androidx.core.view.updatePadding
 import androidx.fragment.app.Fragment
 import androidx.lifecycle.ViewModelProvider
 import androidx.recyclerview.widget.LinearLayoutManager
-import com.google.android.material.search.SearchView
+import com.google.android.material.search.SearchView.TransitionState
 import xyz.apiote.bimba.czwek.dashboard.MainActivity
 import xyz.apiote.bimba.czwek.databinding.FragmentHomeBinding
 import xyz.apiote.bimba.czwek.dpToPixelI
@@ -46,17 +46,20 @@ 			adapter.update(it)
 		}
 
 		val onBackPressedCallback = object :
-			OnBackPressedCallback(binding.searchView.currentTransitionState == SearchView.TransitionState.SHOWN) {
+			OnBackPressedCallback(binding.searchView.currentTransitionState == TransitionState.SHOWN) {
 			override fun handleOnBackPressed() {
-				binding.searchView.hide()
+				binding.searchBar.collapse(binding.searchView)
 			}
 		}
 		activity?.onBackPressedDispatcher?.addCallback(onBackPressedCallback)
 		binding.searchView.addTransitionListener { _, _, newState ->
 			onBackPressedCallback.isEnabled = when (newState) {
-				SearchView.TransitionState.SHOWN -> true
-				SearchView.TransitionState.HIDDEN -> false
+				TransitionState.SHOWN -> true
+				TransitionState.HIDDEN -> false
 				else -> false
+			}
+			if (newState === TransitionState.HIDING) {
+				adapter.update(listOf())
 			}
 		}