|
|
|
@ -5,11 +5,16 @@
|
|
|
|
|
*/
|
|
|
|
|
package com.todoroo.astrid.gtasks;
|
|
|
|
|
|
|
|
|
|
import android.app.Activity;
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.support.v7.widget.Toolbar;
|
|
|
|
|
import android.view.MenuItem;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.widget.ListView;
|
|
|
|
|
|
|
|
|
|
import com.todoroo.andlib.data.Property;
|
|
|
|
|
import com.todoroo.andlib.data.TodorooCursor;
|
|
|
|
|
import com.todoroo.astrid.activity.TaskListFragment;
|
|
|
|
|
import com.todoroo.astrid.adapter.TaskAdapter;
|
|
|
|
|
import com.todoroo.astrid.api.GtasksFilter;
|
|
|
|
@ -19,15 +24,15 @@ import com.todoroo.astrid.dao.TaskDao;
|
|
|
|
|
import com.todoroo.astrid.data.StoreObject;
|
|
|
|
|
import com.todoroo.astrid.data.Task;
|
|
|
|
|
import com.todoroo.astrid.service.SyncV2Service;
|
|
|
|
|
import com.todoroo.astrid.subtasks.OrderedListFragmentHelperInterface;
|
|
|
|
|
import com.todoroo.astrid.subtasks.SubtasksListFragment;
|
|
|
|
|
import com.todoroo.astrid.sync.SyncResultCallback;
|
|
|
|
|
import com.todoroo.astrid.tags.TagService;
|
|
|
|
|
|
|
|
|
|
import org.tasks.Broadcaster;
|
|
|
|
|
import org.tasks.R;
|
|
|
|
|
import org.tasks.dialogs.DialogBuilder;
|
|
|
|
|
import org.tasks.injection.ForApplication;
|
|
|
|
|
import org.tasks.injection.FragmentComponent;
|
|
|
|
|
import org.tasks.preferences.Preferences;
|
|
|
|
|
import org.tasks.themes.Theme;
|
|
|
|
|
import org.tasks.themes.ThemeCache;
|
|
|
|
|
import org.tasks.ui.CheckBoxes;
|
|
|
|
|
|
|
|
|
@ -36,7 +41,7 @@ import java.util.Arrays;
|
|
|
|
|
|
|
|
|
|
import javax.inject.Inject;
|
|
|
|
|
|
|
|
|
|
public class GtasksListFragment extends SubtasksListFragment {
|
|
|
|
|
public class GtasksListFragment extends TaskListFragment {
|
|
|
|
|
|
|
|
|
|
public static TaskListFragment newGtasksListFragment(GtasksFilter filter, GtasksList list) {
|
|
|
|
|
GtasksListFragment fragment = new GtasksListFragment();
|
|
|
|
@ -50,23 +55,19 @@ public class GtasksListFragment extends SubtasksListFragment {
|
|
|
|
|
@Inject TaskDao taskDao;
|
|
|
|
|
@Inject MetadataDao metadataDao;
|
|
|
|
|
@Inject GtasksTaskListUpdater gtasksTaskListUpdater;
|
|
|
|
|
@Inject GtasksPreferenceService gtasksPreferenceService;
|
|
|
|
|
@Inject SyncV2Service syncService;
|
|
|
|
|
@Inject TaskAttachmentDao taskAttachmentDao;
|
|
|
|
|
@Inject Preferences preferences;
|
|
|
|
|
@Inject DialogBuilder dialogBuilder;
|
|
|
|
|
@Inject Broadcaster broadcaster;
|
|
|
|
|
@Inject CheckBoxes checkBoxes;
|
|
|
|
|
@Inject TagService tagService;
|
|
|
|
|
@Inject ThemeCache themeCache;
|
|
|
|
|
@Inject @ForApplication Context context;
|
|
|
|
|
@Inject Theme theme;
|
|
|
|
|
|
|
|
|
|
private GtasksList list;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected OrderedListFragmentHelperInterface createFragmentHelper() {
|
|
|
|
|
return new OrderedMetadataListFragmentHelper<>(preferences, taskAttachmentDao, taskDao,
|
|
|
|
|
metadataDao, this, gtasksTaskListUpdater, dialogBuilder, checkBoxes, tagService, themeCache);
|
|
|
|
|
}
|
|
|
|
|
protected OrderedMetadataListFragmentHelper<GtasksList> helper;
|
|
|
|
|
private int lastVisibleIndex = -1;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
|
|
@ -77,7 +78,7 @@ public class GtasksListFragment extends SubtasksListFragment {
|
|
|
|
|
list = new GtasksList(storeObject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
((OrderedMetadataListFragmentHelper<GtasksList>)helper).setList(list);
|
|
|
|
|
helper.setList(list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -94,6 +95,7 @@ public class GtasksListFragment extends SubtasksListFragment {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onTaskDelete(Task task) {
|
|
|
|
|
super.onTaskDelete(task);
|
|
|
|
|
helper.onDeleteTask(task);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -132,4 +134,62 @@ public class GtasksListFragment extends SubtasksListFragment {
|
|
|
|
|
properties.add(gtasksTaskListUpdater.orderProperty());
|
|
|
|
|
return properties.toArray(new Property<?>[properties.size()]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onAttach(Activity activity) {
|
|
|
|
|
super.onAttach(activity);
|
|
|
|
|
|
|
|
|
|
helper = new OrderedMetadataListFragmentHelper<>(preferences, taskAttachmentDao, taskDao,
|
|
|
|
|
metadataDao, this, gtasksTaskListUpdater, dialogBuilder, checkBoxes, tagService, themeCache);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected int getListBody() {
|
|
|
|
|
return R.layout.task_list_body_subtasks;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
|
|
|
|
super.onViewCreated(view, savedInstanceState);
|
|
|
|
|
|
|
|
|
|
helper.setUpUiComponents();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setTaskAdapter() {
|
|
|
|
|
helper.beforeSetUpTaskList(filter);
|
|
|
|
|
|
|
|
|
|
super.setTaskAdapter();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onPause() {
|
|
|
|
|
super.onPause();
|
|
|
|
|
lastVisibleIndex = getListView().getFirstVisiblePosition();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onResume() {
|
|
|
|
|
super.onResume();
|
|
|
|
|
ListView listView = getListView();
|
|
|
|
|
if (lastVisibleIndex >= 0) {
|
|
|
|
|
listView.setSelection(lastVisibleIndex);
|
|
|
|
|
}
|
|
|
|
|
unregisterForContextMenu(listView);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onTaskCreated(String uuid) {
|
|
|
|
|
helper.onCreateTask(uuid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected TaskAdapter createTaskAdapter(TodorooCursor<Task> cursor) {
|
|
|
|
|
return helper.createTaskAdapter(theme.wrap(context), cursor, taskListDataProvider.getSqlQueryTemplate());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void inject(FragmentComponent component) {
|
|
|
|
|
component.inject(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|