Add id field to filter list item

pull/1020/head
Alex Baker 4 years ago
parent f6737cb002
commit 034bc6e3a0

@ -45,6 +45,7 @@ public class CaldavFilter extends Filter {
public CaldavFilter(CaldavCalendar calendar) {
super(calendar.getName(), queryTemplate(calendar), getValuesForNewTask(calendar));
this.calendar = calendar;
id = calendar.getId();
tint = calendar.getColor();
icon = calendar.getIcon();
order = calendar.getOrder();
@ -100,12 +101,6 @@ public class CaldavFilter extends Filter {
return R.menu.menu_caldav_list_fragment;
}
@Override
public boolean areItemsTheSame(@NonNull FilterListItem other) {
return other instanceof CaldavFilter
&& calendar.getUuid().equals(((CaldavFilter) other).getUuid());
}
@Override
public boolean areContentsTheSame(@NonNull FilterListItem other) {
return super.areContentsTheSame(other)

@ -25,7 +25,6 @@ public class CustomFilter extends Filter {
}
};
private long id;
private String criterion;
public CustomFilter(@NonNull org.tasks.data.Filter filter) {
@ -41,10 +40,6 @@ public class CustomFilter extends Filter {
readFromParcel(parcel);
}
public long getId() {
return id;
}
public String getCriterion() {
return criterion;
}
@ -53,14 +48,12 @@ public class CustomFilter extends Filter {
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeLong(id);
dest.writeString(criterion);
}
@Override
protected void readFromParcel(Parcel source) {
super.readFromParcel(source);
id = source.readLong();
criterion = source.readString();
}
@ -69,11 +62,6 @@ public class CustomFilter extends Filter {
return getId() > 0 ? R.menu.menu_custom_filter : 0;
}
@Override
public boolean areItemsTheSame(@NonNull FilterListItem other) {
return other instanceof CustomFilter && id == ((CustomFilter) other).id;
}
@Override
public boolean areContentsTheSame(@NonNull FilterListItem other) {
return super.areContentsTheSame(other)

@ -25,6 +25,7 @@ public abstract class FilterListItem implements Parcelable {
/** Title of this item displayed on the Filters page */
public String listingTitle = null;
public long id = 0;
public int icon = -1;
public int tint = 0;
public int count = -1;
@ -45,6 +46,7 @@ public abstract class FilterListItem implements Parcelable {
dest.writeInt(tint);
dest.writeInt(count);
dest.writeInt(order);
dest.writeLong(id);
}
// --- parcelable helpers
@ -56,16 +58,22 @@ public abstract class FilterListItem implements Parcelable {
tint = source.readInt();
count = source.readInt();
order = source.readInt();
id = source.readLong();
}
public abstract boolean areItemsTheSame(@NonNull FilterListItem other);
public long getId() {
return id;
}
public boolean areItemsTheSame(@NonNull FilterListItem other) {
return getClass().equals(other.getClass()) && id == other.id;
}
public boolean areContentsTheSame(@NonNull FilterListItem other) {
return Objects.equals(listingTitle, other.listingTitle)
&& icon == other.icon
&& tint == other.tint
&& count == other.count
&& order == other.order;
&& count == other.count;
}
@Override
@ -74,6 +82,8 @@ public abstract class FilterListItem implements Parcelable {
+ "listingTitle='"
+ listingTitle
+ '\''
+ ", id="
+ id
+ ", icon="
+ icon
+ ", tint="

@ -45,6 +45,7 @@ public class GtasksFilter extends Filter {
public GtasksFilter(GoogleTaskList list) {
super(list.getTitle(), getQueryTemplate(list), getValuesForNewTasks(list));
this.list = list;
id = list.getId();
tint = list.getColor();
icon = list.getIcon();
order = list.getOrder();
@ -101,12 +102,6 @@ public class GtasksFilter extends Filter {
return R.menu.menu_gtasks_list_fragment;
}
@Override
public boolean areItemsTheSame(@NonNull FilterListItem other) {
return other instanceof GtasksFilter
&& list.getRemoteId().equals(((GtasksFilter) other).list.getRemoteId());
}
@Override
public boolean areContentsTheSame(@NonNull FilterListItem other) {
return super.areContentsTheSame(other) && Objects.equals(list, ((GtasksFilter) other).list);

@ -44,6 +44,7 @@ public class TagFilter extends Filter {
public TagFilter(TagData tagData) {
super(tagData.getName(), queryTemplate(tagData.getRemoteId()), getValuesForNewTask(tagData));
this.tagData = tagData;
id = tagData.getId();
tint = tagData.getColor();
icon = tagData.getIcon();
order = tagData.getOrder();
@ -92,12 +93,6 @@ public class TagFilter extends Filter {
return R.menu.menu_tag_view_fragment;
}
@Override
public boolean areItemsTheSame(@NonNull FilterListItem other) {
return other instanceof TagFilter
&& tagData.getRemoteId().equals(((TagFilter) other).getUuid());
}
@Override
public boolean areContentsTheSame(@NonNull FilterListItem other) {
return tagData.equals(((TagFilter) other).tagData);

@ -59,6 +59,7 @@ public class PlaceFilter extends Filter {
public PlaceFilter(Place place) {
super(place.getDisplayName(), queryTemplate(place), getValuesForNewTask(place));
this.place = place;
id = place.getId();
tint = place.getColor();
icon = place.getIcon();
order = place.getOrder();
@ -95,12 +96,6 @@ public class PlaceFilter extends Filter {
return R.menu.menu_location_list_fragment;
}
@Override
public boolean areItemsTheSame(@NonNull FilterListItem other) {
return other instanceof PlaceFilter
&& place.getUid().equals(((PlaceFilter) other).getPlace().getUid());
}
@Override
public boolean areContentsTheSame(@NonNull FilterListItem other) {
return place.equals(((PlaceFilter) other).getPlace()) && count == other.count;

Loading…
Cancel
Save