package com.minano.themovielibrary.controllers;

import android.os.AsyncTask;

import com.minano.themovielibrary.helpers.ITVShowJSONParser;
import com.minano.themovielibrary.models.TVShowItem;

/**
 * Created by Admin on 18/09/2016.
 */
public class TVShowItemCaller extends AsyncTask<Void, Void, TVShowItem> {

    private TVSHOWItemCallerResponse callerResponse;
    private String stringUrl;
    private ITVShowJSONParser parser;

    public TVShowItemCaller(String stringUrl, ITVShowJSONParser parser, TVSHOWItemCallerResponse callerResponse) {
        this.callerResponse = callerResponse;
        this.stringUrl = stringUrl;
        this.parser = parser;
    }

    @Override
    protected TVShowItem doInBackground(Void... params) {
        TVShowItem item = new TVShowController().getTVShowItem(stringUrl, parser);
        return item;
    }

    @Override
    protected void onPostExecute(TVShowItem tvShowItem) {
        callerResponse.onCompleted(tvShowItem);
    }
}