Refresh lock was used incorrectly
This commit is contained in:
parent
75b13431fe
commit
a90c7219f3
|
@ -10,6 +10,7 @@ import java.util.List;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.FutureTask;
|
import java.util.concurrent.FutureTask;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -73,11 +74,10 @@ public final class DBTasks {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ReentrantLock refreshAllFeedsLock = new ReentrantLock();
|
private static AtomicBoolean isRefreshing = new AtomicBoolean(false);
|
||||||
|
|
||||||
public static void refreshAllFeeds(final Context context,
|
public static void refreshAllFeeds(final Context context,
|
||||||
final List<Feed> feeds) {
|
final List<Feed> feeds) {
|
||||||
if (refreshAllFeedsLock.tryLock()) {
|
if (isRefreshing.compareAndSet(false, true)) {
|
||||||
new Thread() {
|
new Thread() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (feeds != null) {
|
if (feeds != null) {
|
||||||
|
@ -85,7 +85,7 @@ public final class DBTasks {
|
||||||
} else {
|
} else {
|
||||||
refreshFeeds(context, DBReader.getFeedList(context));
|
refreshFeeds(context, DBReader.getFeedList(context));
|
||||||
}
|
}
|
||||||
refreshAllFeedsLock.unlock();
|
isRefreshing.set(false);
|
||||||
}
|
}
|
||||||
}.start();
|
}.start();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue