stepstone-tech / android-material-stepper

This library allows to use Material steppers inside Android applications.
Apache License 2.0
1.78k stars 261 forks source link

Help required: How to collect the data of all stepper fragments in last fragment to push on server? #251

Closed chnouman closed 6 years ago

GuillaumeEbert commented 6 years ago

I use the ViewModel component. (doc https://developer.android.com/topic/libraries/architecture/viewmodel.html

Put all your data object in the viewHolder In each fragement register the ViewModel to the parent activity like this ViewModelProviders.of(getActivity()).get(ClassOfTheViewHolder.class);

On the on select method get your data from the viewHolder from a getter and Voila your data can be shared between fragments. Just remind you that the ViewHolder is link to the activity life cycle.

Good codding

chnouman commented 6 years ago

@GuillaumeEbert the link to docs is not found can you please share your working example with just two fragments?

felislynx-silae commented 6 years ago

@chnouman URL if you use architecture components it will work like charm