|
|
|
@ -28,26 +28,28 @@ public abstract class BaseTask extends AsyncTask<Void, Integer, Void>
|
|
|
|
|
private static int activeTaskCount;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected final Void doInBackground(Void... params)
|
|
|
|
|
protected void onPreExecute()
|
|
|
|
|
{
|
|
|
|
|
register();
|
|
|
|
|
doInBackground();
|
|
|
|
|
unregister();
|
|
|
|
|
return null;
|
|
|
|
|
super.onPreExecute();
|
|
|
|
|
activeTaskCount++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected abstract void doInBackground();
|
|
|
|
|
|
|
|
|
|
protected void register()
|
|
|
|
|
@Override
|
|
|
|
|
protected void onPostExecute(Void aVoid)
|
|
|
|
|
{
|
|
|
|
|
activeTaskCount++;
|
|
|
|
|
activeTaskCount--;
|
|
|
|
|
super.onPostExecute(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void unregister()
|
|
|
|
|
@Override
|
|
|
|
|
protected final Void doInBackground(Void... params)
|
|
|
|
|
{
|
|
|
|
|
activeTaskCount--;
|
|
|
|
|
doInBackground();
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected abstract void doInBackground();
|
|
|
|
|
|
|
|
|
|
public static void waitForTasks(long timeout)
|
|
|
|
|
throws TimeoutException, InterruptedException
|
|
|
|
|
{
|
|
|
|
|