|
|
|
@ -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<IdListFilter> CREATOR =
|
|
|
|
|
new Creator<IdListFilter>() {
|
|
|
|
|
|
|
|
|
|
/** {@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<Long> ids;
|
|
|
|
|
|
|
|
|
|
public IdListFilter(List<Long>ids) {
|
|
|
|
|
public IdListFilter(List<Long> ids) {
|
|
|
|
|
super("", getQueryTemplate(ids));
|
|
|
|
|
this.ids = ids;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IdListFilter(Parcel source) {
|
|
|
|
|
readFromParcel(source);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static QueryTemplate getQueryTemplate(List<Long> 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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|