Lib下的MVP层
框架结构图
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/d671b871cc40f2791a0fd9588f84de2e.png#pic_center)
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