package com.chrisahn.popularmovies;

import android.os.AsyncTask;

import java.util.ArrayList;

public class FetchMovieTask extends AsyncTask<String, Void, ArrayList<MovieData> > {

    // Interface to send data back to Fragment/Activity
    public interface AsyncResultCallBack {
        void processData(ArrayList<MovieData> arrMovieData);
    }

    @Override
    protected ArrayList<MovieData> doInBackground(String... params) {
        return null;
    }

    @Override
    protected void onPostExecute(ArrayList<MovieData> movieDatas) {
        super.onPostExecute(movieDatas);
    }
}

@@ -49,22 +49,248 @@
 oid.
-os.AsyncTask;%0A
+net.Uri;%0Aimport android.os.AsyncTask;%0Aimport android.util.Log;%0A%0Aimport java.io.BufferedReader;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.InputStreamReader;%0Aimport java.net.HttpURLConnection;%0Aimport java.net.URL;
 %0Aimp
@@ -401,16 +401,90 @@
 a%3E %3E %7B%0A%0A
+    private final String LOG_TAG = FetchMovieTask.class.getSimpleName();%0A%0A
     // I
@@ -722,24 +722,2599 @@
 . params) %7B%0A
+        HttpURLConnection urlConnection = null;%0A        BufferedReader bufferedReader = null;%0A%0A        String jsonResponseStr;%0A%0A        try %7B%0A            final String BASE_URL = %22https://api.themoviedb.org/3/discover/movie?%22;%0A            final String SORT_PARAM = %22sort_by%22;%0A            final String API_KEY_PARAM = %22api_key%22;%0A%0A            // Build URI%0A            Uri uri = Uri.parse(BASE_URL).buildUpon()%0A                    .appendQueryParameter(SORT_PARAM, params%5B0%5D)%0A                    .appendQueryParameter(API_KEY_PARAM, BuildConfig.MOVIE_DB_KEY)%0A                    .build();%0A%0A            // Convert to URL and Log current URL%0A            URL url = new URL(uri.toString());%0A            Log.v(LOG_TAG, %22Final URL: %22 + uri.toString());%0A%0A            // Create request to Movie DB API and open connection%0A            urlConnection = (HttpURLConnection) url.openConnection();%0A            urlConnection.setRequestMethod(%22GET%22);%0A            urlConnection.connect();%0A%0A            // Gather InputStream data and read into the BufferedReader%0A            InputStream inputStream = urlConnection.getInputStream();%0A            StringBuffer jsonStringBuffer = new StringBuffer();%0A%0A            // Check for a response from connection%0A            if (inputStream == null)%0A            %7B%0A                Log.e(LOG_TAG, %22Empty InputStream, no response%22);%0A                return null;%0A            %7D%0A%0A            // Read InputStream into BufferedReader%0A            bufferedReader = new BufferedReader(new InputStreamReader(inputStream));%0A%0A            // Read each line of bufferedReader and append into jsonStringBuffer%0A            String line;%0A            while ((line = bufferedReader.readLine()) != null) %7B%0A                // Append with new-line for readability%0A                jsonStringBuffer.append(line + %22%5Cn%22);%0A            %7D%0A%0A            if (jsonStringBuffer.length() == 0) %7B%0A                // Empty Stream%0A                Log.e(LOG_TAG, %22Empty StringBuffer%22);%0A                return null;%0A            %7D%0A%0A            jsonResponseStr = jsonStringBuffer.toString();%0A        %7D catch (IOException e) %7B%0A            Log.e(LOG_TAG, %22Error %22, e);%0A            return null;%0A        %7D finally %7B%0A            // Close connections%0A            if (urlConnection != null) %7B%0A                urlConnection.disconnect();%0A            %7D%0A            if (bufferedReader != null) %7B%0A                try %7B%0A                    bufferedReader.close();%0A                %7D catch (final IOException e) %7B%0A                    Log.e(LOG_TAG, %22Error closing stream%22, e);%0A                %7D%0A            %7D%0A        %7D%0A
         retu

Implement call to movie db api