Exemple #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);
        }
Exemple #2
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));
        }
Exemple #3
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            if (position == 0)
            {
                if (!(holder is ActivityViewHolder avh))
                {
                    return;
                }

                avh.Title.Text       = learningActivity.Name;
                avh.Description.Text = learningActivity.Description;

                if (string.IsNullOrWhiteSpace(learningActivity.ImageUrl))
                {
                    return;
                }

                if (learningActivity.ImageUrl.StartsWith("upload"))
                {
                    ImageService.Instance.LoadUrl(ServerUtils.GetUploadUrl(learningActivity.ImageUrl))
                    .Transform(new CircleTransformation())
                    .Into(avh.TaskTypeIcon);
                }
                else
                {
                    ImageService.Instance.LoadFile(learningActivity.ImageUrl)
                    .Transform(new CircleTransformation())
                    .Into(avh.TaskTypeIcon);
                }

                return;
            }

            if (position > Data.Count)
            {
                // Allow the activity to be submitted if there's at least one task
                ButtonViewHolder bvh = holder as ButtonViewHolder;
                bvh.Button.Enabled = Data.Count > 0;
                return;
            }

            position--;

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

            vh.Title.Text       = Data[position].TaskType.DisplayName;
            vh.Description.Text = Data[position].Description;

            if (((List <LearningTask>)Data[position].ChildTasks).Count > 0)
            {
                vh.ManageChildrenBtn.Text = context.GetString(Resource.String.createTaskChildrenManage);
            }
            else
            {
                vh.ManageChildrenBtn.Text = context.GetString(Resource.String.createTaskChildrenAdd);
            }

            vh.DeleteBtn.Text = context.Resources.GetString(Resource.String.RemoveBtn);
            AndroidUtils.LoadTaskTypeIcon(Data[position].TaskType, vh.TaskTypeIcon);
        }
Exemple #4
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            if (position == 0)
            {
                if (editingMode)
                {
                    if (!(holder is ActivityViewHolder avh))
                    {
                        return;
                    }

                    avh.Title.Text       = Collection.Name;
                    avh.Description.Text = Collection.Description;

                    if (string.IsNullOrWhiteSpace(Collection.ImageUrl))
                    {
                        return;
                    }

                    if (Collection.ImageUrl.StartsWith("upload"))
                    {
                        ImageService.Instance.LoadUrl(ServerUtils.GetUploadUrl(Collection.ImageUrl))
                        .Transform(new CircleTransformation())
                        .Into(avh.TaskTypeIcon);
                    }
                    else
                    {
                        ImageService.Instance.LoadFile(Collection.ImageUrl)
                        .Transform(new CircleTransformation())
                        .Into(avh.TaskTypeIcon);
                    }
                }
                else
                {
                    if (!(holder is TaskViewHolder tvh))
                    {
                        return;
                    }

                    tvh.Description.Text = Collection.Description;
                    tvh.Title.Visibility = ViewStates.Gone;
                }

                return;
            }

            if (position > Collection.Activities?.Count)
            {
                // Allow the collection to be submitted if there's at least two activities
                ButtonViewHolder bvh = holder as ButtonViewHolder;
                bvh.Button.Enabled = Collection.Activities.Count > 1;
                return;
            }

            position--;

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

            LearningActivity thisActivity = Collection.Activities[position];

            vh.Title.Text       = thisActivity.Name;
            vh.Description.Text = thisActivity.Description;

            if (thisActivity.Places?.Any() ?? false)
            {
                vh.LocationButton.Visibility = ViewStates.Visible;
                vh.LocationText.Text         = string.Format(CultureInfo.CurrentCulture,
                                                             context.GetString(Resource.String.createCollectionActivityLocation),
                                                             thisActivity.Places.FirstOrDefault()?.Name);
            }
            else
            {
                vh.LocationButton.Visibility = ViewStates.Gone;
                vh.LocationText.SetText(Resource.String.createCollectionActivityNoLocation);
            }

            if (string.IsNullOrWhiteSpace(thisActivity.ImageUrl))
            {
                ImageService.Instance.LoadCompiledResource("logoRect")
                .DownSampleInDip(width: 70)
                .Transform(new CircleTransformation())
                .IntoAsync(vh.ActivityIcon);
            }
            else
            {
                ImageService.Instance.LoadUrl(ServerUtils.GetUploadUrl(thisActivity.ImageUrl))
                .DownSampleInDip(width: 70)
                .Transform(new CircleTransformation())
                .IntoAsync(vh.ActivityIcon);
            }

            vh.HandleView.Visibility = (editingMode) ? ViewStates.Visible : ViewStates.Gone;

            if (!editingMode)
            {
                vh.RemoveButton.SetText(Resource.String.collectionStartActivity);
            }
        }
Exemple #5
0
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            // Inflate the CardView for the task:
            View itemView;

            switch (viewType)
            {
            case TaskScan:
            case TaskListen:
            case TaskLocationHunt:
                itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.TaskCard_Btn, parent, false);
                TaskViewHolderBtn bvh = new TaskViewHolderBtn(itemView, OnSpeakClick, OnClick);
                return(bvh);

            case TaskInfo:
                itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.TaskCard_Info, parent, false);
                TaskViewHolderInfo ivh = new TaskViewHolderInfo(itemView, OnSpeakClick, OnClick);
                ivh.Button.Text = context.GetString(Resource.String.ExternalBtn);
                return(ivh);

            case TaskDrawing:
            case TaskPhoto:
                itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.TaskCard_ResultList, parent, false);
                TaskViewHolderResultList pvh = new TaskViewHolderResultList(itemView, OnSpeakClick, OnClick, OnMediaClick);
                return(pvh);

            case TaskMultipleChoice:
                itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.TaskCard_MultipleChoice, parent, false);
                TaskViewHolderMultipleChoice vmh = new TaskViewHolderMultipleChoice(itemView, OnSpeakClick);
                return(vmh);

            case TaskLocationMarker:
                itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.TaskCard_Map, parent, false);
                TaskViewHolderMap mvh = new TaskViewHolderMap(itemView, OnSpeakClick, OnClick);
                return(mvh);

            case TaskTextEntry:
                itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.TaskCard_TextEntry, parent, false);
                TaskViewHolderTextEntry tvh = new TaskViewHolderTextEntry(itemView, OnSpeakClick, OnText);
                return(tvh);

            case TaskVideo:
                itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.TaskCard_ResultList, parent, false);
                TaskViewHolderRecordVideo vvh = new TaskViewHolderRecordVideo(itemView, OnSpeakClick, OnClick, OnMediaClick);
                return(vvh);

            case TaskAudio:
                itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.TaskCard_ResultList, parent, false);
                TaskViewHolderRecordAudio avh = new TaskViewHolderRecordAudio(itemView, OnSpeakClick, OnClick, OnMediaClick);
                return(avh);

            case Finish:
                itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.TaskCard_Finish, parent, false);
                ButtonViewHolder finishViewHolder = new ButtonViewHolder(itemView, OnClick);
                return(finishViewHolder);

            case Curate:
                itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.CuratorCard, parent, false);
                CuratorViewHolder curateCard = new CuratorViewHolder(itemView, OnCurate);
                return(curateCard);

            case Names:
                itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.TaskCard_Name, parent, false);
                TaskViewHolderName nameCard = new TaskViewHolderName(itemView, OnSpeakClick, OnChangeNameClick);
                return(nameCard);

            default:
                itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.TaskCard, parent, false);
                TaskViewHolder vh = new TaskViewHolder(itemView, null);
                return(vh);
            }
        }