摘要
MVC(Model-View-Controller)模式是Android应用开发的传统方式(用Activity/Fragment表示Controller层,用XML文件表示View层),随着项目的页面增多,逻辑复杂度提升,将使Activity文件变得臃肿,代码耦合度明显提高,不利于项目后期的升级和维护。通过对传统MVC开发模式与主流MVP(Model-View-Presenter)开发模式进行研究和比较,发现MVP开发模式能够更好地解决上述问题。同时,官方HttpURLConnection类对于HTTP网络请求的效率无法满足业务需求,而Retrofit2+OkHttp3+RxJava2的响应式网络请求框架具有更高的响应效率。以《长光卫星云极视》项目为背景,研究并验证MVP模式和Retrofit2+OkHttp3+RxJava2的响应式网络请求框架结合的可行性。
MVC(Model-View-Controller)mode is the traditional way of Android application development(Activity/Fragment is used to represent the Controller layer and XML files are used to represent the View layer).As the number of project pages increases,the logic complexity increases,and the Activity file becomes bloated and the code coupling is obvious.Improvement is not conducive to the upgrade and maintenance of the project later.By studying and comparing the traditional MVC development model and the mainstream MVP(Model-View-Presenter)development model,it is found that the MVP development model can better solve the above problems.At the same time,the efficiency of the official HttpURLConnection class for HTTP network requests can not meet business needs,and the responsive network request framework of Retrofit2+OkHttp3+RxJava2 has higher response efficiency.Based on the"Changguang Satellite Cloud Extreme Vision"project as the background,this paper studies and verifies the feasibility of combining the MVP mode with the responsive network request framework of Retrofit2+OkHttp3+RxJava2.
作者
李想
特日根
Li Xiang;Te Rigen(Chang Guang Satellite Technology Co.,Ltd.,Changchun 130000,China;Main Laboratory of Satellite Remote Sensing Technology of Jilin Province,Changchun 130000,China;Changchun Institute of Optics,Fine Mechanics and Physics,Chinese Academy of Sciences,Changchun 130000,China)
出处
《电子技术应用》
2021年第2期49-53,57,共6页
Application of Electronic Technique
基金
国家重点研发计划(2018YFB1004605)
吉林省科技计划-科技创新中心项目(20180623058TC)。