To loop over the details in Pantry model, let's use Kotlin Reflection
Pantry Model changes
Instead of parsing pantry.phone into a String, let's create objects Phone and Availability so in our new DetailsFragment code, we can treat the phone and availability data as special cases.
Implementation
JSON changes
I think we should change the layout of the json data so it looks as follows:
This way, we can require the name, address, and
LatLng
of the pantry and make all details optional.DetailsFragment
changesWe will create a
RecyclerView
that will make a scrollable list of the pantry name, address, and all pantry details.Note: We will need to make multiple
ViewHolder
s to support customView
s for phone and availabilityTo loop over the details in
Pantry
model, let's use Kotlin ReflectionPantry
Model changesInstead of parsing
pantry.phone
into aString
, let's create objectsPhone
andAvailability
so in our newDetailsFragment
code, we can treat the phone and availability data as special cases.