zoukankan      html  css  js  c++  java
  • android mvp高速开发框架介绍(继续dileber)

    android mvp框架:dileber(https://github.com/dileber/dileber.git

    继续为大家介绍android mvp开源框架 dileber

    官方交流qq群:171443726

    我个人qq:297165331~~有什么问题也能够咨询~~


    这节5主要介绍 主要功能  presenter 和 delegate的使用

     

    写一个类继承于AppViewDelegate

    public class SplashViewDelegate extends AppViewDelegate{
    
    
        @Override
        public int getRootLayoutId() {
            return R.layout.activity_splash;
        }
    
        LinearLayout splash_layout;
        ImageView imageView;
    
        @Override
        public void initWidget() {
            super.initWidget();
            splash_layout = bindView(R.id.splash_layout);
            imageView = bindView(R.id.imageView);
        }
    
    }

    如图须要实现 getRootLayoutId方法,这种方法主要就是返回 splashactivity的layout

    SplashViewDelegate
    这个delegate就是专门为splashactivity产生的类

    initwidget就是能够初始化一些组件

    你能够把你要初始化的组件放到这里,还能够在这个类里写一些展示效果

    展示效果能够写到view接口

    再通过对接口的编程。达到须要的效果

    implements ISplashView{


    假设你想获得当前activity

    则能够使用


    getActivity();

    获得当前layout

    getRootView()



    然后開始解说 presenter了


    首先我想讲两个特殊的注解

    @CloseStatusBar
    @CloseTitle
    public class SplashActivity extends ActivityPresenter<SplashViewDelegate>  {
    
    一个是

    @CloseStatusBar
    他的作用是能够使得当前activity全屏


    一个是

    @CloseTitle
    他的作用是能够使得当前activity的title消失


    上面的两个注解主要为了方便开发


    presenter一般使用代码例如以下


    public class SplashActivity extends ActivityPresenter<SplashViewDelegate>  {
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            ISplashScm imageSrc = new SplashScm();
            imageSrc.showSplashResourceImage((ImageView) viewDelegate.get(R.id.imageView));
    
            GoodsListScm goodsListScm = new GoodsListScm();
            goodsListScm.getGoodsList(null, null, null, null, null, new OnGoodsListListener<GoodsModel>() {
                @Override
                public void before() {
                    viewDelegate.loading();
                }
    
                @Override
                public void success(GoodsModel model) {
                    String ss = HJson.toJson(model);
                    SLog.i(">>>>>>",ss);
                    viewDelegate.loadDialogDismiss();
                }
    
                @Override
                public void failed() {
                    viewDelegate.loadDialogDismiss();
                }
            });
    
    
    
        }
    
        @Override
        protected Class<SplashViewDelegate> getDelegateClass() {
            return SplashViewDelegate.class;
        }
    
        @Override
        protected void bindEvenListener() {
            super.bindEvenListener();
        }
    
    
        @Override
        public void onClick(View view) {
    
        }
    }
    


    你能够在bindevenlistener中编写监听器代码。

    例如以下


    @Override
    protected void bindEvenListener() {
        super.bindEvenListener();
        
        viewDelegate.setOnClickListener(this,R.id.mask_left);
    }
    或者例如以下

    viewDelegate.setOnClickListener(this,R.id.mask_left,R.id.confirm_button);
    或者例如以下

    viewDelegate.setOnClickListener(this,button1,view2,view3);

    假设你想展示 toast

    我写了一个自己定义的toast帮助你使用

    viewDelegate.toast("ddddd", Toast.LENGTH_SHORT);

    另一个不错的 载入框


    viewDelegate.loading();


    viewDelegate.loadDialogDismiss();

    注意成对使用

    另一个确定取消框

    viewDelegate.dialogOk("eeee", new DialogLinstener() {
        @Override
        public void confirm(Dialog dialog) {
            
        }
    
        @Override
        public void cancel(Dialog dialog) {
    
        }
    });

    错误对话框

    viewDelegate.showAlert(SplashViewDelegate.DIALOG_ERROR,"ddd");
    

    成功对话框


    viewDelegate.showAlert(SplashViewDelegate.DIALOG_SUCCESS,"ddd");
    

    最主要的使用就是这么多了


    下节我将对我封装的一些好用的工具进行解说







  • 相关阅读:
    mybatis批量操作
    获取datagrid中编辑列combobox的value值与text值
    easyui editor combobox multiple
    Spring mvc Interceptor 解决Session超时配置流程
    Error In Work
    jquery.min.map 404 (Not Found)出错的原因及解决办法
    Ubuntu 14.10安装SecureCRT 7.3
    UEFI引导修复教程和工具
    MySQL 模拟Oracle邻接模型树形处理
    Linux下玩转Dota2
  • 原文地址:https://www.cnblogs.com/gccbuaa/p/7235850.html
Copyright © 2011-2022 走看看