Esempio n. 1
0
        private void Prepare()
        {
            // Check if this is editing an existing task: if so, populate fields
            string editJson = Intent.GetStringExtra("EDIT") ?? "";

            newTask = JsonConvert.DeserializeObject <LearningTask>(editJson);

            if (newTask != null)
            {
                addTaskBtn.SetText(Resource.String.saveChanges);
                AdditionalInfoData addData = JsonConvert.DeserializeObject <AdditionalInfoData>(newTask.JsonData);
                infoField.Text = newTask.Description;
                urlField.Text  = addData.ExternalUrl;
                taskType       = newTask.TaskType;
                editing        = true;

                if (!string.IsNullOrWhiteSpace(addData.ImageUrl))
                {
                    if (addData.ImageUrl.StartsWith("upload"))
                    {
                        string imageUrl = ServerUtils.GetUploadUrl(addData.ImageUrl);
                        ImageService.Instance.LoadUrl(imageUrl)
                        .Transform(new CircleTransformation())
                        .Into(imageView);
                    }
                    else
                    {
                        editCachePath = Path.Combine(
                            Common.LocalData.Storage.GetCacheFolder(null),
                            "editcache-" + DateTime.UtcNow.ToString("MM-dd-yyyy-HH-mm-ss-fff"));
                        File.Copy(addData.ImageUrl, editCachePath, true);
                        Java.IO.File cachedFile = new Java.IO.File(editCachePath);
                        selectedImage = global::Android.Net.Uri.FromFile(cachedFile);
                        ImageService.Instance.LoadFile(selectedImage.Path).Transform(new CircleTransformation()).Into(imageView);
                    }

                    originalPath = addData.ImageUrl;
                }
            }
            else
            {
                // If edit is null, get the tasktype from JSON
                string jsonData = Intent.GetStringExtra("JSON") ?? "";
                taskType = JsonConvert.DeserializeObject <TaskType>(jsonData, new JsonSerializerSettings {
                    TypeNameHandling = TypeNameHandling.Auto
                });
                newTask = new LearningTask
                {
                    TaskType = taskType
                };
            }

            if (selectedImage == null && originalPath == null)
            {
                AndroidUtils.LoadTaskTypeIcon(taskType, imageView);
            }
        }
Esempio n. 2
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            if (!(holder is TaskViewHolderBtn vh))
            {
                return;
            }

            vh.Title.Text       = Data[position].DisplayName;
            vh.Description.Text = Data[position].Description;
            AndroidUtils.LoadTaskTypeIcon(Data[position], vh.TaskTypeIcon);
        }
