問(wèn)題1.每個(gè)View都需要對(duì)應(yīng)一個(gè)Presenter,導(dǎo)致類太多
解決策略1:抽取基類BaseView和BasePresenter,相同功能的presenter實(shí)現(xiàn)代碼復(fù)用青柄。
同時(shí)可以用泛型BaseView<P extends BasePresenter> 和BasePresenter<V extends BaseView>
問(wèn)題2:View持有presenter的引用,presenter持有Model的引用优妙,Model如果在執(zhí)行耗時(shí)操作時(shí)用戶關(guān)閉應(yīng)用,就會(huì)導(dǎo)致內(nèi)存泄漏
解決策略:在Activity的ondestroy中調(diào)用presenter.onDetach(),釋放presenter對(duì)activity的引用孕惜。