// Path: app/src/main/java/com/YC2010/MyClass/callbacks/AsyncTaskCallbackInterface.java
// public interface AsyncTaskCallbackInterface {
//     public void onOperationComplete(Bundle bundle);
// }
// 
// Path: app/src/main/java/com/YC2010/MyClass/data/fetchtasks/CatalogNumFetchTask.java
// public class CatalogNumFetchTask extends AsyncTask<String, Void, Bundle> {
// 
//     private Activity mActivity;
//     AsyncTaskCallbackInterface mAsyncTaskCallbackInterface;
//     private ArrayList<String> mCatalogNum_arraylist = new ArrayList<>();
//     private String mSubject;
//     public CatalogNumFetchTask(String subject, AsyncTaskCallbackInterface asyncTaskCallbackInterface) {
//         mAsyncTaskCallbackInterface = asyncTaskCallbackInterface;
//         mSubject = subject;
//     }
// 
//     @Override
//     protected Bundle doInBackground(String...params) {
//         Bundle result = new Bundle();
//         fetchCourse(result);
// 
//         return result;
//     }
// 
//     private Bundle fetchCourse(Bundle bundle) {
//         try{
//             String url = Connections.getCatalogNumURL(mSubject);
// 
//             JSONObject jsonObject = Connections.getJSON_from_url(url);
//             JSONArray subject_array = jsonObject.getJSONArray("data");
//             Log.d("SubjectFetchTask", "subject array is " + subject_array.length());
// 
//             for(int i = 0; i < subject_array.length(); i++){
//                 JSONObject subject = subject_array.getJSONObject(i);
//                 mCatalogNum_arraylist.add(i,mSubject + " " +  subject.getString("catalog_number"));
//             }
// 
//             bundle.putStringArrayList("CatalogNum_arraylist", mCatalogNum_arraylist);
// 
//             return bundle;
// 
//         } catch (Exception e) {
//             e.printStackTrace();
//         }
//         return bundle;
//     }
// 
//     @Override
//     protected void onPostExecute(Bundle bundle) {
//         mAsyncTaskCallbackInterface.onOperationComplete(bundle);
//     }
// 
// 
// }


import android.app.ListFragment;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import com.YC2010.MyClass.callbacks.AsyncTaskCallbackInterface;
import com.YC2010.MyClass.data.fetchtasks.CatalogNumFetchTask;
import com.YC2010.MyClass.R;
import java.util.ArrayList;
package com.YC2010.MyClass.ui.fragments;




/**
 * A fragment representing a list of Items.
 * <p/>
 * <p/>
 * Activities containing this fragment MUST implement the {@link OnFragmentInteractionListener}
 * interface.
 */
public class CatalogNumFragment extends ListFragment {

    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
    private static final String ARG_SUBJECT = "SUBJECT";

    // TODO: Rename and change types of parameters
    private String mParam1;
    private String mParam2;
    private String mSubject;

    ArrayList<String> mCatalogNum_arraylist;
    AlertDialog.Builder mBuilder;

    private OnFragmentInteractionListener mListener;

    // TODO: Rename and change types of parameters
    /*public static CatalogNumFragment newInstance(String param1, String param2) {
        CatalogNumFragment fragment = new CatalogNumFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }*/

    public CatalogNumFragment(){
    }

    /**
     * Mandatory empty constructor for the fragment manager to instantiate the
     * fragment (e.g. upon screen orientation changes).
     */
    public void setSubject(String subject) {
        mSubject = subject;
    }


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        String subject = getArguments().getString(ARG_SUBJECT);
        if(subject == null)
            Toast.makeText(getActivity(), "subject string not found", Toast.LENGTH_SHORT).show();
        mSubject = subject;

// Path: app/src/main/java/com/YC2010/MyClass/callbacks/AsyncTaskCallbackInterface.java
// public interface AsyncTaskCallbackInterface {
//     public void onOperationComplete(Bundle bundle);
// }
// 
// Path: app/src/main/java/com/YC2010/MyClass/data/fetchtasks/CatalogNumFetchTask.java
// public class CatalogNumFetchTask extends AsyncTask<String, Void, Bundle> {
// 
//     private Activity mActivity;
//     AsyncTaskCallbackInterface mAsyncTaskCallbackInterface;
//     private ArrayList<String> mCatalogNum_arraylist = new ArrayList<>();
//     private String mSubject;
//     public CatalogNumFetchTask(String subject, AsyncTaskCallbackInterface asyncTaskCallbackInterface) {
//         mAsyncTaskCallbackInterface = asyncTaskCallbackInterface;
//         mSubject = subject;
//     }
// 
//     @Override
//     protected Bundle doInBackground(String...params) {
//         Bundle result = new Bundle();
//         fetchCourse(result);
// 
//         return result;
//     }
// 
//     private Bundle fetchCourse(Bundle bundle) {
//         try{
//             String url = Connections.getCatalogNumURL(mSubject);
// 
//             JSONObject jsonObject = Connections.getJSON_from_url(url);
//             JSONArray subject_array = jsonObject.getJSONArray("data");
//             Log.d("SubjectFetchTask", "subject array is " + subject_array.length());
// 
//             for(int i = 0; i < subject_array.length(); i++){
//                 JSONObject subject = subject_array.getJSONObject(i);
//                 mCatalogNum_arraylist.add(i,mSubject + " " +  subject.getString("catalog_number"));
//             }
// 
//             bundle.putStringArrayList("CatalogNum_arraylist", mCatalogNum_arraylist);
// 
//             return bundle;
// 
//         } catch (Exception e) {
//             e.printStackTrace();
//         }
//         return bundle;
//     }
// 
//     @Override
//     protected void onPostExecute(Bundle bundle) {
//         mAsyncTaskCallbackInterface.onOperationComplete(bundle);
//     }
// 
// 
// }


// Path: app/src/main/java/com/YC2010/MyClass/ui/fragments/CatalogNumFragment.java
import android.app.ListFragment;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import com.YC2010.MyClass.callbacks.AsyncTaskCallbackInterface;
import com.YC2010.MyClass.data.fetchtasks.CatalogNumFetchTask;
import com.YC2010.MyClass.R;
import java.util.ArrayList;

package com.YC2010.MyClass.ui.fragments;




/**
 * A fragment representing a list of Items.
 * <p/>
 * <p/>
 * Activities containing this fragment MUST implement the {@link OnFragmentInteractionListener}
 * interface.
 */
public class CatalogNumFragment extends ListFragment {

    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
    private static final String ARG_SUBJECT = "SUBJECT";

    // TODO: Rename and change types of parameters
    private String mParam1;
    private String mParam2;
    private String mSubject;

    ArrayList<String> mCatalogNum_arraylist;
    AlertDialog.Builder mBuilder;

    private OnFragmentInteractionListener mListener;

    // TODO: Rename and change types of parameters
    /*public static CatalogNumFragment newInstance(String param1, String param2) {
        CatalogNumFragment fragment = new CatalogNumFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }*/

    public CatalogNumFragment(){
    }

    /**
     * Mandatory empty constructor for the fragment manager to instantiate the
     * fragment (e.g. upon screen orientation changes).
     */
    public void setSubject(String subject) {
        mSubject = subject;
    }


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        String subject = getArguments().getString(ARG_SUBJECT);
        if(subject == null)
            Toast.makeText(getActivity(), "subject string not found", Toast.LENGTH_SHORT).show();
        mSubject = subject;

        final CatalogNumFetchTask catalogNumFetchTask = new CatalogNumFetchTask(mSubject, new AsyncTaskCallbackInterface() {