vendredi 18 novembre 2016

Apply State Pattern on Android component

I have a fragment, where depending on a state it should change its UI. That is to say to hide certain blocks and to show others.

I have to do several setVisibility(View.GONE); and setVisibility(View.VISIBLE); calls. To adapt the UI to each state.

Would it be appropriate to apply the state pattern here?. I know that it is a behaviour pattern, that depending on the state of the object its behavior changes. But here too it could be applied, because the functionality of the fragment also changes depending on its state.

What would be the right way to approach this?

Aucun commentaire:

Enregistrer un commentaire