From 7339d5dcb3941d75201febdca0cf9de92e01405c Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Fri, 3 Aug 2018 10:29:53 -0500 Subject: [PATCH] Notify content provider after tasks deleted --- app/src/main/java/com/todoroo/astrid/dao/Database.java | 2 +- app/src/main/java/org/tasks/data/DeletionDao.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/todoroo/astrid/dao/Database.java b/app/src/main/java/com/todoroo/astrid/dao/Database.java index 9c14c8536..2c7fc8270 100644 --- a/app/src/main/java/com/todoroo/astrid/dao/Database.java +++ b/app/src/main/java/com/todoroo/astrid/dao/Database.java @@ -108,7 +108,7 @@ public abstract class Database extends RoomDatabase { return this; } - void onDatabaseUpdated() { + public void onDatabaseUpdated() { if (onDatabaseUpdated != null) { onDatabaseUpdated.run(); } diff --git a/app/src/main/java/org/tasks/data/DeletionDao.java b/app/src/main/java/org/tasks/data/DeletionDao.java index 791af4c54..e6a4bafad 100644 --- a/app/src/main/java/org/tasks/data/DeletionDao.java +++ b/app/src/main/java/org/tasks/data/DeletionDao.java @@ -7,11 +7,19 @@ import android.arch.persistence.room.Dao; import android.arch.persistence.room.Delete; import android.arch.persistence.room.Query; import android.arch.persistence.room.Transaction; +import com.todoroo.astrid.dao.Database; import java.util.ArrayList; import java.util.List; @Dao public abstract class DeletionDao { + + private final Database database; + + public DeletionDao(Database database) { + this.database = database; + } + @Query("SELECT _id FROM tasks WHERE deleted > 0") public abstract List getDeleted(); @@ -43,6 +51,7 @@ public abstract class DeletionDao { deleteCaldavTasks(partition); deleteTasks(partition); } + database.onDatabaseUpdated(); } @Query("UPDATE tasks SET modified = :timestamp, deleted = :timestamp WHERE _id IN(:ids)") @@ -53,6 +62,7 @@ public abstract class DeletionDao { for (List partition : partition(ids, 997)) { markDeleted(now, partition); } + database.onDatabaseUpdated(); } @Query("SELECT task FROM google_tasks WHERE deleted = 0 AND list_id = :listId")