Skip to content

Commit

Permalink
feature: fixed cast exception, with place resolution used geo instead… (
Browse files Browse the repository at this point in the history
#365)

* feature: fixed cast exception, with place resolution used geo instead places api, fixed indexOutOfBoundException

* fixes unexpected indentation

* increased minor version

* warning ktLint check
  • Loading branch information
efraespada authored Oct 17, 2022
1 parent bf2531a commit 6e5f749
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 25 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ org.gradle.jvmargs=-Xmx2048m
org.gradle.configureondemand=false
android.useAndroidX=true
libGroup=com.adevinta.android
libVersion=10.0.1
libVersion=10.0.2
61 changes: 37 additions & 24 deletions leku/src/main/java/com/adevinta/leku/LocationPickerActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,12 @@ class LocationPickerActivity :
this,
)
searchAdapter?.onClick = {
setNewSuggestion(suggestionList[it])
changeListResultVisibility(View.GONE)
closeKeyboard()
hideSearchLayout()
if (suggestionList.size > it) {
setNewSuggestion(suggestionList[it])
changeListResultVisibility(View.GONE)
closeKeyboard()
hideSearchLayout()
}
}
}
else -> {
Expand Down Expand Up @@ -493,8 +495,7 @@ class LocationPickerActivity :
updateVoiceSearchVisibility()
} else {
if (term.length > MIN_CHARACTERS) {
if (placeResolution) geocoderPresenter?.getSuggestionsFromLocationName(term)
else retrieveLocationWithDebounceTimeFrom(term)
retrieveLocationWithDebounceTimeFrom(term)
}
clearSearchButton?.visibility = View.VISIBLE
searchOption?.setIcon(R.drawable.leku_ic_search)
Expand Down Expand Up @@ -1088,8 +1089,8 @@ class LocationPickerActivity :

private fun getTransitionBundleParams(transitionBundle: Bundle) {
bundle.putBundle(TRANSITION_BUNDLE, transitionBundle)
if (transitionBundle.keySet().contains(LATITUDE) && transitionBundle.keySet()
.contains(LONGITUDE)
if (transitionBundle.keySet().contains(LATITUDE) &&
transitionBundle.keySet().contains(LONGITUDE)
) {
setLocationFromBundle(transitionBundle)
}
Expand Down Expand Up @@ -1313,26 +1314,38 @@ class LocationPickerActivity :
}

private fun retrieveLocationFrom(query: String) {
if (searchZone != null && searchZone!!.isNotEmpty()) {
retrieveLocationFromZone(query, searchZone!!)
} else if (searchZoneRect != null) {
retrieveLocationFromZone(query, searchZoneRect!!)
} else if (isSearchZoneWithDefaultLocale) {
retrieveLocationFromDefaultZone(query)
} else {
geocoderPresenter?.getFromLocationName(query)
when {
placeResolution -> geocoderPresenter?.getSuggestionsFromLocationName(query)
searchZone != null && searchZone!!.isNotEmpty() -> {
retrieveLocationFromZone(query, searchZone!!)
}
searchZoneRect != null -> {
retrieveLocationFromZone(query, searchZoneRect!!)
}
isSearchZoneWithDefaultLocale -> {
retrieveLocationFromDefaultZone(query)
}
else -> {
geocoderPresenter?.getFromLocationName(query)
}
}
}

private fun retrieveLocationWithDebounceTimeFrom(query: String) {
if (searchZone != null && searchZone!!.isNotEmpty()) {
retrieveDebouncedLocationFromZone(query, searchZone!!, DEBOUNCE_TIME)
} else if (searchZoneRect != null) {
retrieveDebouncedLocationFromZone(query, searchZoneRect!!, DEBOUNCE_TIME)
} else if (isSearchZoneWithDefaultLocale) {
retrieveDebouncedLocationFromDefaultZone(query, DEBOUNCE_TIME)
} else {
geocoderPresenter?.getDebouncedFromLocationName(query, DEBOUNCE_TIME)
when {
placeResolution -> geocoderPresenter?.getSuggestionsFromLocationName(query)
searchZone != null && searchZone!!.isNotEmpty() -> {
retrieveDebouncedLocationFromZone(query, searchZone!!, DEBOUNCE_TIME)
}
searchZoneRect != null -> {
retrieveDebouncedLocationFromZone(query, searchZoneRect!!, DEBOUNCE_TIME)
}
isSearchZoneWithDefaultLocale -> {
retrieveDebouncedLocationFromDefaultZone(query, DEBOUNCE_TIME)
}
else -> {
geocoderPresenter?.getDebouncedFromLocationName(query, DEBOUNCE_TIME)
}
}
}

Expand Down

0 comments on commit 6e5f749

Please sign in to comment.