public MedicationReminderDialogFragment(Activity activity, MedicationListActivity fragment,
                                         ConstantsAndTypes.PRESCRIPTION_TYPE prescriptionType,
                                         ConstantsAndTypes.DAYS_OF_THE_WEEK dayOfWeek,
                                         int medicationSpreadID,
                                         DateTime reminderTime, string title)
 {
     _activity           = activity;
     _fragment           = fragment;
     _prescriptionType   = prescriptionType;
     _dayOfWeek          = dayOfWeek;
     _medicationSpreadID = medicationSpreadID;
     _reminderTime       = reminderTime;
     Log.Info(TAG, "Constructor, dayOfWeek - " + StringHelper.DayStringForConstant(dayOfWeek) + ", medicationSpreadID - " + medicationSpreadID.ToString());
     _dialogTitle = title;
 }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            try
            {
                if (Dialog != null)
                {
                    Dialog.SetTitle(_dialogTitle);
                }

                View view = inflater.Inflate(Resource.Layout.MedicationReminderDialogFragmentLayout, container, false);

                if (view != null)
                {
                    GetFieldComponents(view);
                    Log.Info(TAG, "OnCreateView: Got field components");

                    SetupCallbacks();
                    Log.Info(TAG, "OnCreateView: Setup callbacks");

                    if (savedInstanceState != null)
                    {
                        _prescriptionType   = (ConstantsAndTypes.PRESCRIPTION_TYPE)savedInstanceState.GetInt("prescriptionType", -1);
                        _dayOfWeek          = (ConstantsAndTypes.DAYS_OF_THE_WEEK)savedInstanceState.GetInt("dayOfWeek", (int)ConstantsAndTypes.DAYS_OF_THE_WEEK.Monday);
                        _medicationSpreadID = savedInstanceState.GetInt("medicationSpreadID", -1);
                        _reminderTime       = Convert.ToDateTime(savedInstanceState.GetString("reminderTime"));
                        _dialogTitle        = savedInstanceState.GetString("dialogTitle");
                    }

                    _timeText.Text = _reminderTime.ToShortTimeString();

                    SetupSpinner();
                    Log.Info(TAG, "OnCreateView: Set up spinner");

                    if (_firstTimeView)
                    {
                        switch (_prescriptionType)
                        {
                        case ConstantsAndTypes.PRESCRIPTION_TYPE.Weekly:
                            if (_dayLabel != null)
                            {
                                _dayLabel.Visibility = ViewStates.Visible;
                            }
                            if (_daySpinner != null)
                            {
                                _daySpinner.Visibility = ViewStates.Visible;
                                _daySpinner.SetSelection((int)_dayOfWeek);
                            }
                            if (_timeText != null)
                            {
                                _timeText.Text = _reminderTime.ToShortTimeString();
                            }
                            break;

                        default:
                            if (_dayLabel != null)
                            {
                                _dayLabel.Visibility = ViewStates.Invisible;
                            }
                            if (_daySpinner != null)
                            {
                                _daySpinner.Visibility = ViewStates.Invisible;
                            }
                            if (_timeText != null)
                            {
                                _timeText.Text = _reminderTime.ToShortTimeString();
                            }
                            break;
                        }
                        _firstTimeView = false;
                    }
                }
                else
                {
                    Log.Error(TAG, "OnCreateView: View is NULL!");
                }
                return(view);
            }
            catch (Exception e)
            {
                Log.Error(TAG, "OnCreateView: Exception - " + e.Message);
                if (GlobalData.ShowErrorDialog)
                {
                    ErrorDisplay.ShowErrorAlert(Activity, e, Activity.GetString(Resource.String.ErrorMedListFragCreateView), "MedicationreminderDialogFragment.OnCreateView");
                }
                return(null);
            }
        }