Esempio n. 3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Check if this is editing an existing task: if so, populate fields
            string editJson = Intent.GetStringExtra("EDIT") ?? "";

            newTask = JsonConvert.DeserializeObject <LearningTask>(editJson);

            // otherwise, we'll use basic tasktype info
            string jsonData = Intent.GetStringExtra("JSON") ?? "";

            taskType = JsonConvert.DeserializeObject <TaskType>(jsonData, new JsonSerializerSettings {
                TypeNameHandling = TypeNameHandling.Auto
            });

            if ((taskType != null && taskType.IdName == "SCAN_QR") ||
                (newTask != null && newTask.TaskType.IdName == "SCAN_QR"))
            {
                SetContentView(Resource.Layout.CreateTaskScanQR);
            }
            else
            {
                SetContentView(Resource.Layout.CreateTask);
            }

            TextView       taskTypeName = FindViewById <TextView>(Resource.Id.taskTypeNameText);
            ImageViewAsync image        = FindViewById <ImageViewAsync>(Resource.Id.taskIcon);
            Button         addTaskBtn   = FindViewById <Button>(Resource.Id.addTaskBtn);

            addTaskBtn.Click += AddTaskBtn_Click;
            instructions      = FindViewById <EditText>(Resource.Id.taskInstructions);

            if (newTask != null)
            {
                instructions.Text = newTask.Description;
                taskType          = newTask.TaskType;
                editing           = true;
                addTaskBtn.SetText(Resource.String.saveChanges);
            }
            else
            {
                // If edit is null just use the tasktype JSON
                taskType = JsonConvert.DeserializeObject <TaskType>(jsonData, new JsonSerializerSettings {
                    TypeNameHandling = TypeNameHandling.Auto
                });
                newTask          = new LearningTask();
                newTask.TaskType = taskType;
            }

            taskTypeName.Text = taskType.DisplayName;
            AndroidUtils.LoadTaskTypeIcon(taskType, image);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.CreateTaskMultipleChoice);
            newEntryText       = FindViewById <EditText>(Resource.Id.newOptionText);
            choicesRoot        = FindViewById <LinearLayout>(Resource.Id.multiChoiceRoot);
            optionsHeader      = FindViewById <TextView>(Resource.Id.createdChoicesHeader);
            optionsHeader.Text = Resources.GetString(Resource.String.createNewMultChoiceNone);
            FindViewById <Button>(Resource.Id.addOptionBtn).Click += CreateTaskMultipleChoice_Click;
            Button addTaskBtn = FindViewById <Button>(Resource.Id.addTaskBtn);

            addTaskBtn.Click += AddTaskBtn_Click;
            instructions      = FindViewById <EditText>(Resource.Id.taskInstructions);

            rand    = new Random();
            entries = new List <string>();

            // Check if this is editing an existing task: if so, populate fields
            string editJson = Intent.GetStringExtra("EDIT") ?? "";

            newTask = JsonConvert.DeserializeObject <LearningTask>(editJson);

            if (newTask != null)
            {
                addTaskBtn.SetText(Resource.String.saveChanges);

                editing           = true;
                taskType          = newTask.TaskType;
                instructions.Text = newTask.Description;
                List <string> existingEntries = JsonConvert.DeserializeObject <List <string> >(newTask.JsonData);

                foreach (string entry in existingEntries)
                {
                    AddChoice(entry);
                }
            }
            else
            {
                string jsonData = Intent.GetStringExtra("JSON") ?? "";
                taskType = JsonConvert.DeserializeObject <TaskType>(jsonData, new JsonSerializerSettings {
                    TypeNameHandling = TypeNameHandling.Auto
                });
            }

            FindViewById <TextView>(Resource.Id.taskTypeNameText).Text = taskType.DisplayName;
            ImageViewAsync image = FindViewById <ImageViewAsync>(Resource.Id.taskIcon);

            AndroidUtils.LoadTaskTypeIcon(taskType, image);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.CreateTaskLocationMarker);
            instructions        = FindViewById <EditText>(Resource.Id.taskInstructions);
            userLocOnlyCheckbox = FindViewById <CheckBox>(Resource.Id.checkboxUserLoc);
            minNumText          = FindViewById <EditText>(Resource.Id.minNumMarkers);
            maxNumText          = FindViewById <EditText>(Resource.Id.maxNumMarkers);
            Button addTaskBtn = FindViewById <Button>(Resource.Id.addTaskBtn);

            addTaskBtn.Click += AddTaskBtn_Click;
            minNumText.Text   = "1";
            maxNumText.Text   = "0";

            // Check if this is editing an existing task: if so, populate fields
            string editJson = Intent.GetStringExtra("EDIT") ?? "";

            newTask = JsonConvert.DeserializeObject <LearningTask>(editJson);

            if (newTask != null)
            {
                editing           = true;
                taskType          = newTask.TaskType;
                instructions.Text = newTask.Description;
                addTaskBtn.SetText(Resource.String.saveChanges);

                MapMarkerTaskData data = JsonConvert.DeserializeObject <MapMarkerTaskData>(newTask.JsonData);
                minNumText.Text             = data.MinNumMarkers.ToString();
                maxNumText.Text             = data.MaxNumMarkers.ToString();
                userLocOnlyCheckbox.Checked = data.UserLocationOnly;
            }
            else
            {
                string jsonData = Intent.GetStringExtra("JSON") ?? "";
                taskType = JsonConvert.DeserializeObject <TaskType>(jsonData, new JsonSerializerSettings {
                    TypeNameHandling = TypeNameHandling.Auto
                });
            }

            FindViewById <TextView>(Resource.Id.taskTypeNameText).Text = taskType.DisplayName;
            ImageViewAsync image = FindViewById <ImageViewAsync>(Resource.Id.taskIcon);

            AndroidUtils.LoadTaskTypeIcon(taskType, image);
        }
