mercredi 3 février 2016

Where to put logic that is repeated amongst my Fragments?

I have a tab-based application with 5 tabs (Fragments). Each fragment is very similar in appearance and functionality. Where should I put this logic for these classes so that I am not repeating it in each Fragment?

Should I be putting it in a parent class that extends fragment and then have each Fragment inherit from that class? Is this good android app design or is there a better idea I haven't thought of?

Should I put the logic in my MainActivity since it controls all my Fragments?

Aucun commentaire:

Enregistrer un commentaire