package com.minano.themovielibrary.controllers;

import android.os.AsyncTask;

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

import java.util.List;

/**
 * Created by Admin on 07/09/2016.
 */

public class ItemCaller extends AsyncTask<Void, Void, List<DetailItem>> {

    private ItemCallerResponse callerResponse;
    private String stringUrl;
    private IJSONParser parser;

    public ItemCaller(String stringUrl, IJSONParser parser, ItemCallerResponse callerResponse){
        this.callerResponse=callerResponse;
        this.stringUrl = stringUrl;
        this.parser = parser;
    }

    @Override
    protected List<DetailItem> doInBackground(Void... params) {
        List<DetailItem> itemList = new ItemController().getItemList(stringUrl, parser);
        return itemList;
    }

    @Override
    protected void onPostExecute(List<DetailItem> itemList) {
        callerResponse.onCompleted(itemList);
    }
}