From 6988073de24c15998a8552d1cb593acb8ea57960 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Tue, 28 Apr 2020 11:21:13 -0500 Subject: [PATCH] Save id list --- .../com/todoroo/astrid/api/IdListFilter.java | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/todoroo/astrid/api/IdListFilter.java b/app/src/main/java/com/todoroo/astrid/api/IdListFilter.java index 762dcd104..92c38609f 100644 --- a/app/src/main/java/com/todoroo/astrid/api/IdListFilter.java +++ b/app/src/main/java/com/todoroo/astrid/api/IdListFilter.java @@ -1,6 +1,7 @@ package com.todoroo.astrid.api; import android.os.Parcel; +import com.google.common.primitives.Longs; import com.todoroo.andlib.sql.Join; import com.todoroo.andlib.sql.QueryTemplate; import com.todoroo.astrid.data.Task; @@ -9,29 +10,29 @@ import org.tasks.data.Tag; public class IdListFilter extends Filter { - /** Parcelable Creator Object */ public static final Creator CREATOR = new Creator() { - /** {@inheritDoc} */ @Override public IdListFilter createFromParcel(Parcel source) { - IdListFilter item = new IdListFilter(); - item.readFromParcel(source); - return item; + return new IdListFilter(source); } - /** {@inheritDoc} */ @Override public IdListFilter[] newArray(int size) { return new IdListFilter[size]; } }; - private IdListFilter() {} + private List ids; - public IdListFilter(Listids) { + public IdListFilter(List ids) { super("", getQueryTemplate(ids)); + this.ids = ids; + } + + private IdListFilter(Parcel source) { + readFromParcel(source); } private static QueryTemplate getQueryTemplate(List ids) { @@ -39,4 +40,19 @@ public class IdListFilter extends Filter { .join(Join.left(Tag.TABLE, Tag.TASK.eq(Task.ID))) .where(Task.ID.in(ids)); } + + @Override + public void writeToParcel(Parcel dest, int flags) { + super.writeToParcel(dest, flags); + dest.writeLongArray(Longs.toArray(ids)); + } + + @Override + protected void readFromParcel(Parcel source) { + super.readFromParcel(source); + long[] ids = new long[source.readInt()]; + source.setDataPosition(source.dataPosition() - 1); + source.readLongArray(ids); + this.ids = Longs.asList(ids); + } }