mercredi 12 décembre 2018

The "Single Activity Architecture" - Multiple device layouts...what am I missing?

I am currently writing and app and recently come across the "Single Activity Architecture" which seems great on first glance, using fragments/SupportFragmentManager to load fragments in to a 'container' programatically.

Now in practice, I am having an issue with the pattern, namely with having separate device layouts.

Example

Assuming we are using one Activity.kt class, how can we use the FragmentManager to achieve the above? Using the one Activity class for all devices/orientations, the code seems far too coupled to the layouts to achieve the pattern. You'd need code such as:

if layout == tablet AND Landscape -> do this fragment transaction
if layout == phone AND portrait -> do this fragment transaction
if layout == television AND landscape -> do this fragment transaction

It seems to quickly become a rather bad and messy "un-scaleable" pattern as opposed to having fragments just placed in the various XML layout files for the devices...

Or is the pattern really only intended for say a simple app layout scenarios (say phone only)?

Any enlightenment would be great.

Ref Link:Reddit

Ref Link:Android Dev Blog

Aucun commentaire:

Enregistrer un commentaire