package com.wasu.cs.mvp.presenter;

import com.wasu.cs.model.CartoonStarModel;
import com.wasu.cs.mvp.IView.ICartoonStarView;
import com.wasu.cs.utils.JsonUtil;
import com.wasu.module.datafetch.DataFetchListener;
import com.wasu.module.datafetch.DataFetchModule;

import org.json.JSONObject;

/**
 * Created by chenming on 2016/11/28.
 *
 * @Description: 少儿品牌专区页面presenter
 * @email chenming@wasu.com
 */

public class CartoonStarPresenter extends BasePresenter<ICartoonStarView> {

	CartoonStarModel model;

	public void getCartoonStarData(String url) {
		DataFetchModule.getInstance().fetchJsonGet(url, new DataFetchListener.JsonListener() {
			@Override
			public void onJsonGet(int i, String s, JSONObject jsonObject) {
				if (jsonObject != null && model == null) {
					model = JsonUtil.fromJson(jsonObject.toString(), CartoonStarModel.class);
					CartoonStarPresenter.this.getMvpView().onGetDataSucceed(model);
				} else if (jsonObject == null && model == null) {
					CartoonStarPresenter.this.getMvpView().onGetDataFailed(new Throwable("BrandArea get data failed"));
				}
			}
		});
	}
}
