Пример #1
0
        private void TaskCheck_CheckedChange(object sender, CompoundButton.CheckedChangeEventArgs e)
        {
            // Update task checked state
            ValuedCheckItem checkedItem = sender as ValuedCheckItem;

            if (checkedItem == null)
            {
                return;
            }

            int taskId = Convert.ToInt32(checkedItem.AttachedValue);

            TaskManagerAPI.ProjectTask.UpdateTaskCompletedStatus(Token.AuthToken, taskId, e.IsChecked);
        }
Пример #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.TaskList);

            // Get Project Id
            int projectId = Intent.GetIntExtra("SelectedProjectId", -1);

            _projectId = projectId;

            // Get the tasks from the API
            TaskManagerAPI.ProjectTask[] tasks = TaskManagerAPI.ProjectTask.GetTasks(Token.AuthToken, projectId);

            // Get layout
            LinearLayout layout = FindViewById <LinearLayout>(Resource.Id.linearTaskList);

            // Put tasks onto screen
            foreach (var task in tasks)
            {
                ValuedCheckItem taskCheck = new ValuedCheckItem(this, task.ProjectTaskId.ToString());
                taskCheck.Text = task.Description;

                if (task.Completed)
                {
                    taskCheck.Checked = true;
                }

                taskCheck.CheckedChange += TaskCheck_CheckedChange;

                layout.AddView(taskCheck);
            }

            // Display a message if there are not tasks assigned to this project
            if (tasks.Count() == 0)
            {
                TextView noTasksText = new TextView(this);
                noTasksText.Text = "There are currently no tasks for this project!";
                noTasksText.SetTextColor(Android.Graphics.Color.Red);
                layout.AddView(noTasksText);
            }

            // Get the project
            TaskManagerAPI.Project proj = TaskManagerAPI.Project.GetProject(Token.AuthToken, _projectId);
            this.Title = proj.Name + " Tasks";
        }