Skip to content

Commit 0f70acc

Browse files
committed
bugfixes
1 parent e4d667e commit 0f70acc

File tree

3 files changed

+57
-2
lines changed

3 files changed

+57
-2
lines changed

Habitica/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools"
44
package="com.habitrpg.android.habitica"
5-
android:versionCode="102"
5+
android:versionCode="104"
66
android:versionName="0.0.32"
77
android:screenOrientation="portrait"
88
android:installLocation="auto" >

Habitica/src/main/java/com/habitrpg/android/habitica/ui/activities/MainActivity.java

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import com.magicmicky.habitrpgwrapper.lib.models.tasks.ChecklistItem;
5959
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Days;
6060
import com.magicmicky.habitrpgwrapper.lib.models.tasks.ItemData;
61+
import com.magicmicky.habitrpgwrapper.lib.models.tasks.RemindersItem;
6162
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Task;
6263
import com.magicmicky.habitrpgwrapper.lib.models.tasks.TaskTag;
6364
import com.mikepenz.materialdrawer.AccountHeader;
@@ -378,6 +379,14 @@ private void setUserData(boolean fromLocalDb) {
378379
}
379380
loadAndRemoveOldTaskTags(allTaskTags);
380381

382+
ArrayList<RemindersItem> allReminders = new ArrayList<>();
383+
for (Task t : allTasks) {
384+
if (t.getReminders() != null) {
385+
allReminders.addAll(t.getReminders());
386+
}
387+
}
388+
loadAndRemoveOldReminders(allReminders);
389+
381390
loadAndRemoveOldTags(user.getTags());
382391

383392
updateOwnedDataForUser(user);
@@ -561,6 +570,52 @@ public boolean hasResult(BaseTransaction<List<TaskTag>> baseTransaction, List<Ta
561570

562571
}
563572

573+
private void loadAndRemoveOldReminders(final List<RemindersItem> onlineEntries) {
574+
final ArrayList<String> onlineTaskTagItemIdList = new ArrayList<>();
575+
576+
for (RemindersItem item : onlineEntries) {
577+
onlineTaskTagItemIdList.add(item.getId());
578+
}
579+
580+
From<RemindersItem> query = new Select().from(RemindersItem.class);
581+
try {
582+
if (query.count() != onlineEntries.size()) {
583+
584+
// Load Database Checklist items
585+
query.async().queryList(new TransactionListener<List<RemindersItem>>() {
586+
@Override
587+
public void onResultReceived(List<RemindersItem> items) {
588+
589+
ArrayList<RemindersItem> remindersToDelete = new ArrayList<>();
590+
591+
for (RemindersItem reminder : items) {
592+
if (!onlineTaskTagItemIdList.contains(reminder.getId())) {
593+
remindersToDelete.add(reminder);
594+
}
595+
}
596+
597+
for (RemindersItem reminder : remindersToDelete) {
598+
reminder.async().delete();
599+
}
600+
}
601+
602+
@Override
603+
public boolean onReady(BaseTransaction<List<RemindersItem>> baseTransaction) {
604+
return false;
605+
}
606+
607+
@Override
608+
public boolean hasResult(BaseTransaction<List<RemindersItem>> baseTransaction, List<RemindersItem> items) {
609+
return items != null && items.size() > 0;
610+
}
611+
});
612+
}
613+
} catch (SQLiteDoneException ignored) {
614+
//Ignored
615+
}
616+
617+
}
618+
564619
private void loadAndRemoveOldTags(final List<Tag> onlineEntries) {
565620
final ArrayList<String> onlineTaskTagItemIdList = new ArrayList<>();
566621

Habitica/src/main/java/com/magicmicky/habitrpgwrapper/lib/models/tasks/Task.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,6 @@ public void delete() {
629629
TaskDeleteEvent event = new TaskDeleteEvent();
630630
event.task = this;
631631
EventBus.getDefault().post(event);
632-
super.save();
632+
super.delete();
633633
}
634634
}

0 commit comments

Comments
 (0)