codeestX / GeekNews

:books:A pure reading App based on Material Design + MVP + RxJava2 + Retrofit + Dagger2 + Realm + Glide
3.5k stars 826 forks source link

同页面多presenter问题 #104

Open luckyjmcc opened 7 years ago

luckyjmcc commented 7 years ago

想请教一下,如果同个activity或fragment有多个presenter,这种情况要怎么封装代码?

tengye commented 7 years ago

我也想知道怎么封装,一个的时候就好弄,多个的情况怎么封装?

zhdhr0000 commented 7 years ago

我个人的做法是用组合来解决这个 建立一个汇总Presenter继承各个接口,构造方法里面创建出多个需要的Presenter,分别调用子presenter对应的方法,在汇总presenter的attach和detach方法里面绑定和解绑各个presenter与View的关联 仅供参考