Remove file metadata join

pull/820/head
Alex Baker 7 years ago
parent c6a1fb65c6
commit 7cd7699b95

@ -99,7 +99,6 @@ public final class TaskListFragment extends InjectingFragment
public static final String TAGS_METADATA_JOIN = "for_tags"; // $NON-NLS-1$ public static final String TAGS_METADATA_JOIN = "for_tags"; // $NON-NLS-1$
public static final String GTASK_METADATA_JOIN = "for_gtask"; // $NON-NLS-1$ public static final String GTASK_METADATA_JOIN = "for_gtask"; // $NON-NLS-1$
public static final String CALDAV_METADATA_JOIN = "for_caldav"; // $NON-NLS-1$ public static final String CALDAV_METADATA_JOIN = "for_caldav"; // $NON-NLS-1$
public static final String FILE_METADATA_JOIN = "for_actions"; // $NON-NLS-1$
public static final String ACTION_RELOAD = "action_reload"; public static final String ACTION_RELOAD = "action_reload";
public static final String ACTION_DELETED = "action_deleted"; public static final String ACTION_DELETED = "action_deleted";
private static final int VOICE_RECOGNITION_REQUEST_CODE = 1234; private static final int VOICE_RECOGNITION_REQUEST_CODE = 1234;

@ -12,14 +12,12 @@ import static com.google.common.primitives.Longs.asList;
import androidx.paging.AsyncPagedListDiffer; import androidx.paging.AsyncPagedListDiffer;
import com.google.common.collect.ObjectArrays; import com.google.common.collect.ObjectArrays;
import com.todoroo.andlib.data.Property; import com.todoroo.andlib.data.Property;
import com.todoroo.andlib.data.Property.LongProperty;
import com.todoroo.andlib.data.Property.StringProperty; import com.todoroo.andlib.data.Property.StringProperty;
import com.todoroo.astrid.activity.TaskListFragment; import com.todoroo.astrid.activity.TaskListFragment;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.tasks.data.TaskAttachment;
/** /**
* Adapter for displaying a user's tasks as a list * Adapter for displaying a user's tasks as a list
@ -37,16 +35,13 @@ public class TaskAdapter {
private static final StringProperty CALDAV = private static final StringProperty CALDAV =
new StringProperty(null, TaskListFragment.CALDAV_METADATA_JOIN + ".calendar").as("caldav"); new StringProperty(null, TaskListFragment.CALDAV_METADATA_JOIN + ".calendar").as("caldav");
private static final LongProperty FILE_ID_PROPERTY =
TaskAttachment.ID.cloneAs(TaskListFragment.FILE_METADATA_JOIN, "fileId");
static final Property<?>[] PROPERTIES = static final Property<?>[] PROPERTIES =
ObjectArrays.concat( ObjectArrays.concat(
Task.PROPERTIES, Task.PROPERTIES,
new Property<?>[] { new Property<?>[] {
TAGS, // Concatenated list of tags TAGS, // Concatenated list of tags
GTASK, GTASK,
CALDAV, CALDAV
FILE_ID_PROPERTY // File id
}, },
Property.class); Property.class);
private final Set<Long> selected = new HashSet<>(); private final Set<Long> selected = new HashSet<>();

@ -211,7 +211,6 @@ public class Task implements Parcelable {
@Ignore private transient String tags; @Ignore private transient String tags;
@Ignore private transient String googleTaskList; @Ignore private transient String googleTaskList;
@Ignore private transient String caldav; @Ignore private transient String caldav;
@Ignore private transient boolean hasFiles;
@Ignore private transient HashMap<String, Object> transitoryData = null; @Ignore private transient HashMap<String, Object> transitoryData = null;
public Task() {} public Task() {}
@ -243,7 +242,6 @@ public class Task implements Parcelable {
final int _cursorIndexOfTags = _cursor.getColumnIndex("tags"); final int _cursorIndexOfTags = _cursor.getColumnIndex("tags");
final int _cursorIndexOfGoogleTasks = _cursor.getColumnIndex("googletask"); final int _cursorIndexOfGoogleTasks = _cursor.getColumnIndex("googletask");
final int _cursorIndexOfCaldav = _cursor.getColumnIndex("caldav"); final int _cursorIndexOfCaldav = _cursor.getColumnIndex("caldav");
final int _cursorIndexOfFileId = _cursor.getColumnIndex("fileId");
if (_cursor.isNull(_cursorIndexOfId)) { if (_cursor.isNull(_cursorIndexOfId)) {
id = null; id = null;
} else { } else {
@ -341,9 +339,6 @@ public class Task implements Parcelable {
if (_cursorIndexOfCaldav >= 0) { if (_cursorIndexOfCaldav >= 0) {
caldav = _cursor.getString(_cursorIndexOfCaldav); caldav = _cursor.getString(_cursorIndexOfCaldav);
} }
if (_cursorIndexOfFileId >= 0) {
hasFiles = _cursor.getInt(_cursorIndexOfFileId) > 0;
}
} }
@Ignore @Ignore
@ -1074,9 +1069,6 @@ public class Task implements Parcelable {
if (indent != task.indent) { if (indent != task.indent) {
return false; return false;
} }
if (hasFiles != task.hasFiles) {
return false;
}
if (id != null ? !id.equals(task.id) : task.id != null) { if (id != null ? !id.equals(task.id) : task.id != null) {
return false; return false;
} }
@ -1188,7 +1180,6 @@ public class Task implements Parcelable {
result = 31 * result + (tags != null ? tags.hashCode() : 0); result = 31 * result + (tags != null ? tags.hashCode() : 0);
result = 31 * result + (googleTaskList != null ? googleTaskList.hashCode() : 0); result = 31 * result + (googleTaskList != null ? googleTaskList.hashCode() : 0);
result = 31 * result + (caldav != null ? caldav.hashCode() : 0); result = 31 * result + (caldav != null ? caldav.hashCode() : 0);
result = 31 * result + (hasFiles ? 1 : 0);
return result; return result;
} }

@ -5,7 +5,6 @@ import androidx.room.ColumnInfo;
import androidx.room.Entity; import androidx.room.Entity;
import androidx.room.PrimaryKey; import androidx.room.PrimaryKey;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.todoroo.andlib.data.Property;
import com.todoroo.andlib.data.Table; import com.todoroo.andlib.data.Table;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import java.io.File; import java.io.File;
@ -17,8 +16,6 @@ public final class TaskAttachment {
public static final String KEY = "attachment"; public static final String KEY = "attachment";
@Deprecated
public static final Property.LongProperty ID = new Property.LongProperty(TABLE, "_id");
/** default directory for files on external storage */ /** default directory for files on external storage */
public static final String FILES_DIRECTORY_DEFAULT = "attachments"; // $NON-NLS-1$ public static final String FILES_DIRECTORY_DEFAULT = "attachments"; // $NON-NLS-1$

