MVP+retrofit+解绑(自己总结)

时间:2020-12-18 21:15:29

model拼接字符串

public interface SS_model {
    @GET("getVideoListByKeyWord.do")
    Call<SS_bean> getassets(@Query("keyword") String keyword, @Query("pnum") String pnum);
}


这里在P层需要这样写(请求数据的时候)
public void ss(String s)
{

   Call<SS_bean> call=model.getassets(s,1+"");

}

//解绑的类

public abstract class BaseFragment<T extends Ipresenter> extends Fragment {

    T mPresenter;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        crratepresenter();
    }
    public  abstract  void  crratepresenter();

    @Override
    public void onDestroy() {
        super.onDestroy();
        mPresenter.detch();
    }
}
 

这里的fragment继承的需要更改

public  class Fragment1 extends BaseFragment<ShouYe_presenter> implements Shouye_view {