https://blog.youkuaiyun.com/lmj623565791/article/details/46596109
针对以上博客内容,进一步梳理内容
(一)Model层(业务逻辑和实体模型)
实体类:
User =>String username
=>String password
业务逻辑:
登录操作 --->定义接口:IUserBiz =>Login(String username,String passwrod,OnLoginListener loginListener)
登录操作是耗时操作,通过回调接口来反馈相应的通知状态 --->定义接口:OnLoginListener =>loginSuccess()
=>loginFailed()
实现类:
UserBiz implements IUserBiz
实现login方法 =>成功调用loginListener.loginSuccess()
=>失败调用loginListener.loginFailed()
(二)View层
View层需要提供和进行的操作,定义为接口ILoginView
=>getUserName() getPassword()
=>showLoading() hideLoading()
=>toMainActivity() showFailedError() (登录成功和失败的View端显示)
=>clearUserName() clearPassword()
View的实现类
UserLoginActivity extends Activity implements ILgoinView
1.加载布局获取控件实例
2,实现接口方法,都是对视图控件的处理操作
3.绑定按钮的点击事件,进行Login操作,这里调用Presenter层的login,这里需要Presenter层传递View层的内容给Model层进行Login操作,所以实现类中需要实例化一个Presenter层类--->new UserLoginPresenter(this) =>this是传入的ILoginView的实现,也就是传给Presenter层View层的内容和操作
(三)Presenter层
作为连接Model和View的中间层,持有接口实例IUserBiz,IUserLoginView
方法login --->调用Model层的Login方法,使用View层的内容(都是通过接口获取)