mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-07 17:48:52 -06:00
Remove waitForTasks
This commit is contained in:
@@ -22,7 +22,6 @@ package org.isoron.uhabits.tasks;
|
||||
import android.os.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
import javax.inject.*;
|
||||
|
||||
@@ -59,27 +58,6 @@ public class AndroidTaskRunner implements TaskRunner
|
||||
if (asyncTask.getTask() == task) asyncTask.publish(progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void waitForTasks(long timeout)
|
||||
throws TimeoutException, InterruptedException
|
||||
{
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
|
||||
throw new UnsupportedOperationException(
|
||||
"waitForTasks requires API 16+");
|
||||
|
||||
int poolInterval = 100;
|
||||
|
||||
while (timeout > 0)
|
||||
{
|
||||
if (activeTasks.isEmpty()) return;
|
||||
|
||||
timeout -= poolInterval;
|
||||
Thread.sleep(poolInterval);
|
||||
}
|
||||
|
||||
throw new TimeoutException();
|
||||
}
|
||||
|
||||
private class CustomAsyncTask extends AsyncTask<Void, Integer, Void>
|
||||
{
|
||||
private final Task task;
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
|
||||
package org.isoron.uhabits.tasks;
|
||||
|
||||
import java.util.concurrent.*;
|
||||
|
||||
import javax.inject.*;
|
||||
|
||||
import dagger.*;
|
||||
@@ -50,10 +48,4 @@ public class SingleThreadTaskRunner implements TaskRunner
|
||||
task.onProgressUpdate(progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void waitForTasks(long timeout)
|
||||
throws TimeoutException, InterruptedException
|
||||
{
|
||||
// NOP
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,14 +19,9 @@
|
||||
|
||||
package org.isoron.uhabits.tasks;
|
||||
|
||||
import java.util.concurrent.*;
|
||||
|
||||
public interface TaskRunner
|
||||
{
|
||||
void execute(Task task);
|
||||
|
||||
void publishProgress(Task task, int progress);
|
||||
|
||||
void waitForTasks(long timeout)
|
||||
throws TimeoutException, InterruptedException;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user