Esempio n. 6
0
        private void Prepare()
        {
            // Check if this is editing an existing task: if so, populate fields
            string editJson = Intent.GetStringExtra("EDIT") ?? "";

            newTask = JsonConvert.DeserializeObject <LearningTask>(editJson);

            if (newTask != null)
            {
                editing           = true;
                taskType          = newTask.TaskType;
                instructions.Text = newTask.Description;
                addTaskBtn.SetText(Resource.String.saveChanges);
                fileTextView.SetText(Resource.String.createNewListenChosen);
                editCachePath = Path.Combine(
                    Common.LocalData.Storage.GetCacheFolder(null),
                    "editcache-" + DateTime.Now.ToString("MM-dd-yyyy-HH-mm-ss-fff"));

                if (!newTask.JsonData.StartsWith("upload"))
                {
                    File.Copy(newTask.JsonData, editCachePath, true);
                    Java.IO.File cachedFile = new Java.IO.File(editCachePath);
                    outputFileUri = global::Android.Net.Uri.FromFile(cachedFile);
                }
                else
                {
                    outputFileUri = global::Android.Net.Uri.Parse(newTask.JsonData);
                }

                AudioLoaded();
            }
            else
            {
                string jsonData = Intent.GetStringExtra("JSON") ?? "";
                taskType = JsonConvert.DeserializeObject <TaskType>(jsonData, new JsonSerializerSettings {
                    TypeNameHandling = TypeNameHandling.Auto
                });
            }

            FindViewById <TextView>(Resource.Id.taskTypeNameText).Text = taskType.DisplayName;
            ImageViewAsync image = FindViewById <ImageViewAsync>(Resource.Id.taskIcon);

            AndroidUtils.LoadTaskTypeIcon(taskType, image);
        }
        private void Prepare()
        {
            LearningTask passedTask = JsonConvert.DeserializeObject <LearningTask>(Intent.GetStringExtra("PARENT") ?? "");

            if (passedTask?.TaskType != null)
            {
                isChild = true;
                string[] supportedParents = { "TAKE_PHOTO", "MATCH_PHOTO", "DRAW", "DRAW_PHOTO" };

                if (supportedParents.Contains(passedTask.TaskType.IdName))
                {
                    // We can use the parent task as an image source
                    parentTask = passedTask;

                    Button useParentBtn = FindViewById <Button>(Resource.Id.useParentBtn);
                    useParentBtn.Visibility = global::Android.Views.ViewStates.Visible;
                    useParentBtn.Click     += UseParentBtn_Click;
                    useParentBtn.Text       = string.Format(GetString(
                                                                Resource.String.createNewDrawPhotoChooseParent), passedTask.Description);
                }
            }

            // Check if this is editing an existing task: if so, populate fields
            string editJson = Intent.GetStringExtra("EDIT") ?? "";

            newTask = JsonConvert.DeserializeObject <LearningTask>(editJson);

            if (newTask != null)
            {
                addTaskBtn.SetText(Resource.String.saveChanges);
                LoadExisting();
            }
            else
            {
                string jsonData = Intent.GetStringExtra("JSON") ?? "";
                taskType = JsonConvert.DeserializeObject <TaskType>(jsonData, new JsonSerializerSettings {
                    TypeNameHandling = TypeNameHandling.Auto
                });
            }

            FindViewById <TextView>(Resource.Id.taskTypeNameText).Text = taskType.DisplayName;
            AndroidUtils.LoadTaskTypeIcon(taskType, image);
        }
        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);
        }
