Fix possible data source invalidation loop.

This commit is contained in:
Greyson Parrelli 2020-05-19 15:07:46 -04:00 committed by Alex Hart
parent b80c339c5a
commit 8d3a91f3a4

View File

@ -130,25 +130,18 @@ class ConversationDataSource extends PositionalDataSource<MessageRecord> {
} }
static class Invalidator { static class Invalidator {
private boolean invalidated;
private Runnable callback; private Runnable callback;
synchronized void invalidate() { synchronized void invalidate() {
invalidated = true;
if (callback != null) { if (callback != null) {
callback.run(); callback.run();
} }
} }
private synchronized void observe(@NonNull Runnable callback) { private synchronized void observe(@NonNull Runnable callback) {
if (invalidated) {
callback.run();
} else {
this.callback = callback; this.callback = callback;
} }
} }
}
static class Factory extends DataSource.Factory<Integer, MessageRecord> { static class Factory extends DataSource.Factory<Integer, MessageRecord> {