package com.casic.dcms.mvp.presenter.impl;

import com.casic.dcms.bean.HomePageBean;
import com.casic.dcms.listener.OnGetPageResultListener;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.impl.HomePageModelImpl;
import com.casic.dcms.mvp.presenter.IHomePagePresenter;
import com.casic.dcms.mvp.view.IHomePageView;

public class HomePagePresenterImpl extends BasePresenter implements IHomePagePresenter, OnGetPageResultListener {

    private final IHomePageView view;
    private final HomePageModelImpl actionModel;

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

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

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


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

    @Override
    public void onFailure(Throwable throwable) {

    }
}
