//Create Task
        private void TaskCreate()
        {
            try
            {
                DBHelper dbh = new DBHelper();

                //if (taskGoal.SelectedItemPosition < 0 )
                //{
                //    Toast.MakeText(this, "Select a goal!", ToastLength.Long).Show();
                //    return;
                //}
                if (txtTask.Text.Equals("") || txtTaskDesc.Text.Equals("") || dteTaskStart.Text.Equals("") || dteTaskDeadline.Text.Equals(""))
                {
                    Toast.MakeText(this, "Fill in all fields!", ToastLength.Long).Show();
                }
                else
                {
                    if (DateTime.Parse(dteTaskDeadline.Text) <= DateTime.Parse(dteTaskStart.Text))
                    {
                        Toast.MakeText(this, "Task deadline should be greater than task start!", ToastLength.Long).Show();
                        return;
                    }
                    else if (DateTime.Parse(dteTaskDeadline.Text) <= DateTime.Today)
                    {
                        Toast.MakeText(this, "Task deadline should be greater than current date!", ToastLength.Long).Show();
                    }
                    else
                    {
                        allgoals = GoalsCollection.GetGoals();
                        int    goal         = Convert.ToInt32(allgoals[taskGoal.SelectedItemPosition].Id);
                        string task         = DatabaseUtils.SqlEscapeString(txtTask.Text);
                        string taskDesc     = DatabaseUtils.SqlEscapeString(txtTaskDesc.Text);
                        string taskStart    = dteTaskStart.Text;
                        string taskDeadline = dteTaskDeadline.Text;

                        string result = dbh.CreateGoalTask(task, goal, taskDesc, taskStart, taskDeadline);

                        if (result.Equals("ok"))
                        {
                            Toast.MakeText(this, "Goal task added!", ToastLength.Short).Show();
                            Finish();
                        }
                        else
                        {
                            Toast.MakeText(this, "Failed adding goal task\n. Error info:" + result, ToastLength.Short).Show();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, "Error:\n" + ex.Message, ToastLength.Long);
            }
        }
Exemple #2
0
        private void SetUpRecyclerView(RecyclerView view)
        {
            //Create recycler layout manager
            mLayoutManager = new LinearLayoutManager(view.Context);

            //Set recycler layout manager
            view.SetLayoutManager(mLayoutManager);

            //Get adapter
            mGoalsRecyclerAdapter = new GoalsRecyclerAdapter(GoalsCollection.GetGoals(), view);

            //on click event
            mGoalsRecyclerAdapter.ItemClick += MGoalsRecyclerAdapter_ItemClick;

            //Set adapter
            view.SetAdapter(mGoalsRecyclerAdapter);
        }