-1

I have an application requiring the user to fill a form in order to create a Route. This Route requires the user to create at least one Step, and a Riddle linked to the step. The user can create a Route with many Steps and Riddles.

So I have 3 activities (CreateCustomRouteActivity,CreateCustomStepActivity,CreateCustomRiddleActivity), each one composed of a form with differents fields corresponding to the object's properties.

I don't want the user to be able to create a Step without creating a Riddle, and I don't want him to create a Step and a Riddle without linking it to a Route

In the last activity, there's a button to validate and create the objects.

What is the best way to pass these data across the 3 activities? Should I use Parcelable interface? Should I use a bundle of extras in intents? Should i change the way i'm approaching it?

Keisuke246
  • 25
  • 8
  • Use setArguments() and getArguments() methods, see this url https://stackoverflow.com/questions/17063378/how-to-pass-bundle-from-fragment-to-fragment . – Alexander Nov 13 '17 at 21:11

1 Answers1

1

It looks like a wizard pattern to me. I'd consider the following:

  • If your data is small, using Parcelable sounds like a good idea. It will be executed on the main thread so if you have a lot of data to parcel, that will block the UI.
  • I'd also consider implementing those 3 screens as fragments, you can have that data saved in the activity. You will still have to parcel it for configuration changes (rotation of the device for example)
  • You can store the data in a singleton object that won't get removed across configuration changes.
Quanturium
  • 5,698
  • 2
  • 30
  • 36