admin 管理员组文章数量: 887021
2024年1月13日发(作者:特效素材中国免费素材网)
XXXPresenter(IView view) {mView = view;mModel = newModel();}@OverridepublicvoidinitData(){ading();t(xx, xx, mCallback);}@Overridepublicvoidcommit(){ading();t(xx, xx, mCallback);}}View:interfaceIView{voidupdateHeader(String header);voidupdateContent(String content);voidshowLoading();voidcancelLoading();voidshowError(String error);}publicclassXXXActivityextendsBaseActivityimplementsIView{privateIPresenter mPresenter;privateTextView tvHeader;privateTextView tvContent;publicvoidonCreate(Bundle saveInstanceState){
publicvoidonCreate(Bundle saveInstanceState){te(saveInstanceState);setContentView(layout);initView();initData();}publicvoidinitView(){tvHeader = findViewById(..);tvContent = findViewById(..);lickListener( newOnClickListener(){publicvoidonClick(View v){();}});}publicvoidinitData(){mPresenter = newXXXPresenter( this);ta();}@OverridepublicvoidupdateHeader(String header){t(header);}@OverridepublicvoidupdateContent(String content){t(content);}
publicinterfaceBaseView{publicvoidshowLoading();publicvoidcancelLoading();publicvoidshowError();}// BaseActivitypublicclassBaseActivityextendsActivityimplementsBaseView{publicvoidshowLoading(){ading( this);}publicvoidcancelLoading(){Loading( this);}publicvoidshowError(){ror( this);}}BasePresenter// BasePresenterpublicabstractclassBasePresenter
onRequestSuccess(r);}publicvoid(Error e){ror();onRequestFailed(e);}};protectedabstractvoidonRequestSuccess(Response r);protectedabstractvoidonRequestFailed(Error e);}Contract// Contractinterace Contract {interfaceViewextendsBaseView{voidupdateHeader(String header);voidupdateContent(String content);}abstractclassPresenterextendsBasePresenter
{ter mPresenter;privateTextView tvHeader;privateTextView tvContent;publicvoidonCreate(Bundle saveInstanceState){te(saveInstanceState);setContentView(layout);initView();initData();}publicvoidinitView(){tvHeader = findViewById(..);tvContent = findViewById(..);lickListener( newOnClickListener(){publicvoidonClick(View v){();}});}publicvoidinitData(){mPresenter = newXXPresenter( this);ta();}@OverridepublicvoidupdateHeader(String header){t(header);}
版权声明:本文标题:AndroidMVP开发模式-Contract用法 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/free/1705140509h474383.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论