-
Notifications
You must be signed in to change notification settings - Fork 11.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tablet layout #3
Comments
Hi, do you have an example for this case? |
Not yet :) |
Ok thanks.. I'm dealing with something like that. Do you have any recommendations about how to implement this communication between presenters? |
@JoseAlcerreca Will be a viewpager in the tablet layout? If this (viewpager / handle multiple fragments) is so "complicated" then I'm hoping to see an useful example here. 👍 |
Do you have some design mockups? |
@JoseAlcerreca Looking forward to see an example of the tablet layout. |
Pulled upstream changes in branch Todo databinding
It might be easier and cleaner to create a todo-mvp-tablet sample. Adding a tablet view to all variants is going to be hard and will pollute the code making it harder to compare between variants. |
I've prefered todo-mvp-tablet too! easy to read and for maintenance. |
same here, add tablet to every single sample would be a bit of overkill. |
Will a viewpager be used? |
@Rainer-Lang no, no need. |
I've been experimenting with this and basically have two solutions, each with pros and cons. Let me know what you think: JoseAlcerreca#1 JoseAlcerreca#2 |
I have small question, to your solutions. Why do you want so much, to have one Presenter per screen? If you keep one Presenter per fragment, then it will be easier to maintain and easier to understand. But you will have to create some kind of Navigator, who will decide what to open. I can create an example if you want. |
@NikitaKozlov Could your solution even be used for viewpager? |
Yeap. Even with retaining presenter, but this is completly out of scope. |
One of the solution uses 2 presenters, the other one uses 3, actually. The reasoning for each is in the PR description.
Yes, that's what I've done in both, see TasksNavigator.java. |
IMO, #2 is a more correct, modular approach. If each presenter handles the logic of a fragment (a "screen"), a "tablet fragment" is composed of several "screens" (eg, list/detail classic example). As such, you would be interesting in creating a composite presenter ( This approach also requires to have separate logic to know when to employ the correct set of Presenters and tweak a little the navigation between the fragments. |
I don't think it's a Presenter job to talk to other Presenters... (#2). It should be handled be a different layer. Navigator looks like the best place for me. Navigator contains the logic to open a new Activity, or put a DetailFragment into DetailContainer (if exists). The reverse communication (action on DetailFragment like bookmarking, or favoriting object, that should affect visual changes on ListFragment) can be done be listening to database changes, and it's a ListPresenter job to update its view everytime database has a new dataset. |
Yes that's how Data Binding and other libraries that observe changes work, but this is an vanilla MVP approach. |
@JoseAlcerreca I will try to rephrase my point. You are considering tablet layout as an advanced “Tasks screen”, so all orchestration logic is in the guy who implements |
Yeah, that's exactly JoseAlcerreca#2 with the TasksTabletPresenter, that's why I think we're talking about the same thing. It does exactly what you're describing :) |
@JoseAlcerreca Yes and no. In JoseAlcerreca#2 your fragments are talking directly to |
Right, but I think that's a good thing: You are forced to implement the tablet behavior. Even if it's just bypassing the event, you have the guarantee that that's the behavior you want in tablet mode. |
JoseAlcerreca#2 updated with some UI fixes and now I'm retaining presenters in retained fragments so that rotation is fast and easy. It's risky for a sample, since it can easily be misused, so it would need some documentation. |
Merges changes from todo-mvp and fixes UI tests
A layout with multiple fragments per screen would showcase how to keep data fresh between views and send messages between presenters.
The text was updated successfully, but these errors were encountered: