I have inherited some code at work, and I have a question about some implementation. In the application in which I work, there is an Activity that contains about 15 different fragments. The logic in the Office that processes these fragments can be roughly summed with the following pseudo-code:
if (button_1 selected) { load fragment_1; } else if (button_2 selected) { load fragment_2; } else if (button_3 selected) { load fragment_3; } ...and so on x15ish
My question is: is there some kind of Android design template to handle such situations? The code works; however, I don't feel too comfortable with a giant if / else or case statement. I saw this question and it seems very similar to the problem I am facing. I searched quite a bit on the Internet, but I did not find any examples or best practices for such a scenario.
If someone can point me in the right direction or offer me some suggestions; it would be great. Thanks!
source share