Embed CaldavTask in TaskContainer

pull/848/head
Alex Baker 5 years ago
parent 3c5df292ee
commit c7b7e13768

@ -6,9 +6,9 @@ import com.todoroo.astrid.data.Task;
public class TaskContainer {
@Embedded public Task task;
@Embedded public GoogleTask googletask;
@Embedded public CaldavTask caldavTask;
@Embedded public Location location;
public String tags;
public String caldav;
public int children;
public int siblings;
public long primarySort;
@ -25,7 +25,7 @@ public class TaskContainer {
}
public String getCaldav() {
return caldav;
return caldavTask == null ? null : caldavTask.getCalendar();
}
public String getNotes() {
@ -131,22 +131,22 @@ public class TaskContainer {
if (googletask != null ? !googletask.equals(that.googletask) : that.googletask != null) {
return false;
}
if (location != null ? !location.equals(that.location) : that.location != null) {
if (caldavTask != null ? !caldavTask.equals(that.caldavTask) : that.caldavTask != null) {
return false;
}
if (tags != null ? !tags.equals(that.tags) : that.tags != null) {
if (location != null ? !location.equals(that.location) : that.location != null) {
return false;
}
return caldav != null ? caldav.equals(that.caldav) : that.caldav == null;
return tags != null ? tags.equals(that.tags) : that.tags == null;
}
@Override
public int hashCode() {
int result = task != null ? task.hashCode() : 0;
result = 31 * result + (googletask != null ? googletask.hashCode() : 0);
result = 31 * result + (caldavTask != null ? caldavTask.hashCode() : 0);
result = 31 * result + (location != null ? location.hashCode() : 0);
result = 31 * result + (tags != null ? tags.hashCode() : 0);
result = 31 * result + (caldav != null ? caldav.hashCode() : 0);
result = 31 * result + children;
result = 31 * result + siblings;
result = 31 * result + (int) (primarySort ^ (primarySort >>> 32));
@ -163,14 +163,13 @@ public class TaskContainer {
+ task
+ ", googletask="
+ googletask
+ ", caldavTask="
+ caldavTask
+ ", location="
+ location
+ ", tags='"
+ tags
+ '\''
+ ", caldav='"
+ caldav
+ '\''
+ ", children="
+ children
+ ", siblings="

@ -11,6 +11,7 @@ import androidx.recyclerview.widget.ListUpdateCallback;
import androidx.recyclerview.widget.RecyclerView;
import com.todoroo.astrid.activity.TaskListFragment;
import com.todoroo.astrid.adapter.TaskAdapter;
import com.todoroo.astrid.api.CaldavFilter;
import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.GtasksFilter;
import com.todoroo.astrid.utility.Flags;
@ -27,7 +28,7 @@ public abstract class TaskListRecyclerAdapter extends RecyclerView.Adapter<ViewH
private final RecyclerView recyclerView;
private final ViewHolderFactory viewHolderFactory;
private final ActionModeProvider actionModeProvider;
private final boolean isGoogleTaskList;
private final boolean isRemoteList;
private ActionMode mode = null;
TaskListRecyclerAdapter(
@ -41,7 +42,7 @@ public abstract class TaskListRecyclerAdapter extends RecyclerView.Adapter<ViewH
this.viewHolderFactory = viewHolderFactory;
this.taskList = taskList;
this.actionModeProvider = actionModeProvider;
isGoogleTaskList = taskList.getFilter() instanceof GtasksFilter;
isRemoteList = taskList.getFilter() instanceof GtasksFilter || taskList.getFilter() instanceof CaldavFilter;
}
@NonNull
@ -54,7 +55,7 @@ public abstract class TaskListRecyclerAdapter extends RecyclerView.Adapter<ViewH
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
TaskContainer task = getItem(position);
if (task != null) {
holder.bindView(task, isGoogleTaskList);
holder.bindView(task, isRemoteList);
holder.setMoving(false);
int indent = adapter.getIndent(task);
task.setIndent(indent);

@ -85,7 +85,7 @@ public class ViewHolder extends RecyclerView.ViewHolder {
private int indent;
private boolean selected;
private boolean moving;
private boolean isGoogleTaskList;
private boolean isRemoteList;
private int minIndent;
private int maxIndent;
@ -203,9 +203,9 @@ public class ViewHolder extends RecyclerView.ViewHolder {
return Math.round(indent * getShiftSize());
}
void bindView(TaskContainer task, boolean isGoogleTaskList) {
void bindView(TaskContainer task, boolean isRemoteList) {
this.task = task;
this.isGoogleTaskList = isGoogleTaskList;
this.isRemoteList = isRemoteList;
nameView.setText(task.getTitle());
hidden.setVisibility(task.isHidden() ? View.VISIBLE : View.GONE);
@ -282,8 +282,8 @@ public class ViewHolder extends RecyclerView.ViewHolder {
List<Chip> chips =
chipProvider.getChips(
context,
task.getCaldav(),
isGoogleTaskList ? null : task.getGoogleTaskList(),
isRemoteList ? null : task.getCaldav(),
isRemoteList ? null : task.getGoogleTaskList(),
tagUuids);
if (chips.isEmpty()) {
chipGroup.setVisibility(View.GONE);

@ -56,8 +56,7 @@ public class TaskListViewModel extends ViewModel implements Observer<PagedList<T
private static final Field GTASK = field(GTASK_METADATA_JOIN + ".*");
private static final Field GEOFENCE = field("geofences.*");
private static final Field PLACE = field("places.*");
private static final StringProperty CALDAV =
new StringProperty(null, CALDAV_METADATA_JOIN + ".cd_calendar").as("caldav");
private static final Field CALDAV = field(CALDAV_METADATA_JOIN + ".*");
private static final Field CHILDREN = field("children");
private static final Field SIBLINGS = field("siblings");
private static final Field PRIMARY_SORT = field("primary_sort").as("primarySort");

Loading…
Cancel
Save