package com.minano.themovielibrary.controllers;

import android.os.AsyncTask;

import com.minano.themovielibrary.helpers.IFilmJSONParser;
import com.minano.themovielibrary.helpers.IJSONParser;
import com.minano.themovielibrary.models.DetailItem;
import com.minano.themovielibrary.models.FilmItem;

import java.util.List;

/**
 * Created by Admin on 13/09/2016.
 */
public class FilmItemCaller extends AsyncTask<Void, Void, FilmItem> {

    private FilmItemCallerResponse callerResponse;
    private String stringUrl;
    private IFilmJSONParser parser;

    public FilmItemCaller(String stringUrl, IFilmJSONParser parser, FilmItemCallerResponse callerResponse) {
        this.callerResponse = callerResponse;
        this.stringUrl = stringUrl;
        this.parser = parser;
    }

    @Override
    protected FilmItem doInBackground(Void... params) {
        FilmItem item = new FilmController().getFilmItem(stringUrl, parser);
        return item;
    }

    @Override
    protected void onPostExecute(FilmItem filmItem) {
        callerResponse.onCompleted(filmItem);
    }
}
