package fishrungames.bashgid.core;

import android.os.AsyncTask;
import android.os.Handler;
import android.os.Message;
import fishrungames.bashgid.MainActivity;
import fishrungames.bashgid.core.ArticleManager.ArticleFullData;

public class DatabaseGetArticleTask extends AsyncTask<String, Integer, Long>
{

	ArticleFullData article;
	
	public Handler mHandler;

	protected Long doInBackground(String... queryArr)
	{
		String articleName = queryArr[0];
		
		article = MainActivity.getInstance().articleDataSource.GetArticleFullData(articleName);
		
		return (long) 0;
	}

	protected void onProgressUpdate(Integer... progress)
	{
		Message completeMessage = mHandler.obtainMessage(MainActivity.DATABASE_GET_ARTICLE_STATE_UPDATE, article);

		completeMessage.sendToTarget();

	}

	protected void onPostExecute(Long result)
	{
		Message completeMessage = mHandler.obtainMessage(MainActivity.DATABASE_GET_ARTICLE_STATE_FINISHED, article);

		completeMessage.sendToTarget();
	}
}