mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Remove waitForTasks
This commit is contained in:
@@ -127,23 +127,4 @@ public class BaseAndroidTest
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected void waitForAsyncTasks()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
|
||||
{
|
||||
Thread.sleep(1000);
|
||||
return;
|
||||
}
|
||||
|
||||
taskRunner.waitForTasks(10000);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
fail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,6 @@ public class FrequencyCardTest extends BaseViewTest
|
||||
|
||||
view.setHabit(habit);
|
||||
view.refreshData();
|
||||
waitForAsyncTasks();
|
||||
|
||||
measureView(view, 800, 600);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,6 @@ public class HistoryCardTest extends BaseViewTest
|
||||
|
||||
view.setHabit(habit);
|
||||
view.refreshData();
|
||||
waitForAsyncTasks();
|
||||
|
||||
measureView(view, 800, 600);
|
||||
}
|
||||
|
||||
@@ -52,8 +52,6 @@ public class OverviewCardTest extends BaseViewTest
|
||||
|
||||
view.setHabit(habit);
|
||||
view.refreshData();
|
||||
waitForAsyncTasks();
|
||||
|
||||
measureView(view, 800, 300);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,8 +52,6 @@ public class ScoreCardTest extends BaseViewTest
|
||||
|
||||
view.setHabit(habit);
|
||||
view.refreshData();
|
||||
waitForAsyncTasks();
|
||||
|
||||
measureView(view, 800, 600);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,5 @@ public class ExportCSVTaskTest extends BaseAndroidTest
|
||||
assertTrue(f.exists());
|
||||
assertTrue(f.canRead());
|
||||
}));
|
||||
|
||||
waitForAsyncTasks();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,5 @@ public class ExportDBTaskTest extends BaseAndroidTest
|
||||
});
|
||||
|
||||
taskRunner.execute(task);
|
||||
waitForAsyncTasks();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,8 +67,6 @@ public class ImportDataTaskTest extends BaseAndroidTest
|
||||
|
||||
taskRunner.execute(new ImportDataTask(habitList, file,
|
||||
(result) -> assertThat(result, equalTo(expectedResult))));
|
||||
|
||||
waitForAsyncTasks();
|
||||
}
|
||||
|
||||
private void copyAssetToFile(String assetPath, File dst) throws IOException
|
||||
|
||||
@@ -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