public ClearedTaskModel(TaskModel taskModel)
 {
     Checked = taskModel.Checked;
     DateCompleted = DateTime.UtcNow;
     DateCreated = taskModel.DateCreated;
     DueDate = taskModel.DueDate;
     PhoneNumber = taskModel.PhoneNumber;
     Task = taskModel.Task;
 }
Ejemplo n.º 2
0
 public static int SaveTask(TaskModel item)
 {
     return DataLayer.TaskDatabase.SaveItem<TaskModel>(item);
 }
Ejemplo n.º 3
0
        private void ReloadData(int startId)
        {
            m_AllTasks.Clear();
            foreach(var task in DataManager.GetTasks(Settings.SortBy))
            {
                m_AllTasks.Add(task);
            }

            #if DEBUG
            if(m_AllTasks.Count == 0)
            {
                m_AllTasks = new JavaList<TaskModel>();
                foreach (var item in m_FakeData)
                {
                    var task = new TaskModel {Task = item};
                    task.ID = DataManager.SaveTask(task);
                    m_AllTasks.Add(task);
                }
            }
            #endif
            RunOnUiThread(() =>
            {
                ListAdapter = new TaskAdapter(this, m_AllTasks);
                if (ListView.Visibility == ViewStates.Gone)
                {
                    ListView.Visibility = ViewStates.Visible;
                    ListView.StartAnimation(AnimationUtils.LoadAnimation(this, Resource.Animation.fadein));
                }
            });

            SetChecks();

            SetActionBar();

            if (startId == 0)
                    return;

            var firstTask = m_AllTasks.FirstOrDefault(t => t.ID == startId);
            if(firstTask == null)
                return;

            var itemIndex = m_AllTasks.IndexOf(firstTask);
            RunOnUiThread(()=> ListView.SetSelection(itemIndex));
        }
Ejemplo n.º 4
0
        private void AddNewTask()
        {
            var task = m_TaskEditText.Text.Trim();

            if (string.IsNullOrWhiteSpace(task))
                return;

            m_DataChanged = true;
            var newTask = new TaskModel {Task = task};

            try
            {
                DataManager.SaveTask(newTask);

                var selection = 0;
                switch(Settings.SortBy)
                {
                    case SortOption.Newest:
                        m_AllTasks.Insert(0, newTask);
                        SetChecks();
                        break;
                    case SortOption.Oldest:
                        m_AllTasks.Add(newTask);
                        selection = m_AllTasks.Count - 1;
                        break;
                }

                m_TaskEditText.Text = string.Empty;

                RunOnUiThread(() =>
                                  {
                                      ((TaskAdapter)ListAdapter).NotifyDataSetChanged();
                                      ListView.SetSelection(selection);
                                  });
            }
            catch (Exception)
            {
                RunOnUiThread(() => Toast.MakeText(this, Resource.String.unable_to_save,
                                                   ToastLength.Short).Show());

            }
        }