Android-CleanArchitecture icon indicating copy to clipboard operation
Android-CleanArchitecture copied to clipboard

Two presenters and one user case: how can link them ?

Open aeroxr1 opened this issue 6 years ago • 2 comments

i have a fragment with two inner fragment. For the outside fragment I write a presenter with a user case "UserPressRedButton"

when the UserPressRedButton action is completed I have to update the presentation layer of the two inner fragment

In which way can link all together ?

aeroxr1 avatar May 28 '19 07:05 aeroxr1

@aeroxr1 I guess you can keep the references of the instances of the inner fragments in the outer fragment and simply call the public method to update the UI state. And if you want to access presenter in inner fragment then you can add inner fragments using ChildFragmentManager and then from inner fragment you can call getParentFragment() to access the public methods of parent fragment.

dharmendrainnovify avatar May 28 '19 08:05 dharmendrainnovify

I already done in that way, but i don't know if it is much clean.. In this way in the view there is some sort of business logic. It knows that he has to call update method on its inner fragments. Currently I have only one presenter instance for outside and inner fragment and in inner fragment I call getParentFragment() to access the public method of presenter. But in this way the view is too much dependent each other

aeroxr1 avatar May 28 '19 11:05 aeroxr1