@ -1,7 +1,6 @@
package org.tasks.ui; package org.tasks.ui;
import static com.todoroo.astrid.activity.TaskListFragment.CALDAV_METADATA_JOIN; import static com.todoroo.astrid.activity.TaskListFragment.CALDAV_METADATA_JOIN;
import static com.todoroo.astrid.activity.TaskListFragment.FILE_METADATA_JOIN;
import static com.todoroo.astrid.activity.TaskListFragment.GTASK_METADATA_JOIN; import static com.todoroo.astrid.activity.TaskListFragment.GTASK_METADATA_JOIN;
import static com.todoroo.astrid.activity.TaskListFragment.TAGS_METADATA_JOIN; import static com.todoroo.astrid.activity.TaskListFragment.TAGS_METADATA_JOIN;
@ -30,7 +29,6 @@ import org.tasks.data.CaldavTask;
import org.tasks.data.GoogleTask; import org.tasks.data.GoogleTask;
import org.tasks.data.LimitOffsetDataSource; import org.tasks.data.LimitOffsetDataSource;
import org.tasks.data.Tag; import org.tasks.data.Tag;
import org.tasks.data.TaskAttachment;
import org.tasks.preferences.Preferences; import org.tasks.preferences.Preferences;
public class TaskListViewModel extends ViewModel { public class TaskListViewModel extends ViewModel {
@ -100,9 +98,6 @@ public class TaskListViewModel extends ViewModel {
// elsewhere. // elsewhere.
String joinedQuery = String joinedQuery =
Join.left(Tag.TABLE.as(TAGS_METADATA_JOIN), tagsJoinCriterion).toString() // $NON-NLS-1$ Join.left(Tag.TABLE.as(TAGS_METADATA_JOIN), tagsJoinCriterion).toString() // $NON-NLS-1$
+ Join.left(
TaskAttachment.TABLE.as(FILE_METADATA_JOIN),
Task.UUID.eq(Field.field(FILE_METADATA_JOIN + ".task_id")))
+ Join.left(GoogleTask.TABLE.as(GTASK_METADATA_JOIN), gtaskJoinCriterion).toString() + Join.left(GoogleTask.TABLE.as(GTASK_METADATA_JOIN), gtaskJoinCriterion).toString()
+ Join.left(CaldavTask.TABLE.as(CALDAV_METADATA_JOIN), caldavJoinCriterion).toString() + Join.left(CaldavTask.TABLE.as(CALDAV_METADATA_JOIN), caldavJoinCriterion).toString()
+ filter.getSqlQuery(); + filter.getSqlQuery();

Loading…
Cancel
Save