Giter Site home page Giter Site logo

Comments (24)

JoseAlcerreca avatar JoseAlcerreca commented on May 6, 2024 19

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.
👍 or 👎 ?

from architecture-samples.

Rainer-Lang avatar Rainer-Lang commented on May 6, 2024 2

@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. 👍

from architecture-samples.

Sefford avatar Sefford commented on May 6, 2024 2

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 (TasksTabletPresenter) which orchestrates the communication between all the individual Presenters.

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.

from architecture-samples.

NikitaKozlov avatar NikitaKozlov commented on May 6, 2024 1

Yeap. Even with retaining presenter, but this is completly out of scope.

from architecture-samples.

logo17 avatar logo17 commented on May 6, 2024

Hi, do you have an example for this case?

from architecture-samples.

JoseAlcerreca avatar JoseAlcerreca commented on May 6, 2024

Not yet :)

from architecture-samples.

logo17 avatar logo17 commented on May 6, 2024

Ok thanks.. I'm dealing with something like that. Do you have any recommendations about how to implement this communication between presenters?

from architecture-samples.

NikitaKozlov avatar NikitaKozlov commented on May 6, 2024

Do you have some design mockups?

from architecture-samples.

sergeykosik avatar sergeykosik commented on May 6, 2024

@JoseAlcerreca Looking forward to see an example of the tablet layout.

from architecture-samples.

flipper83 avatar flipper83 commented on May 6, 2024

I've prefered todo-mvp-tablet too! easy to read and for maintenance.

from architecture-samples.

malmstein avatar malmstein commented on May 6, 2024

same here, add tablet to every single sample would be a bit of overkill.

from architecture-samples.

Rainer-Lang avatar Rainer-Lang commented on May 6, 2024

Will a viewpager be used?

from architecture-samples.

JoseAlcerreca avatar JoseAlcerreca commented on May 6, 2024

@Rainer-Lang no, no need.

from architecture-samples.

JoseAlcerreca avatar JoseAlcerreca commented on May 6, 2024

I've been experimenting with this and basically have two solutions, each with pros and cons. Let me know what you think:

JoseAlcerreca#1
Modifies each call to TasksPresenter or TaskDetailPresenter to be tablet-aware.

JoseAlcerreca#2
Adds another layer of abstraction for presenters with a TasksTabletPresenter that talks to the list and detail presenters, keeping modifications to the original mvp classes low.

from architecture-samples.

NikitaKozlov avatar NikitaKozlov commented on May 6, 2024

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.

from architecture-samples.

Rainer-Lang avatar Rainer-Lang commented on May 6, 2024

@NikitaKozlov Could your solution even be used for viewpager?

from architecture-samples.

JoseAlcerreca avatar JoseAlcerreca commented on May 6, 2024

Why do you want so much, to have one Presenter per screen?

One of the solution uses 2 presenters, the other one uses 3, actually. The reasoning for each is in the PR description.

But you will have to create some kind of Navigator, who will decide what to open.

Yes, that's what I've done in both, see TasksNavigator.java.

from architecture-samples.

lurbas avatar lurbas commented on May 6, 2024

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.
To do it you can use libraries like sqlbrite, or it's not so difficult to write similar thing by yourself.
If you're interested, I can provide some examples.

from architecture-samples.

JoseAlcerreca avatar JoseAlcerreca commented on May 6, 2024

Yes that's how Data Binding and other libraries that observe changes work, but this is an vanilla MVP approach.

from architecture-samples.

NikitaKozlov avatar NikitaKozlov commented on May 6, 2024

@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 TasksContract.Presenter: for #1 it is TasksPresenter, for #2 it is TasksTabletPresenter. I’m proposing to treat each fragment with a presenter as a block with it’s listeners and setters. And then create a controller on top that will handle the orchestration logic. This guy could be a Navigator, another Presenter or any kind of controller and will be responsible for connecting callbacks from different blocks(aka Presenters). He will also remove TaskDetailFragment on clearing if required, or tell proper Navigator to do that. Sort of “Presenter“ for Activity.
That will keep changes to the minimum and make a code a little bit more decoupled. Once I finished with the example I will show it.

from architecture-samples.

JoseAlcerreca avatar JoseAlcerreca commented on May 6, 2024

and then create a controller on top that will handle the orchestration logic. This guy could be a Navigator, another Presenter

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 :)

from architecture-samples.

NikitaKozlov avatar NikitaKozlov commented on May 6, 2024

@JoseAlcerreca Yes and no. In JoseAlcerreca#2 your fragments are talking directly to TasksTabletPresenter. Instead of that I want, for example, TasksFragment talk to TasksPresenter, but TasksTabletPresenter will put some callbacks on TasksPresenter. It is your approach, but upside down.
But the difference is significant if it comes to extendability. Let's image that you want to add a couple more methods to TasksContract.Presenter, in your case you will have to add them to TasksTabletPresenter as well, in my case I will have to change something only if it affects TaskDetailPresenter.

from architecture-samples.

JoseAlcerreca avatar JoseAlcerreca commented on May 6, 2024

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.

from architecture-samples.

JoseAlcerreca avatar JoseAlcerreca commented on May 6, 2024

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.

from architecture-samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.