Example #1
0
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            switch (viewType)
            {
            case 0:
            {
                // The Activity details at the top of the list
                View activityView      = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.TaskCard_Activity, parent, false);
                ActivityViewHolder avh = new ActivityViewHolder(activityView, null, OnEditActivityClick);
                return(avh);
            }

            case 2:
            {
                // The finish button at the bottom of the list
                View             finishView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.TaskCard_Finish, parent, false);
                ButtonViewHolder bvh        = new ButtonViewHolder(finishView, OnFinishClick);
                return(bvh);
            }
            }

            View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.CreateTaskCard, parent, false);
            TaskViewHolderCreatedTask vh = new TaskViewHolderCreatedTask(itemView, null, OnDeleteItemClick, OnEditItemClick, OnManageChildrenClick);

            return(vh);
        }
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            if (position == 0)
            {
                ActivityViewHolder avh = holder as ActivityViewHolder;
                avh.Title.SetText(Resource.String.createTaskChildrenManage);
                avh.Button.Visibility = ViewStates.Gone;
                avh.Description.Text  = string.Format(context.Resources.GetString(Resource.String.createTaskChildrenDesc),
                                                      parentTask.TaskType.DisplayName);

                AndroidUtils.LoadTaskTypeIcon(parentTask.TaskType, avh.TaskTypeIcon);
                return;
            }

            if (position > data.Count)
            {
                // Allow the activity to be submitted if there's at least one task
                if (!(holder is ButtonViewHolder bvh))
                {
                    return;
                }

                bvh.Button.Enabled = true;
                bvh.Button.SetText(Resource.String.createTaskChildrenFinish);

                return;
            }

            position--;

            if (!(holder is TaskViewHolderCreatedTask vh))
            {
                return;
            }

            vh.Title.Text                   = data[position].TaskType.DisplayName;
            vh.Description.Text             = data[position].Description;
            vh.ManageChildrenBtn.Visibility = ViewStates.Gone;

            vh.DeleteBtn.Text = context.Resources.GetString(Resource.String.RemoveBtn);
            AndroidUtils.LoadTaskTypeIcon(data[position].TaskType, vh.TaskTypeIcon);
        }
Example #3
0
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            switch (viewType)
            {
            case 0:
            {
                // The Collection details at the top of the list
                View activityView      = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.TaskCard_Activity, parent, false);
                ActivityViewHolder avh = new ActivityViewHolder(activityView, null, OnEditCollectionClick);
                return(avh);
            }

            case 1:
            {
                // The collection description
                View           descView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.TaskCard, parent, false);
                TaskViewHolder dvh      = new TaskViewHolder(descView, null);
                return(dvh);
            }

            case 2:
            {
                // The finish button at the bottom of the list
                View             finishView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.TaskCard_Finish, parent, false);
                ButtonViewHolder bvh        = new ButtonViewHolder(finishView, OnFinishClick);
                return(bvh);
            }
            }

            View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.ActivityCollectionCard, parent, false);

            if (editingMode)
            {
                return(new ActivityCollectionAdapterViewHolder(itemView, null, OnDeleteItemClick, OnOpenLocationClick));
            }

            return(new ActivityCollectionAdapterViewHolder(itemView, null, OnOpenItemClick, OnOpenLocationClick));
        }