-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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
Convert firestore quickstart to Kotlin #638
Conversation
Change-Id: I3995228bb5b924cf3d63a1906dd8b461088759c0
Change-Id: Ieeeebb59750672b9126f9d039a8736341a640492
Change-Id: I1e7a8d63b8b65fbbcefaaddc11c8b8008bfc55af
Change-Id: I0f71b80b14306b9a790b3663b23e3bdb4c63f8ac
@the-dagger @rosariopfernandes if either one of you has time to review, this one is ready to go. If not I can get someone on my team to review, don't need to take up all of your time! |
@samtstern Sure, I'll have a look. |
firestore/app/src/main/java/com/google/firebase/example/fireeats/java/FilterDialogFragment.java
Show resolved
Hide resolved
} | ||
|
||
fun onSearchClicked() { | ||
if (filterListener != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this can be replaced with a safe call. ?.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this would do:
filterListener?.let{
filterListener.onFilter(filters)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, correct.
Also, I think that
filterListener?.onFilter(filters)
would work just fine as well, no need for the let block.
What do you think @rosariopfernandes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PERFECTION ✨
|
||
// Sort by (orderBy with direction) | ||
if (filters.hasSortBy()) { | ||
query = query.orderBy(filters.sortBy!!, filters.sortDirection!!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of !!
can we use toString()
on these params?
|
||
override fun onResume() { | ||
super.onResume() | ||
dialog.window!!.setLayout( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I think that we should avoid the not-null assertion operator (!!) as much as we can.
Leads to undesirable NPEs!
restaurantFormRating.rating.toDouble(), | ||
restaurantFormText.text.toString()) | ||
|
||
if (ratingListener != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, can be replaced with a safe call operator ?.
firestore/app/src/main/java/com/google/firebase/example/fireeats/kotlin/FilterDialogFragment.kt
Outdated
Show resolved
Hide resolved
/** | ||
* Model POJO for a rating. | ||
*/ | ||
class Rating { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use a data class here?
* Restaurant POJO. | ||
*/ | ||
@IgnoreExtraProperties | ||
class Restaurant { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data class here as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samtstern added some pointers.
Most of it looks good!
Change-Id: I063d6190ca8136a83249b37c48e2d643df74067e
Change-Id: I08a033f6a890efca393da5faa073ba1495273af5
Change-Id: I1c97a006b23e32f5b35a7e8640b83c42b98a323a
Fixes #630