Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search by place. String provider. Detekt. #42

Merged
merged 4 commits into from
Jun 1, 2019

Conversation

GustavoSanMartin
Copy link
Member

@GustavoSanMartin GustavoSanMartin commented Jun 1, 2019

Issues

Closes #28

Summary

  • Using Mapbox Geocoding sdk to provide search results
  • Added a strings generator to access string values from anywhere
  • Switched to detekt for checking lint
  • Formatted lines which violate detekt checker

Use ./gradlew detekt to check for lint errors
Todo #43

Screenshots

device-2019-06-01-125803

@GustavoSanMartin GustavoSanMartin changed the title Search by place using mapbox. Added string provider Search by place. String provider. Detekt. Jun 1, 2019
Copy link
Member

@dellisd dellisd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can (or should) generally prefer idiomatic code wherever possible.

suspend fun getSearchResults(query: String): List<SearchResult> = withContext(Dispatchers.IO) {
if (query.isEmpty()) return@withContext emptyList<SearchResult>()

val stops = getStops(query)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
val stops = getStops(query)
getStops(query).takeIf { it.isNotEmpty() }?.let { /* Add header and append to search results */ }

This could be made more idiomatic by using a takeIf followed by a let block where the header and results can be added to the output list.

.executeCall()
.body()
?.features()
?.map { SearchResult.PlaceItem(it.placeName().orEmpty(), it.text().orEmpty()) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
?.map { SearchResult.PlaceItem(it.placeName().orEmpty(), it.text().orEmpty()) }
?.map { feature -> SearchResult.PlaceItem(feature.placeName().orEmpty(), feature.text().orEmpty()) }

Add explicit lambda parameter name here

Copy link
Member Author

@GustavoSanMartin GustavoSanMartin Jun 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason for this? It's not overshadowed or anything. Are we avoiding the it implicit parameter altogether?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's more readable this way. it explicitly states what's being dealt with in the closure since it's a bit too confusing to infer at the bottom of a long chain of function calls.

app/src/main/res/layout/search_place.xml Show resolved Hide resolved
@GustavoSanMartin GustavoSanMartin requested a review from dellisd June 1, 2019 21:37
@GustavoSanMartin GustavoSanMartin merged commit a10c5df into Llamabagel:master Jun 1, 2019
@GustavoSanMartin GustavoSanMartin deleted the search-place branch June 1, 2019 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to search for places
2 participants