Esempio n. 9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.CreateTaskLocationHunt);
            instructions = FindViewById <EditText>(Resource.Id.taskInstructions);
            scrollView   = FindViewById <ScrollView>(Resource.Id.scrollView);
            Button addTaskBtn = FindViewById <Button>(Resource.Id.addTaskBtn);

            addTaskBtn.Click += AddTaskBtn_Click;

            // Check if this is editing an existing task: if so, populate fields
            string editJson = Intent.GetStringExtra("EDIT") ?? "";

            newTask = JsonConvert.DeserializeObject <LearningTask>(editJson);

            if (newTask != null)
            {
                editing           = true;
                taskType          = newTask.TaskType;
                instructions.Text = newTask.Description;
                Selected          = JsonConvert.DeserializeObject <LocationHuntLocation>(newTask.JsonData);
                addTaskBtn.SetText(Resource.String.saveChanges);
            }
            else
            {
                string jsonData = Intent.GetStringExtra("JSON") ?? "";
                taskType = JsonConvert.DeserializeObject <TaskType>(jsonData, new JsonSerializerSettings {
                    TypeNameHandling = TypeNameHandling.Auto
                });
            }

            FindViewById <TextView>(Resource.Id.taskTypeNameText).Text = taskType.DisplayName;
            ImageViewAsync image = FindViewById <ImageViewAsync>(Resource.Id.taskIcon);

            AndroidUtils.LoadTaskTypeIcon(taskType, image);

            TouchableMapFragment mapFrag = (TouchableMapFragment)FragmentManager.FindFragmentById(Resource.Id.map);

            mapFrag.TouchUp   += (sender, args) => scrollView.RequestDisallowInterceptTouchEvent(false);
            mapFrag.TouchDown += (sender, args) => scrollView.RequestDisallowInterceptTouchEvent(true);
            mapFrag.GetMapAsync(this);
        }
Esempio n. 10
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);
        }
