elizarov
05/23/2017, 5:35 PMlateinit
? Can you share some code?edenman
05/23/2017, 6:11 PMPagerAdapter
, each PlaceCardView
can be in a different state (loading, showing a place, or showing the “no nearby places” state). PlaceCardView
has a private var place: Place? = null
property and three modifier methods (showPlace(place: Place)
, showLoading()
, showNoNearbyPlaces()
) that set/unset the place
var
then the click listeners for the various views all have to do
foo.setOnClickListener {
val place = place
if (place == null) {
// do a thing
} else {
// do the other thing
}
}
lateinit doesn’t work because i need to check if the value is set or not and i need to be able to unset it.edenman
05/23/2017, 6:15 PMsetOnClickListener
every time the place
changes, but that feels even more gross to me in this caseorangy
EmptyObject
pattern. Make a singleton object Nowhere : Place
and use it whenever place is not defined. You will save yourself a lot of issues with null handling.edenman
05/23/2017, 7:48 PMorangy