Allow multiple AsyncTasks to run concurrently

Fixes #134
pull/171/head
Alinson S. Xavier 9 years ago
parent f178bcbdd2
commit 8eb9f398d5

@ -179,7 +179,7 @@ public abstract class CheckmarkList
* @param from timestamp for the beginning of the interval * @param from timestamp for the beginning of the interval
* @param to timestamp for the end of the interval * @param to timestamp for the end of the interval
*/ */
protected final void compute(long from, final long to) protected final synchronized void compute(long from, final long to)
{ {
final long day = DateUtils.millisecondsInOneDay; final long day = DateUtils.millisecondsInOneDay;

@ -154,7 +154,7 @@ public abstract class ScoreList implements Iterable<Score>
* @param from timestamp of the beginning of the interval * @param from timestamp of the beginning of the interval
* @param to timestamp of the end of the time interval * @param to timestamp of the end of the time interval
*/ */
protected void compute(long from, long to) protected synchronized void compute(long from, long to)
{ {
final long day = DateUtils.millisecondsInOneDay; final long day = DateUtils.millisecondsInOneDay;
final double freq = habit.getFrequency().toDouble(); final double freq = habit.getFrequency().toDouble();

@ -65,7 +65,7 @@ public abstract class StreakList
public abstract void invalidateNewerThan(long timestamp); public abstract void invalidateNewerThan(long timestamp);
public void rebuild() public synchronized void rebuild()
{ {
long today = DateUtils.getStartOfToday(); long today = DateUtils.getStartOfToday();

@ -27,6 +27,8 @@ import java.util.*;
import dagger.*; import dagger.*;
import static android.os.AsyncTask.*;
@Module @Module
public class AndroidTaskRunner implements TaskRunner public class AndroidTaskRunner implements TaskRunner
{ {
@ -60,7 +62,7 @@ public class AndroidTaskRunner implements TaskRunner
public void execute(Task task) public void execute(Task task)
{ {
task.onAttached(this); task.onAttached(this);
new CustomAsyncTask(task).execute(); new CustomAsyncTask(task).executeOnExecutor(THREAD_POOL_EXECUTOR);
} }
@Override @Override

Loading…
Cancel
Save