private void DisplayListContent(string listDocId) { Couchbase.Lite.Document document = GetDatabase().GetDocument(listDocId); ActionBar.Subtitle = (string)document.GetProperty("title"); FragmentManager fragmentManager = FragmentManager; fragmentManager.BeginTransaction().Replace(Resource.Id.container, MainActivity.TasksFragment .NewInstance(listDocId)).Commit(); Application application = (CouchbaseSample.Android.Application)Application; application.SetCurrentListId(listDocId); }
public void OnItemClick <_T0>(AdapterView <_T0> adapter, global::Android.Views.View view, int position, long id) where _T0 : Adapter { Couchbase.Lite.Document task = (Couchbase.Lite.Document)adapter.GetItemAtPosition (position); bool @checked = ((bool)task.GetProperty("checked")); try { Task.UpdateCheckedStatus(task, @checked); } catch (CouchbaseLiteException e) { Log.E(Application.Tag, "Cannot update checked status", e); Sharpen.Runtime.PrintStackTrace(e); } }
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); }
/// <exception cref="Couchbase.Lite.CouchbaseLiteException"></exception> public static void AssignOwnerToListsIfNeeded(Database database, Couchbase.Lite.Document user) { QueryEnumerator enumerator = GetQuery(database).Run(); if (enumerator == null) { return; } foreach (var row in enumerator) { Couchbase.Lite.Document document = row.Document; string owner = (string)document.GetProperty("owner"); if (owner != null) { continue; } IDictionary <string, object> properties = new Dictionary <string, object>(); properties.PutAll(document.Properties); properties.Put("owner", user.Id); document.PutProperties(properties); } }
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); }