So, hopefully this question is not vaguely described, my scenario is the following:
In my app I have three flows (evidently could be more in the future, but I have to deliver this app asap to meet the requirements and as usual make my best to have an strong foundation for the guy that come next to me) so, in those three flows there are four steps for each one and each step is fairly simple, just take one piece of data and pass it along until the end of the flow.
So, my question is: which would be the "best" approach in terms of easy to implement and scalable to be able to define those flows reusing some of the activities. In other words, I have something like:
Flow 1:
A to B to C to D display all gathered data
Flow 2:
A to E to C to D display all gathered data
Flow 3:
A to F to G to D display all gathered data
How should be the handling of the data and how I can say to each activity which is the next one after itself, besides I'm using an action bar which is going to have a back arrow so in any case you can go back to the previous step and edit the data that you had choose or created before.
Maybe the word "best" is not that suitable since I'm not asking for simple opinions instead I'm asking for the suggested method to do this in an Android app, since it is a situation that I would say many apps have to deal with.
Update I:
First round implementing this flow I got working the following approach, (kind of broken pseudo java code to be brief):
// ActionBarActivity suppose to offer me the change to deal with actionBar and fragment otherwise just Fragment
Flow1Activity extends ActionBarActivity implements AFragmentListener
onCreate {
newFragment = new FragmentA();
generateTransactionTo(newFragment);
}
generateTransactionTo(android.app.Fragment newFragment) {
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(R.id.container, newFragment);
transaction.addToBackStack(null);
transaction.commit();
}
onAfragmentConfirmed() {
// do whatever...
}
Afterwards, each of the fragments has their own inner interface that the activity holder should implement (perhaps on each next into the fragment you will call to this injected interface) like:
FragmentA extends Fragment
public interface AFragmentListener {
void onAFragmentConfirmed();
}
onAttach(Context context) {
super.onAttach(context);
Activity activity = getActivity();
try {
mAFragmentListener = (AFragmentListener) activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString() + " must implement AFragmentListener");
}
}
onClickSomething() {
mAFragmentListener.onAfragmentConfirmed()
}
My current issue is that the ActionBar is not working as I would expected, I am setting my action bar doing like:
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
actionBar.setElevation(0);
}
But the button back is shown ant it doesn't do anything, and if I hit back on the android button below it goes to the prev activity :(
Useful links: