Launch task comments view when non-editable task clicked

pull/14/head
Sam Bosley 12 years ago
parent 61eabcc3cf
commit 812c5b128e

@ -6,10 +6,12 @@ import android.view.ViewGroup;
import android.widget.ListView;
import com.timsu.astrid.R;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Query;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.adapter.UpdateAdapter;
import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.Update;
import com.todoroo.astrid.service.StatisticsConstants;
@ -18,6 +20,9 @@ public class TaskCommentsFragment extends CommentsFragment {
public static final String EXTRA_TASK = "extra_task"; //$NON-NLS-1$
@Autowired
private TaskDao taskDao;
private Task task;
public TaskCommentsFragment() {
@ -26,8 +31,10 @@ public class TaskCommentsFragment extends CommentsFragment {
@Override
protected void loadModelFromIntent(Intent intent) {
if (task == null)
task = intent.getParcelableExtra(EXTRA_TASK);
if (task == null) {
long taskId = intent.getLongExtra(EXTRA_TASK, 0L);
task = taskDao.fetch(taskId, Task.PROPERTIES);
}
}
@Override

@ -27,8 +27,10 @@ import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.astrid.actfm.CommentsActivity;
import com.todoroo.astrid.actfm.CommentsFragment;
import com.todoroo.astrid.actfm.TagCommentsFragment;
import com.todoroo.astrid.actfm.TaskCommentsFragment;
import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.FilterListItem;
@ -248,6 +250,14 @@ public class AstridActivity extends FragmentActivity
@Override
public void onTaskListItemClicked(long taskId, boolean editable) {
if (editable) {
editTask(taskId);
} else {
showComments(taskId);
}
}
private void editTask(long taskId) {
Intent intent = new Intent(this, TaskEditActivity.class);
intent.putExtra(TaskEditFragment.TOKEN_ID, taskId);
getIntent().putExtra(TaskEditFragment.TOKEN_ID, taskId); // Needs to be in activity intent so that TEA onResume doesn't create a blank activity
@ -286,6 +296,13 @@ public class AstridActivity extends FragmentActivity
}
}
private void showComments(long taskId) {
Intent intent = new Intent(this, CommentsActivity.class);
intent.putExtra(TaskCommentsFragment.EXTRA_TASK, taskId);
startActivity(intent);
AndroidUtilities.callOverridePendingTransition(this, R.anim.slide_left_in, R.anim.slide_left_out);
}
@Override
public void onBackPressed() {
if (isFinishing())

Loading…
Cancel
Save