MVP到MVVM Android [英] MVP to MVVM Android

查看:137
本文介绍了MVP到MVVM Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自这里的一个人告诉我,MVVM比MVP更好,他告诉我许多专业人士和许多人,但我想知道我的MVP是否做得好还是你知道其他任何方式可能转换为MVVM。
这是使用Google MVP登录的。
我不会把所有的代码都放进去,但我会把文件夹和一些小解释:



-Model




  • 用户(简单用户pojo类)



-Presenter




  • 我有一个IGoogleLoginView的对象,我调用这些方法,但这里我有逻辑 createGoogleClient()登入() onActivityResult()的onStop() onStart() onDestroy()所有这些方法都来自我的接口在同一个包中 IGoogleSignIn

  • IGoogleSignIn - Presenter类中的所有方法



-View




  • googleSignIn()

  • goToMainActivity()



然后我调用方法我的MainActivity ...



我想知道在MVVM上做到这一点有多么不同,做什么会有什么变化,以及als o是不是在好地方?

解决方案

这是一个开始的知识库,你应该制作自己的项目并实施这些软件架构,以便采用适合您和项目的项目:






One guy from here told me that MVVM is better than MVP he told me many pros and many conts, but I'd like to know if my MVP is well done or if you know any other way maybe to convert to MVVM. It's a Sign in with Google MVP. I won't put all of the code but I'll put the folders and little explanation :

-Model

  • User (Simple user pojo class)

-Presenter

  • I have an object of my IGoogleLoginView where I call the methods, but here I have the logic createGoogleClient(),signIn(),onActivityResult(),onStop(), onStart(), onDestroy() all of those methods are from my interface inside the same package IGoogleSignIn
  • IGoogleSignIn - All of the methods from the Presenter class

-View

  • googleSignIn()
  • goToMainActivity()

And then I have my MainActivity where I call the methods...

I'm wondering how different could be to do that on MVVM and what would be the changes to do it, and also is something that it's not on the good place?

解决方案

Here is a knowledge base to get started, you should make your own project and implement these software architectures in order to adopt the one that works for you and your project:

Android Architecture Blueprints

Reactive Apps with MODEL-VIEW-INTENT - PART1 - Model

这篇关于MVP到MVVM Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