Beispiel #1
0
        private void ActivitiesWeek_ItemLongClick(object sender, AdapterView.ItemLongClickEventArgs e)
        {
            try
            {
                long packedPosition = _activitiesWeek.GetExpandableListPosition(e.Position);

                if (ExpandableListView.GetPackedPositionType(packedPosition) == PackedPositionType.Child)
                {
                    // get item ID's
                    int groupPosition = ExpandableListView.GetPackedPositionGroup(packedPosition);
                    int childPosition = ExpandableListView.GetPackedPositionChild(packedPosition);

                    Activities   activity     = GlobalData.ActivitiesForWeek[groupPosition];
                    ActivityTime activityTime = activity.ActivityTimes[childPosition];

                    string startTime, endTime;

                    StringHelper.ActivityTimeBeginEndForConstant(activityTime.ActivityTime, out startTime, out endTime);

                    _timeFragment = new ActivityTimeDialogFragment(this, activity.ActivityDate, activityTime.ActivityTime, startTime, endTime, groupPosition, childPosition, "Add Activity");

                    var fragmentTransaction = FragmentManager.BeginTransaction();
                    _timeFragment.Show(fragmentTransaction, _timeFragment.Tag);

                    Log.Info(TAG, "ActivitiesWeek_ItemLongClick: groupPosition - " + groupPosition.ToString() + ", childPosition - " + childPosition.ToString());

                    e.Handled = true;
                }
            }
            catch (Exception ex)
            {
                Log.Error(TAG, "ActivitiesWeek_ItemLongClick: Exception - " + ex.Message);
                if (GlobalData.ShowErrorDialog)
                {
                    ErrorDisplay.ShowErrorAlert(this, ex, GetString(Resource.String.ErrorActivitySelectChildItem), "ActivitiesActivity.ActivitiesWeek_ItemLongClick");
                }
            }
        }
        public override View GetChildView(int groupPosition, int childPosition, bool isLastChild, View convertView, ViewGroup parent)
        {
            try
            {
                if (convertView == null)
                {
                    if (_parent != null)
                    {
                        convertView = _parent.LayoutInflater.Inflate(Resource.Layout.ActivitiesChildItem, null);
                        Log.Info(TAG, "GetChildView: Inflated Activities Child Item successfully, groupPosition - " + groupPosition.ToString() + ", childPosition - " + childPosition.ToString());
                    }
                    else if (parent != null)
                    {
                        LayoutInflater inflator = (LayoutInflater)_parent.GetSystemService(Context.LayoutInflaterService);
                        convertView = inflator.Inflate(Resource.Layout.ActivitiesChildItem, null);
                    }
                    else
                    {
                        return(convertView);
                    }
                }

                if (convertView != null)
                {
                    GetChildFieldComponents(convertView);

                    if (_childTextView != null)
                    {
                        var childItem    = _activities[groupPosition].ActivityTimes[childPosition];
                        var activityName = (string.IsNullOrEmpty(childItem.ActivityName) ? _parent.GetString(Resource.String.ActivitiesNoActivity) : childItem.ActivityName);
                        _childTextView.Text = activityName;
                        if (childItem.ActivityTimeID == -1)
                        {
                            _hasActivitySet.Visibility  = ViewStates.Invisible;
                            _activitySummary.Visibility = ViewStates.Gone;
                        }
                        else
                        {
                            _hasActivitySet.Visibility  = ViewStates.Visible;
                            _activitySummary.Visibility = ViewStates.Visible;
                            _achievementSummary.Text    = childItem.Achievement.ToString() + "/10";
                            _intimacySummary.Text       = childItem.Intimacy.ToString() + "/10";
                            _pleasureSummary.Text       = childItem.Pleasure.ToString() + "/10";
                        }
                    }
                    else
                    {
                        Log.Error(TAG, "GetChildView: _childTextView is NULL!");
                    }
                    string startTime, endTime;
                    StringHelper.ActivityTimeBeginEndForConstant(_activities[groupPosition].ActivityTimes[childPosition].ActivityTime, out startTime, out endTime);
                    if (_childStartTime != null)
                    {
                        _childStartTime.Text = startTime;
                    }
                    else
                    {
                        Log.Error(TAG, "GetChildView: _childStartTime is NULL!");
                    }
                    if (_childEndTime != null)
                    {
                        _childEndTime.Text = endTime;
                    }
                    else
                    {
                        Log.Error(TAG, "GetChildView: _childEndTime is NULL!");
                    }
                }
                else
                {
                    Log.Error(TAG, "GetChildView: convertView is NULL!");
                }
            }
            catch (System.Exception e)
            {
                Log.Error(TAG, "GetChildView: Exception - " + e.Message);
                if (GlobalData.ShowErrorDialog)
                {
                    ErrorDisplay.ShowErrorAlert(_parent, e, _parent.GetString(Resource.String.ErrorActivityTimeAdapterChildView), "ActivitiesExpandableListAdapter.GetChildView");
                }
            }
            return(convertView);
        }