// Path: app/src/main/java/com/github/istin/schedule/http/HttpJob.java
// public class HttpJob<Result> implements ThreadManager.IJob<Result> {
// 
//     private String mUrl;
// 
//     private Class<Result> mResultClass;
// 
//     public HttpJob(String pUrl, Class<Result> pResultClass) {
//         mUrl = pUrl;
//         mResultClass = pResultClass;
//     }
// 
//     @Override
//     public Result doJob() throws Exception {
//         InputStream inputStream = null;
//         InputStreamReader inputStreamReader = null;
//         BufferedReader bufferedReader = null;
//         try {
//             inputStream = HttpUtils.getInputStream(mUrl);
//             inputStreamReader = new InputStreamReader(inputStream, "UTF-8");
//             bufferedReader = new BufferedReader(inputStreamReader, 8192);
//             //return new Gson().fromJson(bufferedReader, returnedClass());
//             return new Gson().fromJson(bufferedReader, mResultClass);
//         } finally {
//             HttpUtils.close(inputStream);
//             HttpUtils.close(inputStreamReader);
//             HttpUtils.close(bufferedReader);
//         }
//     }
// 
//     public Class<Result> returnedClass() {
//         ParameterizedType parameterizedType = (ParameterizedType)getClass().getGenericSuperclass();
//         return (Class<Result>) parameterizedType.getActualTypeArguments()[0];
//     }
// }
// 
// Path: app/src/main/java/com/github/istin/schedule/manager/ThreadManager.java
// public class ThreadManager {
// 
//     public static final String APP_SERVICE_KEY = "thread:manager";
// 
//     public static ThreadManager get(Context pContext) {
//         return CoreApplication.get(pContext, APP_SERVICE_KEY);
//     }
// 
//     public interface IExecutionListener<Result> {
// 
//         void onJobStarted();
// 
//         void onDone(Result pResult);
// 
//         void onError(Exception e);
// 
//     }
// 
//     public interface IJob<Result> {
// 
//         Result doJob() throws Exception;
// 
//     }
// 
//     public <Result> void execute(final IJob<Result> pJob, final IExecutionListener<Result> pExecutionListener) {
//         pExecutionListener.onJobStarted();
//         final Handler handler = new Handler();
//         new Thread(new Runnable() {
//             @Override
//             public void run() {
//                 try {
//                     final Result result = pJob.doJob();
//                     handler.post(new Runnable() {
//                         @Override
//                         public void run() {
//                             pExecutionListener.onDone(result);
//                         }
//                     });
//                 } catch (final Exception e) {
//                     handler.post(new Runnable() {
//                         @Override
//                         public void run() {
//                             pExecutionListener.onError(e);
//                         }
//                     });
//                 }
//             }
//         }).start();
//     }
// 
// }


import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.StringRes;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import com.github.istin.schedule.http.HttpJob;
import com.github.istin.schedule.manager.ThreadManager;
package com.github.istin.schedule;



/**
 * Created by uladzimir_klyshevich on 10/6/15.
 */
public abstract class CommonHttpJobActivity<Result> extends AppCompatActivity implements ThreadManager.IExecutionListener<Result> {

    private EditText mSearchEditText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getContentViewLayout());
        mSearchEditText = (EditText) findViewById(R.id.search_edit_text);
        execute();
    }

    private void execute() {
// Path: app/src/main/java/com/github/istin/schedule/http/HttpJob.java
// public class HttpJob<Result> implements ThreadManager.IJob<Result> {
// 
//     private String mUrl;
// 
//     private Class<Result> mResultClass;
// 
//     public HttpJob(String pUrl, Class<Result> pResultClass) {
//         mUrl = pUrl;
//         mResultClass = pResultClass;
//     }
// 
//     @Override
//     public Result doJob() throws Exception {
//         InputStream inputStream = null;
//         InputStreamReader inputStreamReader = null;
//         BufferedReader bufferedReader = null;
//         try {
//             inputStream = HttpUtils.getInputStream(mUrl);
//             inputStreamReader = new InputStreamReader(inputStream, "UTF-8");
//             bufferedReader = new BufferedReader(inputStreamReader, 8192);
//             //return new Gson().fromJson(bufferedReader, returnedClass());
//             return new Gson().fromJson(bufferedReader, mResultClass);
//         } finally {
//             HttpUtils.close(inputStream);
//             HttpUtils.close(inputStreamReader);
//             HttpUtils.close(bufferedReader);
//         }
//     }
// 
//     public Class<Result> returnedClass() {
//         ParameterizedType parameterizedType = (ParameterizedType)getClass().getGenericSuperclass();
//         return (Class<Result>) parameterizedType.getActualTypeArguments()[0];
//     }
// }
// 
// Path: app/src/main/java/com/github/istin/schedule/manager/ThreadManager.java
// public class ThreadManager {
// 
//     public static final String APP_SERVICE_KEY = "thread:manager";
// 
//     public static ThreadManager get(Context pContext) {
//         return CoreApplication.get(pContext, APP_SERVICE_KEY);
//     }
// 
//     public interface IExecutionListener<Result> {
// 
//         void onJobStarted();
// 
//         void onDone(Result pResult);
// 
//         void onError(Exception e);
// 
//     }
// 
//     public interface IJob<Result> {
// 
//         Result doJob() throws Exception;
// 
//     }
// 
//     public <Result> void execute(final IJob<Result> pJob, final IExecutionListener<Result> pExecutionListener) {
//         pExecutionListener.onJobStarted();
//         final Handler handler = new Handler();
//         new Thread(new Runnable() {
//             @Override
//             public void run() {
//                 try {
//                     final Result result = pJob.doJob();
//                     handler.post(new Runnable() {
//                         @Override
//                         public void run() {
//                             pExecutionListener.onDone(result);
//                         }
//                     });
//                 } catch (final Exception e) {
//                     handler.post(new Runnable() {
//                         @Override
//                         public void run() {
//                             pExecutionListener.onError(e);
//                         }
//                     });
//                 }
//             }
//         }).start();
//     }
// 
// }


// Path: app/src/main/java/com/github/istin/schedule/CommonHttpJobActivity.java
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.StringRes;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import com.github.istin.schedule.http.HttpJob;
import com.github.istin.schedule.manager.ThreadManager;

package com.github.istin.schedule;



/**
 * Created by uladzimir_klyshevich on 10/6/15.
 */
public abstract class CommonHttpJobActivity<Result> extends AppCompatActivity implements ThreadManager.IExecutionListener<Result> {

    private EditText mSearchEditText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getContentViewLayout());
        mSearchEditText = (EditText) findViewById(R.id.search_edit_text);
        execute();
    }

    private void execute() {
        ThreadManager.get(this).execute(new HttpJob<>(getUrl(), getResultClass()), this);