android10 / android10/Android-CleanArchitecture
What about communicate between presenters?
- Dominant language
- Java
- Stars
- 15.5k
- Forks
- 3.3k
- PR merge metrics
- No merged PRs in 30d
Description
I need show progressbar in parent fragment in case if child fragment has needed state (for example count elements in `ListView`).
To solve the problem it is necessary that the presenters were able to communicate. The `MainPresenter` should know about entities size in the `ChildPresenter`. Is it correct from the point of view MVP if the presenter will know about another presenter? And how this approach can be implemented in Clean Architecture?
``` java
====== Main =======
public interface MainView {
void showLoading();
}
public class MainFragment implements MainView {
ChildFragment childFragment;
private void init(){
childFragment = new ChildFragment();
view.add(childFragment);
}
public void showLoading(){
// show progressbar
}
}
public class MainPesenter {
public void showLoading() {
getView().showLoading(); //show only if ChildPresenter has count > 0
}
}
====== Child =======
public interface ChildView {
void showList(List entities);
}
public class ChildFragment implements ChildView {
public void showList(List entities) {
//show list on UI
}
}
public class ChildPresenter {
List entities;
public void init() {
entities = getEntities();
getView().showList(entities);
}
public int getCount(){
return entities.size();
}
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.