I have my application that has to show quite a few views. For example, there is the login view, which takes their details. They click to log in and then they go to the profile view, which shows them their information. Then there are the search, search results and various others.
I'm hitting this problem though. I'm trying to go down the OO route and I don't know the best way to manage my views. I created my activity, with this function:
Page is a base class where the other pages are derived from, for example LoginPage extends Page and looks a little bit like this:
But that is posing a problem, because once the login page has successfully logged the user in, the user data is contained in this login page AND it has to tell the parent to switch views.. which is going to cause issues because the parent will then destroy the login page and replace it with the profile page.
So I'm looking for a better way, but I don't know what that way is. Ideally, the Activity should be able to create views/pages and views/pages need a way to indicate that they should be changed, however the page class (or derived - eg LoginPage) shouldn't need to keep an instance of the parent (Activity) class.
So I'd like to know how other people are managing their views and if anyone can give me some guidance to designing this application properly.