package com.sipai.jspatrol.Base;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

/**
 * created by lvliming on 2020/3/23
 */
public abstract class BaseView<P extends BasePresenter,CONTRACT> extends AppCompatActivity {
    protected P p;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //弱引用
        p = getPresenter();
        //绑定
        p.bindView(this);

    }
    //从子类获取具体契约
    protected abstract P getPresenter();

    //让P层做什么需求
    public abstract CONTRACT getContract();

    //如果Presenter层出现了异常，需要告知View层
    public void  error(Exception e){

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        //解除绑定
        p.unBindView();
    }
}
