mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-20 04:39:04 +00:00
Save the task before tags/checklists
This commit is contained in:
parent
96508a2447
commit
ef57e2ddfa
3 changed files with 25 additions and 7 deletions
|
|
@ -81,6 +81,7 @@
|
|||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.crashlytics.sdk.android/crashlytics/2.3.0/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.github.florent37/materialviewpager/1.1.0/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.github.ksoichiro/android-observablescrollview/1.5.2/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.github.mmin18.layoutcast/library/1.1.4/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.github.porokoro/paperboy/364c77b49f/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.instabug.library/instabugcore/1.6.1/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.instabug.library/instabugsupport/1.6.1/jars" />
|
||||
|
|
@ -110,18 +111,19 @@
|
|||
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" exported="" name="gson-2.3.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="commons-io-2.4" level="project" />
|
||||
<orderEntry type="library" exported="" name="library-1.0.18" level="project" />
|
||||
<orderEntry type="library" exported="" name="commons-io-2.4" level="project" />
|
||||
<orderEntry type="library" exported="" name="okhttp-2.3.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="kenburnsview-1.0.6" level="project" />
|
||||
<orderEntry type="library" exported="" name="rxjava-1.0.10" level="project" />
|
||||
<orderEntry type="library" exported="" name="antlr4-4.5" level="project" />
|
||||
<orderEntry type="library" exported="" name="crashlytics-core-2.3.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="aboutlibraries-5.0.5" level="project" />
|
||||
<orderEntry type="library" exported="" name="antlr4-runtime-4.5" level="project" />
|
||||
<orderEntry type="library" exported="" name="antlr4-annotations-4.5" level="project" />
|
||||
<orderEntry type="library" exported="" name="antlr4-runtime-4.5" level="project" />
|
||||
<orderEntry type="library" exported="" name="instabugsupport-1.6.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="library-1.0-rc1" level="project" />
|
||||
<orderEntry type="library" exported="" name="library-1.1.4" level="project" />
|
||||
<orderEntry type="library" exported="" name="org.abego.treelayout.core-1.0.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="paperboy-364c77b49f" level="project" />
|
||||
<orderEntry type="library" exported="" name="library-1.1.0" level="project" />
|
||||
|
|
@ -140,8 +142,8 @@
|
|||
<orderEntry type="library" exported="" name="gridlayout-v7-22.2.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="commons-codec-1.10" level="project" />
|
||||
<orderEntry type="library" exported="" name="javawriter-2.5.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="kotlin-stdlib-0.12.613" level="project" />
|
||||
<orderEntry type="library" exported="" name="commons-lang3-3.3.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="kotlin-stdlib-0.12.613" level="project" />
|
||||
<orderEntry type="library" exported="" name="design-22.2.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="cardview-v7-22.2.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="kotlin-runtime-0.12.613" level="project" />
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.magicmicky.habitrpgwrapper.lib.models.tasks.TaskTag;
|
|||
import com.raizlabs.android.dbflow.sql.language.Select;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -26,6 +27,15 @@ public class TagsAdapter extends TypeAdapter<List<TaskTag>>{
|
|||
out.endObject();
|
||||
}
|
||||
|
||||
private boolean alreadyContainsTag(List<TaskTag> list, String idToCheck)
|
||||
{
|
||||
for(TaskTag t : list)
|
||||
if(t.getTag().getId().equals(idToCheck))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskTag> read(JsonReader in) throws IOException {
|
||||
List<TaskTag> tags = new ArrayList<>();
|
||||
|
|
@ -39,17 +49,20 @@ public class TagsAdapter extends TypeAdapter<List<TaskTag>>{
|
|||
in.beginObject();
|
||||
break;
|
||||
case NAME:
|
||||
String taskId = in.nextName();
|
||||
String tagId = in.nextName();
|
||||
|
||||
if(in.nextBoolean()) {
|
||||
TaskTag taskTag = new TaskTag();
|
||||
for (Tag tag : allTags) {
|
||||
if (tag.getId().equals(taskId)) {
|
||||
if (tag.getId().equals(tagId)) {
|
||||
taskTag.setTag(tag);
|
||||
|
||||
if(!alreadyContainsTag(tags, tagId))
|
||||
tags.add(taskTag);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
tags.add(taskTag);
|
||||
}
|
||||
break;
|
||||
case END_OBJECT:
|
||||
|
|
|
|||
|
|
@ -297,17 +297,20 @@ public class Task extends BaseModel {
|
|||
|
||||
@Override
|
||||
public void save() {
|
||||
super.save();
|
||||
|
||||
if (this.tags != null) {
|
||||
for (TaskTag tag : this.tags) {
|
||||
tag.setTask(this);
|
||||
tag.save();
|
||||
}
|
||||
}
|
||||
if (this.checklist != null) {
|
||||
for (ChecklistItem item : this.checklist) {
|
||||
item.setTask(this);
|
||||
item.save();
|
||||
}
|
||||
}
|
||||
super.save();
|
||||
}
|
||||
|
||||
public int getLightTaskColor()
|
||||
|
|
|
|||
Loading…
Reference in a new issue