mvp

How should I pass data (e.g. which item was clicked) between Activities in MVP?

风流意气都作罢 提交于 2019-12-10 12:44:01
问题 I have list of items shown with MVP pattern. View is an Activity (a.k.a. ItemsList ). I want to show next Activity (also MVP'ed, a.k.a. ItemDetails ) with details of item clicked in ItemsList . Model for ItemsList is fed with data from Repository. So actually it's RMVP. It looks like this: |->Model<->Presenter<->View [ItemsList] Repository<-| |->Model<->Presenter<->View [ItemDetails] So Model for ItemsList already knows exactly what Model item was clicked so I could pass it right away from

Register a Presenter with a View

北慕城南 提交于 2019-12-10 11:27:03
问题 If I have a presenter like this - public class LandingPresenter : ILandingPresenter { private ILandingView _view { get; set; } private IProductService _productService { get; set; } public LandingPresenter(ILandingView view, IProductService) { .... } } How do I register this Presenter with Autofac considering the dependent view will not be registered (but IProductService will) builder.RegisterType<LandingPresenter>().As<ILandingPresenter>(); ???? 回答1: Why not register the views in the

Wiring View, Model and Presenter dynamically, by convention / reflection

纵然是瞬间 提交于 2019-12-10 10:46:49
问题 I'm trying to develop an application using the MVP pattern. The problem is wiring all the code manually. I was hoping to reduce the code needed. I tried to copy another solution, but I couldn't get to work. I'm using Winforms and the solution I was using as source is using WPF. It would wire things on some conventions: View events are wired by name. For example:"Loaded" event on the view will be wired to the "OnLoaded()" method on the presenter Button commands are wired by name. For example:

Why do Presenters attach to View events instead of View calling Presenter Methods in most ASP.NET MVP implementations?

青春壹個敷衍的年華 提交于 2019-12-10 10:28:15
问题 I noticed that in the Webforms MVP implementation and most other examples, the Presenter usually attaches handlers to View events. Why can't the Views just call methods in the presenter directly? Just wondering, since the whole task of attaching a handler to an event, defining EventArgs for special parameters, checking if the event is null on the view side seems a lot more tedious than just calling a method. 回答1: Sure they can, and I find that to be the best middle ground. What you are

Android MVP 模式 项目初体验(一)

老子叫甜甜 提交于 2019-12-09 20:36:07
版权声明:本文出自veidy的博客,转载必须注明出处 转载请注明出处 : http://my.oschina.net/aibenben/blog/381274 之前大家听得最多的是MVC,去年 去中兴面试的时候被问到MVP,当时脑子里面第一个想到是NBA 詹姆士,哈哈哈。那是第一次听到MVP模式,后面也没注意,再后面又听到别人提起,于是百度了解了一下。 什么是MVP? 为什么要用MVP? 怎么在Android上实现MVP? 我再这里给大家推荐一篇博客: ym——Android开发MVP模式(解决了View和Model的耦合) 不多说了,我写了一个登录的Demo,直接拿来分析MVP在项目中的使用吧。 大家先看看目录结构 先看M层 model里面我写了一个接口LoginModel,一个实现类LoginModelImple然后还有一个接口OnLoginListener 先看LoginModel 再看LoginModelImple 接着我们看V层 View里面我写了一个接口LoginView 然后,在登录这个Activity 去实现这个接口,并实现其抽象方法。即看LoginActivity 最后我们看P层。 这是很重要的一个环节 我们不是要登录吗?所以我们在LoginPresenter里面写一个方法login(),然后我们在ActiviLoginActivity点击登录按钮后调这个方法。

【腾讯Bugly干货分享】一步一步实现Android的MVP框架

寵の児 提交于 2019-12-09 20:17:03
本文来自于 腾讯bugly开发者社区 ,非经作者同意,请勿转载,原文地址: http://dev.qq.com/topic/5799d7844bef22a823b3ad44 内容大纲: Android 开发框架的选择 如何一步步搭建分层框架 使用 RxJava 来解决主线程发出网络请求的问题 结语 一、Android开发框架的选择 由于原生 Android 开发应该已经是一个基础的 MVC 框架,所以在初始开发的时候并没有遇到太多框架上的问题,可是一旦项目规模到了一定的程度,就需要对整个项目的代码结构做一个总体上的规划,最终的目的是使代码可读,维护性好,方便测试。’ 只有项目复杂度到了一定程度才需要使用一些更灵活的框架或者结构,简单来说,写个 Hello World 并不需要任何第三方的框架 原生的 MVC 框架遇到大规模的应用,就会变得代码难读,不好维护,无法测试的囧境。因此,Android 开发方面也有很多对应的框架来解决这些问题。 构建框架的最终目的是增强项目代码的 可读性 , 维护性 和 方便测试 ,如果背离了这个初衷,为了使用而使用,最终是得不偿失的 从根本上来讲,要解决上述的三个问题,核心思想无非两种:一个是 分层 ,一个是 模块化 。两个方法最终要实现的就是解耦,分层讲的是纵向层面上的解耦,模块化则是横向上的解耦。下面我们来详细讨论一下 Android

【腾讯Bugly干货分享】基于RxJava的一种MVP实现

陌路散爱 提交于 2019-12-09 20:15:09
本文来自于 腾讯bugly开发者社区 ,非经作者同意,请勿转载,原文地址: http://dev.qq.com/topic/57bfef673c1174283d60bac0 Dev Club 是一个交流移动开发技术,结交朋友,扩展人脉的社群,成员都是经过审核的移动开发工程师。每周都会举行嘉宾分享,话题讨论等活动。 本期,我们邀请了腾讯IEG Android 开发工程师——戴俊,为大家分享《基于RxJava的一种MVP实现》。 分享内容简介: RxJava是一个实现Java响应式编程的库,让异步事件以序列的形式组织。MVP则通常用来将View业务层与Model层分离开来,两者结合起来可轻松实现业务解耦、线程控制、单元测试等等强大功能 内容大体框架: Android开发框架的选择 如何一步步搭建MVP分层框架 使用RxJava来进行线程控制 结语 下面是本期分享内容整理 Hello,大家好,我是戴俊。目前在IEG腾讯动漫主要负责Android端的开发工作。 第一次进行这种微信群的分享,如果有任何疑问,欢迎大家在分享结束后提问。下面开始我们今天的分享。 1. Android开发框架的选择 我们知道原生Android开发已经是一个基础的MVC框架,所以在项目刚开始开发的时候并没有遇到太多问题。 对一个经典的Android MVC框架来讲,它的结构大概是下面这样(图片来自参考文献)

Android -------- MVC,MVP 和 MVVM 架构设计模式

流过昼夜 提交于 2019-12-09 13:39:17
MVC(Model-View-Controller)是最常见的软件架构之一,业界有着广泛应用。它本身很容易理解,但是要讲清楚,它与衍生的 MVP 和 MVVM 架构的区别就不容易了。 一、MVC MVC模式的意思是,软件可以分成三个部分。 视图(View):用户界面。 控制器(Controller):业务逻辑 模型(Model):数据保存 各部分之间的通信方式如下。 View 传送指令到 Controller Controller 完成业务逻辑后,要求 Model 改变状态 Model 将新的数据发送到 View,用户得到反馈 所有通信都是单向的。 MVC优点: 耦合性低 重用性高 生命周期成本低 部署快 可维护性高 有利软件工程化管理 MVC缺点: 没有明确的定义 不适合小型,中等规模的应用程序 增加系统结构和实现的复杂性 视图与控制器间的过于紧密的连接 视图对模型数据的低效率访问 一般高级的界面工具或构造器不支持模式 在MVC里,View是可以直接访问Model的。从而,View里会包含Model信息,不可避免的还要包括一些业务逻辑。 在MVC模型里,更关注的Model的不变,而同时有多个对Model的不同显示,及View。 所以,在MVC模型里,Model不依赖于View,但是View是依赖于Model的。不仅如此,因为有一些业务逻辑在View里实现了

GWT Editors framework - ListEditor, removing items, MVP violation

人盡茶涼 提交于 2019-12-09 13:30:14
问题 public class PersonListEditor extends Composite implements IsEditor<ListEditor<Person, PersonListItemWidget>> { private static PersonListEditorUiBinder uiBinder = GWT.create(PersonListEditorUiBinder.class); interface PersonListEditorUiBinder extends UiBinder<Widget, PersonListEditor> {} private class Source extends EditorSource<PersonListItemWidget> { @Override public PersonListItemWidget create(int index) { PersonListItemWidget widget = new PersonListItemWidget(); panel.insert(widget, index)

What is the advantage of the MVP pattern (GWT)

ぐ巨炮叔叔 提交于 2019-12-09 13:13:12
问题 I just read this article and it did confuse me a lot. Secondly, this model allows us to minimize our use of GWTTestCase, which relies on the presence of a browser, and, for the bulk of our code, write lightweight (and fast) JRE tests (which don't require a browser). [1] Is this the whole benefit, I have from following this design pattern? It seems to make the code more complex... Do you use this pattern? 回答1: I have to disagree, MVP makes code way less complex, especially in case of GWT. If