boredream / DesignResCollection

一个项目搞定全部主流框架 A collection of samples to discuss and showcase different architectural tools and patterns for Android apps.
481 stars 175 forks source link

Presenter 没有Android相关代码 #1

Open pqpo opened 7 years ago

pqpo commented 7 years ago

最近也在将公司原项目重构成MVP模式,以便于单元测试,但是发现很难做到 Presenter 没有Android相关代码,比如获取string,或者原先遗留方法中会调用到Android相关代码,再或者项目中有些变量直接存在了Application中。 还有页面销毁时,Presenter 如何做数据恢复。 以上两点有什么好的建议吗?

boredream commented 7 years ago

好问题~ 不过已有项目重构确实不太好整,string啥的可以参考ObservableDecorator的做法,写一个String提供器类,其中做处理真实环境getString,测试什么的 直接手动加个string啥的

销毁啥的暂时还没考虑到

Blankeer commented 7 years ago

可以看看Mosby Mvp框架,对页面意外销毁等做了相应的处理,我在用。官方地址:https://github.com/sockeqwe/mosby,我写的demo和分析:https://github.com/Blankeer/MVPMosbyDemo