Skip to content

Commit

Permalink
reduced search debounce time to solve swap location issue
Browse files Browse the repository at this point in the history
  • Loading branch information
shah272728 committed Oct 23, 2023
1 parent 30f2c76 commit 8a7d432
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1866,6 +1866,7 @@ class ExploreFragment :
}

private fun BottomSheetDirectionSearchBinding.showAllApiFailed() {
clMyLocation.root.hide()
cardMapOption.hide()
layoutCardError.groupCardErrorNoSearchFound.show()
layoutCardError.root.show()
Expand Down Expand Up @@ -2528,8 +2529,8 @@ class ExploreFragment :

ivSwapLocation.setOnClickListener {
if (checkInternetConnection() && !mIsSwapClicked && !checkDirectionLoaderVisible()) {
mViewModel.searchDebounce = DELAY_300
mIsSwapClicked = true
mLastClickTime = SystemClock.elapsedRealtime()
if (!edtSearchDest.text.isNullOrEmpty() && !edtSearchDirection.text.isNullOrEmpty()) {
showDirectionSearchShimmer()
}
Expand Down Expand Up @@ -2580,13 +2581,18 @@ class ExploreFragment :
mViewModel.mSearchDirectionDestinationData = originData
mViewModel.mSearchDirectionDestinationData?.isDestination = true
showOriginToDestinationRoute()
} else if (mViewModel.mSearchDirectionOriginData != null) {
mViewModel.mSearchDirectionDestinationData = mViewModel.mSearchDirectionOriginData
mViewModel.mSearchDirectionOriginData = null
} else if (mViewModel.mSearchDirectionDestinationData != null) {
mViewModel.mSearchDirectionOriginData = mViewModel.mSearchDirectionDestinationData
mViewModel.mSearchDirectionDestinationData = null
}
}
activity?.hideKeyboard()
lifecycleScope.launch {
delay(DELAY_300)
delay(DELAY_500)
mIsSwapClicked = false
mViewModel.searchDebounce = CLICK_DEBOUNCE
}
}
}
Expand Down Expand Up @@ -2633,7 +2639,7 @@ class ExploreFragment :
isDataSearchForDestination = false
}
}
edtSearchDest.textChanges().debounce(mViewModel.searchDebounce).onEach { text ->
edtSearchDest.textChanges().debounce(DELAY_500).onEach { text ->
updateDirectionSearchUI(text.isNullOrEmpty())
if (text?.trim().toString().lowercase() == getString(R.string.label_my_location).trim().lowercase()) {
return@onEach
Expand All @@ -2659,7 +2665,7 @@ class ExploreFragment :
checkMyLocationUI(text, edtSearchDirection)
}.launchIn(lifecycleScope)

edtSearchDirection.textChanges().debounce(mViewModel.searchDebounce).onEach { text ->
edtSearchDirection.textChanges().debounce(DELAY_500).onEach { text ->
updateDirectionSearchUI(text.isNullOrEmpty())
if (text?.trim().toString().lowercase() == getString(R.string.label_my_location).trim().lowercase()) {
return@onEach
Expand Down Expand Up @@ -4035,7 +4041,9 @@ class ExploreFragment :
if (mMapHelper.isGrabSelectedAndOutsideBound) {
mBinding.bottomSheetDirectionSearch.clMyLocation.root.hide()
} else {
mBinding.bottomSheetDirectionSearch.clMyLocation.root.show()
if (!mBinding.bottomSheetDirectionSearch.layoutCardError.root.isVisible) {
mBinding.bottomSheetDirectionSearch.clMyLocation.root.show()
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class ExploreViewModel @Inject constructor(
var providerOptions = ArrayList<FilterOption>()
var attributeOptions = ArrayList<FilterOption>()
var typeOptions = ArrayList<FilterOption>()
var searchDebounce = CLICK_DEBOUNCE

private val _searchForSuggestionsResultList =
Channel<HandleResult<SearchSuggestionResponse>>(Channel.BUFFERED)
Expand Down

0 comments on commit 8a7d432

Please sign in to comment.