Move getLimitOffsetDataSource

pull/513/head
Alex Baker 7 years ago
parent 87aa964d1d
commit de7a0242ad

@ -8,9 +8,7 @@ package com.todoroo.astrid.dao;
import static com.todoroo.andlib.utility.DateUtilities.now; import static com.todoroo.andlib.utility.DateUtilities.now;
import android.arch.persistence.room.Dao; import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert; import android.arch.persistence.room.Insert;
import android.arch.persistence.room.Transaction;
import android.arch.persistence.room.Update; import android.arch.persistence.room.Update;
import android.content.Context; import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
@ -25,9 +23,6 @@ import com.todoroo.astrid.helper.UUIDHelper;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.tasks.BuildConfig; import org.tasks.BuildConfig;
import org.tasks.data.GoogleTaskAccount;
import org.tasks.data.GoogleTaskList;
import org.tasks.data.LimitOffsetDataSource;
import org.tasks.jobs.AfterSaveIntentService; import org.tasks.jobs.AfterSaveIntentService;
import timber.log.Timber; import timber.log.Timber;
@ -241,16 +236,6 @@ public abstract class TaskDao {
return database.rawQuery(queryString); return database.rawQuery(queryString);
} }
public LimitOffsetDataSource getLimitOffsetDataSource(
String queryTemplate, Property<?>... properties) {
String query =
Query.select(properties)
.withQueryTemplate(PermaSql.replacePlaceholdersForQuery(queryTemplate))
.from(Task.TABLE)
.toString();
return new LimitOffsetDataSource(database, query);
}
/** Generates SQL clauses */ /** Generates SQL clauses */
public static class TaskCriteria { public static class TaskCriteria {

@ -14,12 +14,14 @@ import com.todoroo.andlib.data.Property;
import com.todoroo.andlib.sql.Criterion; import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Field; import com.todoroo.andlib.sql.Field;
import com.todoroo.andlib.sql.Join; import com.todoroo.andlib.sql.Join;
import com.todoroo.andlib.sql.Query;
import com.todoroo.astrid.api.CaldavFilter; import com.todoroo.astrid.api.CaldavFilter;
import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.GtasksFilter; import com.todoroo.astrid.api.GtasksFilter;
import com.todoroo.astrid.api.PermaSql;
import com.todoroo.astrid.api.TagFilter; import com.todoroo.astrid.api.TagFilter;
import com.todoroo.astrid.core.SortHelper; import com.todoroo.astrid.core.SortHelper;
import com.todoroo.astrid.dao.TaskDao; import com.todoroo.astrid.dao.Database;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.data.CaldavTask; import org.tasks.data.CaldavTask;
@ -31,8 +33,8 @@ import org.tasks.preferences.Preferences;
public class TaskListViewModel extends ViewModel { public class TaskListViewModel extends ViewModel {
@Inject TaskDao taskDao;
@Inject Preferences preferences; @Inject Preferences preferences;
@Inject Database database;
private LimitOffsetDataSource latest; private LimitOffsetDataSource latest;
private LiveData<PagedList<Task>> tasks; private LiveData<PagedList<Task>> tasks;
@ -116,7 +118,17 @@ public class TaskListViewModel extends ViewModel {
groupedQuery = query + " GROUP BY " + Task.ID; groupedQuery = query + " GROUP BY " + Task.ID;
} }
return taskDao.getLimitOffsetDataSource(groupedQuery, properties); return getLimitOffsetDataSource(groupedQuery, properties);
}
private LimitOffsetDataSource getLimitOffsetDataSource(
String queryTemplate, Property<?>... properties) {
String query =
Query.select(properties)
.withQueryTemplate(PermaSql.replacePlaceholdersForQuery(queryTemplate))
.from(Task.TABLE)
.toString();
return new LimitOffsetDataSource(database, query);
} }
public void invalidate() { public void invalidate() {

Loading…
Cancel
Save