Esempio n. 11
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            TaskViewHolder vh;

            Type thisType = holder.GetType();

            OnBind = true;

            if (Curator)
            {
                if (position == 0)
                {
                    return;
                }
            }

            if (position == 0 || (Curator && position == 1))
            {
                // Activity description + entered names (if required)
                vh = holder as TaskViewHolderName;
                if (vh == null)
                {
                    return;
                }

                vh.Title.Text       = description;
                vh.Description.Text = context.Resources.GetString(Resource.String.TasksTitle);

                ((TaskViewHolderName)vh).NameSection.Visibility =
                    (reqName) ? ViewStates.Visible : ViewStates.Gone;
                ((TaskViewHolderName)vh).EnteredNames.Text = names;

                return;
            }

            if (position == Items.Count - 1)
            {
                // Finish button
                if (holder is ButtonViewHolder bvh)
                {
                    bvh.Button.Enabled = true;
                }

                return;
            }

            string taskType = Items[position].TaskType.IdName;

            if (thisType == typeof(TaskViewHolderInfo))
            {
                AdditionalInfoData taskInfo = JsonConvert.DeserializeObject <AdditionalInfoData>(Items[position].JsonData);
                vh = holder as TaskViewHolderInfo;
                Items[position].IsCompleted = true;

                if (!string.IsNullOrWhiteSpace(taskInfo.ImageUrl))
                {
                    Items[position].ImageUrl = taskInfo.ImageUrl;
                }

                TaskViewHolderInfo taskViewHolderInfo = (TaskViewHolderInfo)vh;
                if (taskViewHolderInfo != null)
                {
                    taskViewHolderInfo.Button.Visibility =
                        (string.IsNullOrWhiteSpace(taskInfo.ExternalUrl)) ? ViewStates.Gone : ViewStates.Visible;
                }
            }
            else if (thisType == typeof(TaskViewHolderRecordAudio))
            {
                vh = holder as TaskViewHolderRecordAudio;
                if (vh != null)
                {
                    ((TaskViewHolderRecordAudio)vh).StartTaskButton.Text =
                        context.Resources.GetString(Resource.String.StartBtn);

                    if (!string.IsNullOrWhiteSpace(Items[position].CompletionData.JsonData))
                    {
                        List <string> audioPaths =
                            JsonConvert.DeserializeObject <List <string> >(Items[position].CompletionData.JsonData);

                        ((TaskViewHolderRecordAudio)vh).ShowResults(audioPaths, context);
                        Items[position].IsCompleted = true;
                    }
                    else
                    {
                        Items[position].IsCompleted = false;
                        ((TaskViewHolderRecordAudio)vh).ClearResults();
                    }
                }
            }
            else if (thisType == typeof(TaskViewHolderRecordVideo))
            {
                vh = holder as TaskViewHolderRecordVideo;
                if (vh != null)
                {
                    ((TaskViewHolderRecordVideo)vh).StartTaskButton.Text =
                        context.Resources.GetString(Resource.String.RecBtn);

                    if (!string.IsNullOrWhiteSpace(Items[position].CompletionData.JsonData))
                    {
                        List <string> videoPaths =
                            JsonConvert.DeserializeObject <List <string> >(Items[position].CompletionData.JsonData);

                        ((TaskViewHolderRecordVideo)vh).ShowResults(videoPaths, context);
                        Items[position].IsCompleted = true;
                    }
                    else
                    {
                        Items[position].IsCompleted = false;
                        ((TaskViewHolderRecordVideo)vh).ClearResults();
                    }
                }
            }
            else if (thisType == typeof(TaskViewHolderResultList))
            {
                vh = holder as TaskViewHolderResultList;

                bool   btnEnabled = true;
                string btnText;

                if (taskType == "DRAW" || taskType == "DRAW_PHOTO")
                {
                    btnText = context.Resources.GetString(Resource.String.StartDrawBtn);

                    if (taskType == "DRAW_PHOTO")
                    {
                        btnEnabled = !int.TryParse(Items[position].JsonData, out var idResult) || GetTaskWithId(idResult).IsCompleted;

                        if (!btnEnabled)
                        {
                            btnText = context.Resources.GetString(Resource.String.TaskBtnNotReady);
                        }
                    }
                }
                else
                {
                    btnText = context.Resources.GetString(Resource.String.TakePhotoBtn);
                }

                if (vh != null)
                {
                    ((TaskViewHolderResultList)vh).StartTaskButton.Text    = btnText;
                    ((TaskViewHolderResultList)vh).StartTaskButton.Enabled = btnEnabled;

                    if (!string.IsNullOrWhiteSpace(Items[position].CompletionData.JsonData))
                    {
                        List <string> photoPaths =
                            JsonConvert.DeserializeObject <List <string> >(Items[position].CompletionData.JsonData);

                        ((TaskViewHolderResultList)vh).ShowResults(photoPaths, context);
                        Items[position].IsCompleted = true;
                    }
                    else
                    {
                        Items[position].IsCompleted = false;
                        ((TaskViewHolderResultList)vh).ClearResults();
                    }
                }
            }
            else if (thisType == typeof(TaskViewHolderBtn))
            {
                vh = holder as TaskViewHolderBtn;
                string btnText = context.Resources.GetString(Resource.String.TaskBtn);

                if (taskType == "LISTEN_AUDIO")
                {
                    btnText = context.Resources.GetString(Resource.String.ListenBtn);
                }

                TaskViewHolderBtn viewHolderBtn = (TaskViewHolderBtn)vh;
                if (viewHolderBtn != null)
                {
                    viewHolderBtn.Button.Text = btnText;
                }
            }
            else if (thisType == typeof(TaskViewHolderTextEntry))
            {
                vh = holder as TaskViewHolderTextEntry;
                if (vh != null)
                {
                    ((TaskViewHolderTextEntry)vh).TextField.Text = Items[position].CompletionData.JsonData;
                    Items[position].IsCompleted =
                        !string.IsNullOrWhiteSpace(((TaskViewHolderTextEntry)vh).TextField.Text);
                }
            }
            else
            {
                if (thisType == typeof(TaskViewHolderMultipleChoice))
                {
                    vh = holder as TaskViewHolderMultipleChoice;
                    RadioGroup radios = ((TaskViewHolderMultipleChoice)vh)?.RadioGroup;

                    string[] choices = JsonConvert.DeserializeObject <string[]>(Items[position].JsonData);
                    int.TryParse(Items[position].CompletionData.JsonData, out var answeredInd);

                    if (radios != null && radios.ChildCount == 0)
                    {
                        int index = 0;
                        foreach (string option in choices)
                        {
                            RadioButton rad = new RadioButton(context)
                            {
                                Text = option
                            };
                            rad.SetPadding(0, 0, 0, 5);
                            rad.TextSize = 16;
                            radios.AddView(rad);

                            if (Items[position].IsCompleted && answeredInd == index)
                            {
                                ((RadioButton)radios.GetChildAt(answeredInd)).Checked = true;
                            }
                            index++;
                        }
                    }

                    if (answeredInd == -1)
                    {
                        Items[position].IsCompleted = false;
                    }

                    if (radios != null)
                    {
                        radios.CheckedChange += (sender, e) =>
                        {
                            Items[position].IsCompleted = true;
                            int  radioButtonId = radios.CheckedRadioButtonId;
                            View radioButton   = radios.FindViewById(radioButtonId);
                            int  idx           = radios.IndexOfChild(radioButton);
                            Items[position].CompletionData.JsonData = idx.ToString();
                            NotifyItemChanged(Items.Count - 1);
                        };
                    }
                }
                else if (thisType == typeof(TaskViewHolderMap))
                {
                    vh = holder as TaskViewHolderMap;
                    TaskViewHolderMap mapHolder = ((TaskViewHolderMap)vh);

                    if (taskType == "MAP_MARK")
                    {
                        List <Map_Location> points = JsonConvert.DeserializeObject <List <Map_Location> >(Items[position].CompletionData.JsonData);

                        if (points != null && points.Count > 0)
                        {
                            if (mapHolder != null)
                            {
                                mapHolder.EnteredLocationsView.Visibility = ViewStates.Visible;
                                mapHolder.EnteredLocationsView.Text       = string.Format(
                                    context.Resources.GetString(Resource.String.ChosenLocations),
                                    points.Count,
                                    (points.Count > 1) ? "s" : "");
                            }

                            Items[position].IsCompleted = true;
                        }
                        else
                        {
                            if (mapHolder != null)
                            {
                                mapHolder.EnteredLocationsView.Visibility = ViewStates.Gone;
                            }

                            Items[position].IsCompleted = false;
                        }
                    }
                }
                else
                {
                    vh = holder as TaskViewHolder;
                }
            }

            // These apply to all task types:
            AndroidUtils.LoadTaskTypeIcon(Items[position].TaskType, ((TaskViewHolder)holder).TaskTypeIcon);

            if (!string.IsNullOrWhiteSpace(Items[position].ImageUrl))
            {
                AndroidUtils.LoadActivityImageIntoView(vh.TaskImage, Items[position].ImageUrl, activityId, 350);
            }
            else
            {
                if (vh != null)
                {
                    vh.TaskImage.Visibility = ViewStates.Gone;
                }
            }

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

            bool hasChildren = Items[position].ChildTasks != null && Items[position].ChildTasks.Any();

            if (Items[position].TaskType.IdName == "ENTER_TEXT")
            {
                vh.LockedChildrenTease.Visibility = ViewStates.Gone;
            }
            else if (hasChildren && !Items[position].IsCompleted)
            {
                vh.LockedChildrenTease.Visibility = ViewStates.Visible;
                int childCount = Items[position].ChildTasks.Count();
                vh.LockedChildrenTease.Text = string.Format(
                    context.GetString(Resource.String.taskLockedParent),
                    childCount,
                    (childCount > 1) ? "s" : "");
            }
            else if (hasChildren && Items[position].IsCompleted)
            {
                vh.LockedChildrenTease.Visibility = ViewStates.Visible;
                vh.LockedChildrenTease.Text       = context.GetString(Resource.String.taskUnlockedParent);
            }
            else
            {
                vh.LockedChildrenTease.Visibility = ViewStates.Gone;
            }

            OnBind = false;
        }