package fishrungames.bashgid.core;

import java.util.ArrayList;

import android.os.AsyncTask;
import android.os.Handler;
import android.os.Message;
import fishrungames.bashgid.MainActivity;
import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;

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

ArrayList<JournalSemiFullData> journalList;
	
	public Handler mHandler;

	protected Long doInBackground(String... queryArr)
	{

		if (queryArr.length > 0)
		{
			journalList = MainActivity.getInstance().journalDataSource.GetJournalListMain(3); //Xperimental -- need to pass exactly how many articles
		}
		else
		{
			journalList = MainActivity.getInstance().journalDataSource.GetAllJournalListExceptHidden(3); //Xperimental -- need to pass exactly how many articles
		}
		
		
		return (long) 0;
	}

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

		completeMessage.sendToTarget();

	}

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

		completeMessage.sendToTarget();
	}
	
}
