package com.casic.dcms.mvp.presenter;

import com.casic.dcms.bean.HomePageBean;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.HomePageModelImpl;
import com.casic.dcms.mvp.view.IHomePageView;

public class HomePagePresenterImpl extends BasePresenter implements IHomePagePresenter, HomePageModelImpl.OnGetPageResultListener {

    private IHomePageView view;
    private HomePageModelImpl actionModel;

    public HomePagePresenterImpl(IHomePageView homePageView) {
        this.view = homePageView;
        actionModel = new HomePageModelImpl(this);
    }

    @Override
    public void onReadyRetrofitRequest(String resourceType) {
        addSubscription(actionModel.sendRetrofitRequest(resourceType));
    }

    @Override
    public void disposeRetrofitRequest() {
        unSubscription();
    }


    @Override
    public void onSuccess(HomePageBean pageBean) {
        view.obtainHomePageResult(pageBean);
    }

    @Override
    public void onFailure(Throwable throwable) {

    }
}
