public override global::Android.Views.View GetView(int position, global::Android.Views.View convertView
                                                               , ViewGroup parent)
            {
                if (convertView == null)
                {
                    LayoutInflater inflater = (LayoutInflater)parent.GetContext().GetSystemService(Context
                                                                                                   .LayoutInflaterService);
                    convertView = inflater.Inflate(R.Layout.view_user, null);
                }
                Couchbase.Lite.Document task = (Couchbase.Lite.Document) this.GetItem(position);
                TextView text = (TextView)convertView.FindViewById(R.ID.text);

                text.SetText((string)task.GetProperty("name"));
                Couchbase.Lite.Document user = (Couchbase.Lite.Document) this.GetItem(position);
                CheckBox checkBox            = (CheckBox)convertView.FindViewById(R.ID.@checked);
                bool     @checked            = this.IsMemberOfTheCurrentList(user);

                checkBox.SetChecked(@checked);
                checkBox.SetOnClickListener(new _OnClickListener_118(this, checkBox, user));
                return(convertView);
            }
Exemple #2
0
                public override global::Android.Views.View GetView(int position, global::Android.Views.View convertView
                                                                   , ViewGroup parent)
                {
                    if (convertView == null)
                    {
                        LayoutInflater inflater = (LayoutInflater)parent.GetContext().GetSystemService(Context
                                                                                                       .LayoutInflaterService);
                        convertView = inflater.Inflate(Resource.Layout.view_task, null);
                    }
                    Couchbase.Lite.Document task   = (Couchbase.Lite.Document) this.GetItem(position);
                    Bitmap             image       = null;
                    Bitmap             thumbnail   = null;
                    IList <Attachment> attachments = task.GetCurrentRevision().GetAttachments();

                    if (attachments != null && attachments.Count > 0)
                    {
                        Attachment attachment = attachments[0];
                        try
                        {
                            image     = BitmapFactory.DecodeStream(attachment.GetContent());
                            thumbnail = ThumbnailUtils.ExtractThumbnail(image, MainActivity.TasksFragment.ThumbnailSizePx
                                                                        , MainActivity.TasksFragment.ThumbnailSizePx);
                        }
                        catch (Exception e)
                        {
                            Log.E(Application.Tag, "Cannot decode the attached image", e);
                        }
                    }
                    Bitmap    displayImage = image;
                    ImageView imageView    = (ImageView)convertView.FindViewById(Resource.Id.image);

                    if (thumbnail != null)
                    {
                        imageView.SetImageBitmap(thumbnail);
                    }
                    else
                    {
                        imageView.SetImageDrawable(this._enclosing.GetResources().GetDrawable(Resource.Drawable.
                                                                                              ic_camera_light));
                    }
                    imageView.Click += async(sender, e) => {
                        if (displayImage != null)
                        {
                            DispatchImageViewIntent(displayImage);
                        }
                        else
                        {
                            AttachImage(task);
                        }
                    };
                    TextView text = (TextView)convertView.FindViewById(Resource.Id.text);

                    text.SetText((string)task.GetProperty("title"));
                    CheckBox checkBox        = (CheckBox)convertView.FindViewById(Resource.Id.@checked);
                    bool     checkedProperty = (bool)task.GetProperty("checked");
                    bool     @checked        = checkedProperty != null ? checkedProperty : false;

                    checkBox.SetChecked(@checked);
                    checkBox.Click += async(sender, e) => {
                        try
                        {
                            Task.UpdateCheckedStatus(task, checkBox.IsChecked());
                        }
                        catch (CouchbaseLiteException ex)
                        {
                            Log.E(((CouchbaseSample.Android.Application)Application).Tag, "Cannot update checked status", e);
                        }
                    };
                    return(convertView);
                }