//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);
            }
        }
 //populate list
 private void populateItemsList(View view, int gId)
 {
     try
     {
         gTasks             = GoalsCollection.GetGoalTasks(gId);
         adapter            = new GoalTasksAdapter(view.Context, gTasks);
         mListTasks.Adapter = adapter;
     }
     catch (Exception ex)
     {
         Toast.MakeText(view.Context, "Error: " + ex.Message, ToastLength.Long).Show();
     }
 }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

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

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);

            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);

            txtTask     = FindViewById <EditText>(Resource.Id.txtTask);
            txtTaskDesc = FindViewById <EditText>(Resource.Id.txtTaskDetails);
            taskGoal    = FindViewById <Spinner>(Resource.Id.spinTaskGoal);

            allgoals         = GoalsCollection.SpinnerGoals();
            adapter          = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, allgoals);
            taskGoal.Adapter = adapter;

            //task start
            dteTaskStart        = FindViewById <TextView>(Resource.Id.AddGTStarts);
            dteTaskStart.Text   = DateTime.Now.ToShortDateString();
            dteTaskStart.Click += DteTaskStart_Click;

            //task start reset
            dteTaskStartReset        = FindViewById <TextView>(Resource.Id.AddGTStartsReset);
            dteTaskStartReset.Click += delegate
            {        //Reset goal start
                dteTaskStart.Text = DateTime.Now.ToShortDateString();
            };

            //task deadline
            dteTaskDeadline        = FindViewById <TextView>(Resource.Id.AddGTDeadline);
            dteTaskDeadline.Text   = DateTime.Now.ToShortDateString();
            dteTaskDeadline.Click += DteTaskDeadline_Click;

            //task deadline reset
            dteTaskDeadlineReset        = FindViewById <TextView>(Resource.Id.AddGTDeadlineReset);
            dteTaskDeadlineReset.Click += delegate
            {        //Reset goal deadline
                dteTaskDeadline.Text = DateTime.Now.ToShortDateString();
            };
        }
Example #4
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);
        }
Example #5
0
        //check if goal near deadline
        public void CheckUpdate()
        {
            Thread t = new Thread(() =>
            {
                Thread.Sleep(6000);
                if (GoalsCollection.CheckItem(DateTime.Now))
                {
                    var nMgr = (NotificationManager)GetSystemService(NotificationService);

                    //Details of notification in previous recipe
                    Notification.Builder builder = new Notification.Builder(this)
                                                   .SetAutoCancel(true)
                                                   .SetContentTitle("Goals Deadline")
                                                   .SetNumber(notifyId)
                                                   .SetContentText("Some goals deadline are today. Please check to update progress.")
                                                   .SetVibrate(new long[] { 100, 200, 300 })
                                                   .SetSmallIcon(Resource.Drawable.ic_bell);

                    nMgr.Notify(0, builder.Build());
                }
            });

            t.Start();
        }