package ca.ualberta.cs.cmput301f14t14.questionapp.data.threading;

import ca.ualberta.cs.cmput301f14t14.questionapp.data.Callback;
import ca.ualberta.cs.cmput301f14t14.questionapp.model.Question;
import android.content.Context;
import android.os.AsyncTask;

public abstract class AbstractDataManagerTask<S,T,V> extends AsyncTask<S,T,V> {
	
	protected Context context;
	
	public AbstractDataManagerTask(Context c) {
		context = c;
	}
	
	protected Context getContext() {
		return context;
	}
	
	Callback<V> callback = null;
	
	public void setCallBack(Callback<V> c) {
		callback = c;
	}
	/** Runs doInBackground in the current thread.
	 * 
	 * @param param
	 * @return
	 */
	public V blockingRun(S... params){
		return this.doInBackground(params);
	}

	@Override
	protected void onPostExecute(V v) {
		if (callback == null) {
			return;
		}
		callback.run(v);
	}
}

@@ -135,127 +135,264 @@
 ort 
-ca.ualberta.cs.cmput301f14t14.questionapp.model.Question;%0Aimport android.content.Context;%0Aimport android.os.AsyncTask;%0A
+android.content.Context;%0Aimport android.os.AsyncTask;%0A%0A/**%0A * An AsyncTask that will run the provided callback in its onPostExecute section%0A * @param %3CS%3E Task parameter type%0A * @param %3CT%3E Task progress response type%0A * @param %3CV%3E Task return value type%0A */
 %0Apub
@@ -498,16 +498,56 @@
 ontext;%0A
+%09protected Callback%3CV%3E callback = null;%0A
 %09%0A%09publi
@@ -591,19 +591,152 @@
 %7B%0A%09%09
-context = c
+this(c, null);%0A%09%7D%0A%0A%09public AbstractDataManagerTask(Context context, Callback%3CV%3E callback) %7B%0A%09%09this.context = context;%0A%09%09this.callback = callback
 ;%0A%09%7D
@@ -799,40 +799,8 @@
 %7D%0A%09%0A
-%09Callback%3CV%3E callback = null;%0A%09%0A
 %09pub
@@ -860,12 +860,17 @@
 %0A%09%7D%0A
+%0A
 %09/**
+%0A%09 *
  Run
@@ -913,13 +913,8 @@
 ad.%0A
-%09 * %0A
 %09 * 

Refactor AbstractDataManagerTask