コード例 #1
0
        private void AddThoughtButton()
        {
            try
            {
                if (_automaticThought == null)
                {
                    return;
                }

                if (string.IsNullOrWhiteSpace(_automaticThought.Text.Trim()))
                {
                    var resourceString = GetString(Resource.String.automaticThoughtNoEvidence);
                    _automaticThought.Error = resourceString;
                    return;
                }

                AutomaticThoughts thought = new AutomaticThoughts();
                thought.ThoughtRecordId = GlobalData.ThoughtRecordId;
                thought.Thought         = _automaticThought.Text.Trim();
                if (GlobalData.AutomaticThoughtsItems == null)
                {
                    GlobalData.AutomaticThoughtsItems = new List <AutomaticThoughts>();
                }
                GlobalData.AutomaticThoughtsItems.Add(thought);

                UpdateAdapter();

                _automaticThought.Text = "";
            }
            catch (Exception ex)
            {
                Log.Error(TAG, "AddThoughtButton_Click: Exception - " + ex.Message);
                if (GlobalData.ShowErrorDialog)
                {
                    ErrorDisplay.ShowErrorAlert(this, ex, GetString(Resource.String.ErrorAddingAutomaticThought), "ThoughtRecordWizardAutomaticThoughtsStep.AddThoughtButton_Click");
                }
            }
        }
コード例 #2
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            try
            {
                var view = convertView ?? _activity.LayoutInflater.Inflate(Resource.Layout.AutomaticThoughtsListItem, parent, false);

                var thought = view.FindViewById <TextView>(Resource.Id.txtAutomaticThought);

                AutomaticThoughts thoughtEntry = _automaticThoughtEntries.ElementAt(position);
                thought.Text = thoughtEntry.Thought.Trim() + (thoughtEntry.IsHotThought ? "  " + _activity.GetString(Resource.String.HotThoughtTag): "");

                var parentHeldSelectedItemIndex = ((ThoughtRecordWizardAutomaticThoughtsStep)_activity).GetSelectedItem();
                if (position == parentHeldSelectedItemIndex)
                {
                    view.SetBackgroundColor(Color.Argb(255, 19, 75, 127));
                    thought.SetBackgroundColor(Color.Argb(255, 19, 75, 127));
                }
                else
                {
                    view.SetBackgroundDrawable(null);
                    thought.SetBackgroundDrawable(null);
                }
                return(view);
            }
            catch (Exception e)
            {
                Log.Error(TAG, "GetView: Exception - " + e.Message);
                if (_activity != null)
                {
                    if (GlobalData.ShowErrorDialog)
                    {
                        ErrorDisplay.ShowErrorAlert(_activity, e, _activity.GetString(Resource.String.ErrorGetAutoThoughtAdapterView), "AutomaticThoughtItemsAdapter.GetView");
                    }
                }
                return(null);
            }
        }