private int GetCurrentSelectedPosition(QueryEnumerator enumerator) { if (enumerator == null) { return(-1); } var application = (Application)Activity.Application; string currentListId = application.GetCurrentListId(); if (currentListId == null) { return(enumerator.Count() > 0 ? 0 : -1); } int position = 0; foreach (var row in enumerator) { if (currentListId.Equals(row.Document.Id)) { break; } ++position; } return(position); }
private string GetCurrentListId() { var application = (CouchbaseSample.Android.Application)Application; string currentListId = application.GetCurrentListId(); if (currentListId == null) { try { QueryEnumerator enumerator = List.GetQuery(GetDatabase()).Run(); if (enumerator.Count() > 0) { currentListId = enumerator.GetRow(0).Document.Id; } } catch (CouchbaseLiteException) { } } return(currentListId); }
private int GetCurrentSelectedPosition(QueryEnumerator enumerator) { if (enumerator == null) { return -1; } var application = (Application)Activity.Application; string currentListId = application.GetCurrentListId(); if (currentListId == null) { return enumerator.Count() > 0 ? 0 : -1; } int position = 0; foreach(var row in enumerator) { if (currentListId.Equals(row.Document.Id)) { break; } ++position; } return position; }