private void Add_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(_activityName.Text))
                {
                    _activityName.Error = Activity.GetString(Resource.String.ActivityTimeFragmentAddToast);
                    return;
                }

                //get the activity
                Activities activity = GlobalData.ActivitiesForWeek[_groupPosition];
                if (activity.ActivityID == -1)
                {
                    activity.IsNew   = true;
                    activity.IsDirty = false;
                    Log.Info(TAG, "Add_Click: Activity ID is -1, setting IsNew, resetting IsDirty");
                }
                else
                {
                    Log.Info(TAG, "Add_Click: Activity ID is valid - " + activity.ActivityID.ToString() + ", set IsDirty, reset IsNew");
                    activity.IsDirty = true;
                    activity.IsNew   = false;
                }

                ActivityTime activityTime;
                Log.Info(TAG, "Add_Click: Created ActivityTime...");
                if (activity.ActivityTimes[_childPosition].ActivityTimeID == -1)
                {
                    activityTime         = new ActivityTime();
                    activityTime.IsNew   = true;
                    activityTime.IsDirty = false;
                    Log.Info(TAG, "Add_Click: ActivityTime is new - set IsNew, reset IsDirty");
                }
                else
                {
                    activityTime         = activity.ActivityTimes[_childPosition];
                    activityTime.IsNew   = false;
                    activityTime.IsDirty = true;
                    Log.Info(TAG, "Add_Click: Existing ActivityTime ID - " + activityTime.ActivityTimeID.ToString() + ", set IsDirty, reset IsNew");
                }
                Log.Info(TAG, "Add_Click: ActivityTime has been defined as a" + (activityTime.IsNew ? " new" : "n existing") + " ActivityTime");
                activityTime.ActivityID = activity.ActivityID;
                Log.Info(TAG, "Add_Click: Set ActivityTime ActivityID to " + activityTime.ActivityID.ToString());
                activityTime.ActivityName = _activityName.Text.Trim();
                Log.Info(TAG, "Add_Click: ActivityName - " + activityTime.ActivityName);
                activityTime.ActivityTime = _activityHours;
                Log.Info(TAG, "Add_Click: ActivityTime - " + StringHelper.ActivityTimeForConstant(_activityHours));
                activityTime.Achievement = _achievement.Progress;
                activityTime.Intimacy    = _intimacy.Progress;
                activityTime.Pleasure    = _pleasure.Progress;
                Log.Info(TAG, "Add_Click: Achievement - " + activityTime.Achievement.ToString() + ", Intimacy - " + activityTime.Intimacy.ToString() + ", Pleasure - " + activityTime.Pleasure.ToString());

                activity.ActivityTimes[_childPosition] = activityTime;
                Log.Info(TAG, "Add_Click: Set Activity Time at position " + _childPosition.ToString());
                GlobalData.ActivitiesForWeek[_groupPosition] = activity;
                Log.Info(TAG, "Add_Click: Set Activity in GlobalData at position " + _groupPosition.ToString());
                Log.Info(TAG, "Add_Click: Calling CompletedActivityTime with groupPosition - " + _groupPosition.ToString() + ", childPosition - " + _childPosition.ToString());
                ((IActivityTimeCallback)Activity).CompletedActivityTime(_groupPosition, _childPosition);

                Dismiss();
            }
            catch (Exception ex)
            {
                Log.Error(TAG, "Add_Click: Exception - " + ex.Message);
                if (GlobalData.ShowErrorDialog)
                {
                    ErrorDisplay.ShowErrorAlert(Activity, ex, GetString(Resource.String.ErrorActivityTimeFragAmendingActivityTime), "ActivityTimeDialogFragment.Add_Click");
                }
            }
        }
        private bool GetUpComingActivity()
        {
            Globals dbHelp = null;
            bool    didGet = false;

            try
            {
                if (_notificationBody != null)
                {
                    if (_notificationImage != null)
                    {
                        ApplyRelevantImageResource(ConstantsAndTypes.NotificationCategories.Activity);
                    }
                    else
                    {
                        Log.Error(TAG, "GetUpComingActivity: _notificationImage is NULL!");
                    }
                    if (_notificationText != null)
                    {
                        dbHelp = new Globals();
                        dbHelp.OpenDatabase();
                        if (dbHelp.GetSQLiteDatabase().IsOpen)
                        {
                            DateTime startDate = DateTime.Now;
                            if (GlobalData.ActivitiesForWeek != null)
                            {
                                if (GlobalData.ActivitiesForWeek.Count > 0)
                                {
                                    var laterActivities =
                                        (from itemActivity in GlobalData.ActivitiesForWeek
                                         where itemActivity.ActivityDate >= startDate
                                         select itemActivity).ToList();

                                    foreach (Activities activities in laterActivities)
                                    {
                                        //we need to find if there are any activities in this item
                                        if (activities.GetTotalNumberOfActivities() > 0)
                                        {
                                            bool getNextActivity = false;
                                            foreach (ActivityTime activityTime in activities.ActivityTimes)
                                            {
                                                if (activities.ActivityDate > startDate)
                                                {
                                                    getNextActivity = true;
                                                }
                                                if (!string.IsNullOrEmpty(activityTime.ActivityName.Trim()) && getNextActivity)
                                                {
                                                    _notificationText.Text = _activity.GetString(Resource.String.MainNotHelpNextActivity) + " " + activities.ActivityDate.ToShortDateString() + " " + StringHelper.ActivityTimeForConstant(activityTime.ActivityTime) + ",\n" + activityTime.ActivityName;
                                                    didGet = true;
                                                    break;
                                                }
                                                ConstantsAndTypes.NumericComparator comparator = DateHelper.CompareSpecifiedTimeWithActivityTimeRange(startDate, activityTime.ActivityTime);
                                                if (comparator == ConstantsAndTypes.NumericComparator.EqualTo)
                                                {
                                                    if (!string.IsNullOrEmpty(activityTime.ActivityName.Trim()))
                                                    {
                                                        _notificationText.Text = _activity.GetString(Resource.String.MainNotHelpNextActivity) + " " + activities.ActivityDate.ToShortDateString() + " " + StringHelper.ActivityTimeForConstant(activityTime.ActivityTime) + ",\n" + activityTime.ActivityName;
                                                        didGet = true;
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        getNextActivity = true;
                                                    }
                                                }
                                                if (comparator == ConstantsAndTypes.NumericComparator.LessThan)
                                                {
                                                    //we will cycle thru from here to the next activity
                                                    getNextActivity = true;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        Log.Error(TAG, "GetUpComingActivity: _notificationText is NULL!");
                    }
                }
                else
                {
                    Log.Error(TAG, "GetUpComingActivity: _notificationBody is NULL!");
                }
            }
            catch (Exception e)
            {
                Log.Error(TAG, "GetUpComingActivity: Exception - " + e.Message);
                if (GlobalData.ShowErrorDialog)
                {
                    ErrorDisplay.ShowErrorAlert(_activity, e, _activity.GetString(Resource.String.ErrorGetRandomActivity), "MainNotificationHelper.GetUpComingActivity");
                }
            }
            return(didGet);
        }