I'm calling two AsyncTasks in parallel via this snippet in onCreate
:
if ((DictMode.equals("TATOEBA")) || (DictMode.equals("SENTENCE"))) {
dictAsyncTask = new DictAsyncTask(DictionaryLookUp.this, "Tatoeba");
// dictAsyncTask.execute();
dictAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
if ((DictMode.equals("JUKUU")) || (DictMode.equals("SENTENCE"))) {
dictAsyncTask = new DictAsyncTask(DictionaryLookUp.this, "Jukuu");
// dictAsyncTask.execute();
dictAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
during onPostExecute
I check whether any data gets retrieved and return from the startActivityForResult
call via finish
:
if (alldictStuff.size() == 0) {
...
Toast.makeText(DictionaryLookUp.this,"NOTHING FOUND ...",Toast.LENGTH_SHORT).show();
if ((DictMode.equals("TATOEBA")) || (DictMode.equals("JUKUU")) || (DictMode.equals("SENTENCE"))) {
Intent intentCard = new Intent(getApplicationContext(), CardView.class);
setResult(Activity.RESULT_OK);
finish();
}
but that's obviously flawed since I'm not checking whether both threads return no results, so what's the best way to check whether both threads are finished and returned nothing ? Do I have to use my own variables to track it or is there something neat/built-in I can utilize ?