MVP框架加载数据

这篇博客探讨了Lib下的MVP架构,详细介绍了框架的各个组件,包括M(model)接口与BaseModel,P(presenter)接口及BasePresenter,以及V(view)中的Activity、Fragment接口和基类。此外,还涵盖了app的实现部分,如contract、model、presenter模块,以及BaseQuick万能适配器的使用,最后展示了实际页面的实现效果。
摘要由CSDN通过智能技术生成

Lib下的MVP层

框架结构图

在这里插入图片描述

M:model接口

package com.example.lib.model;

public interface IModel {
   
    //销毁
    void distroy();
}


M:BaseModel class类

package com.example.lib.model;

public class BaseModel implements IModel {
   
    @Override
    public void distroy() {
   

    }
}


P:Presenter 接口

package com.example.lib.presenter;

public interface IPresenter {
   
    void distroy();//销毁
}


P:BasePresenter class类

package com.example.lib.presenter;

import com.example.lib.model.IModel;
import com.example.lib.view.IView;

public class BasePresenter<M extends IModel,V extends IView> implements IPresenter {
   
    protected M mModel;
    protected V mView;

    public BasePresenter(M mModel, V mView) {
   
        this.mModel = mModel;
        this.mView = mView;
    }

    @Override
    public void distroy() {
   

    }
}


V:view接口

package com.example.lib.view;

public interface IView {
   
    void showToast();//输出数据
}


V:Activity接口

package com.example.lib.view;

public interface IActivity  {
   
    int bindLayout();//绑定
    void initView();//初始化组件
    void initData();//初始化数据
}


V:Fragment接口

package com.example.lib.view;

public interface IFragment extends IActivity {
   
}

V:BaseFragment类

package com.example.lib.view;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.IdRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.lib.presenter.IPresenter;

public abstract class BaseFragment<P extends IPresenter> extends Fragment implements IFragment {
   
    protected P mPresenter;
    protected View inflate;


    public BaseFragment(P mPresenter, View inflate) {
   
        this.mPresenter = mPresenter;
        this.inflate = inflate
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值