//void FetchAndListenExpensesTable() //{ // CollectionReference monthyearRef = database.Collection("ExpenseTable"); // Query query = monthyearRef.WhereEqualTo("DateYear", YearSelected).WhereEqualTo("DateMonth", MonthSelected).WhereEqualTo("UserUid", CurrentUserUid).OrderBy("DateDay", Query.Direction.Descending); // query.Get().AddOnSuccessListener(this).AddOnFailureListener(this); //} public void OnEvent(Java.Lang.Object obj, FirebaseFirestoreException error) { TotalExpenseValue = new List <string>(); var snapshot = (QuerySnapshot)obj; parentObjects = new List <IParentObject>(); GlobalchildList = new List <object>(); if (!snapshot.IsEmpty) { var documents = snapshot.Documents; foreach (DocumentSnapshot docitem in documents) { TotalExpenseValue.Add(docitem.Get("Amount").ToString()); expenseitem = new ExpenseItemParent(); var childList = new List <Object>(); childList.Add(new ExpenseItemChild(docitem.Get("Description").ToString(), docitem.Id.ToString(), docitem.Get("Date").ToString(), docitem.Get("ItemName").ToString(), docitem.Get("Amount").ToString())); // GlobalchildList.Add(childList); expenseitem = new ExpenseItemParent() { ExpenseItem = docitem.Get("ItemName").ToString(), ExpenseItemAmount = docitem.Get("Amount").ToString() }; expenseitem.ChildObjectList = childList; GlobalchildList.Add(expenseitem.ChildObjectList[0]); parentObjects.Add(expenseitem); } // GlobalchildList = expenseitem.ChildObjectList; SetupVerticalRecyclerView(); //if(expenseadapter!=null) //{ // expenseadapter.NotifyDataSetChanged(); //} } }
public bool OnQueryTextSubmit(string newText) { //Toast.MakeText(this, "submitt", ToastLength.Long).Show(); childListsearch = GlobalchildList.ConvertAll(x => (ExpenseItemChild)x); childListsearch = (from expense in childListsearch where expense.ExpenseItemName.ToLower().Contains(newText.ToLower()) || expense.ExpenseItemDescription.ToLower().Contains(newText.ToLower()) select expense).ToList(); parentObjects = new List <IParentObject>(); foreach (var searchitem in childListsearch) { // TotalExpenseValue.Add(docitem.Get("Amount").ToString()); var childList = new List <Object>(); childList.Add(new ExpenseItemChild(searchitem.ExpenseItemDescription, searchitem.ExpenseId, searchitem.ExpenseItemDate, searchitem.ExpenseItemName, searchitem.ExpenseItemAmount)); expenseitem = new ExpenseItemParent() { ExpenseItem = searchitem.ExpenseItemName, ExpenseItemAmount = searchitem.ExpenseItemAmount }; expenseitem.ChildObjectList = childList; parentObjects.Add(expenseitem); } SetupVerticalRecyclerView(); return(true); }
public bool OnQueryTextChange(string newText) { //Toast.MakeText(this, "text changed", ToastLength.Long).Show(); if (!string.IsNullOrWhiteSpace(newText)) { childListsearch = GlobalchildList.ConvertAll(x => (ExpenseItemChild)x); childListsearch = (from expense in childListsearch where expense.ExpenseItemName.ToLower().Contains(newText.ToLower()) || expense.ExpenseItemDescription.ToLower().Contains(newText.ToLower()) select expense).ToList(); //childListsearch = (from expense in childListsearch // where ((expense.ExpenseItemName.ToLower().Contains(newText.ToLower())) || // (expense.ExpenseItemDescription.ToLower().Contains(newText.ToLower()))) // select expense).ToList(); parentObjects = new List <IParentObject>(); foreach (var searchitem in childListsearch) { // TotalExpenseValue.Add(docitem.Get("Amount").ToString()); var childList = new List <Object>(); childList.Add(new ExpenseItemChild(searchitem.ExpenseItemDescription, searchitem.ExpenseId, searchitem.ExpenseItemDate, searchitem.ExpenseItemName, searchitem.ExpenseItemAmount)); expenseitem = new ExpenseItemParent() { ExpenseItem = searchitem.ExpenseItemName, ExpenseItemAmount = searchitem.ExpenseItemAmount }; expenseitem.ChildObjectList = childList; parentObjects.Add(expenseitem); } SetupVerticalRecyclerView(); } else { FetchExpensesTableForMonthYear(); } return(true); }
//public void OnFailure(Java.Lang.Object result) //{ //} public void OnSuccess(Java.Lang.Object result) { TotalExpenseValue = new List <string>(); var snapshot = (QuerySnapshot)result; parentObjects = new List <IParentObject>(); GlobalchildList = new List <object>(); if (!snapshot.IsEmpty) { var documents = snapshot.Documents; foreach (DocumentSnapshot docitem in documents) { TotalExpenseValue.Add(docitem.Get("Amount").ToString()); expenseitem = new ExpenseItemParent(); var childList = new List <Object>(); childList.Add(new ExpenseItemChild(docitem.Get("Description").ToString(), docitem.Id.ToString(), docitem.Get("Date").ToString(), docitem.Get("ItemName").ToString(), docitem.Get("Amount").ToString())); expenseitem = new ExpenseItemParent() { ExpenseItem = docitem.Get("ItemName").ToString(), ExpenseItemAmount = docitem.Get("Amount").ToString() }; expenseitem.ChildObjectList = childList; GlobalchildList.Add(expenseitem.ChildObjectList[0]); parentObjects.Add(expenseitem); } nodataicon.Visibility = ViewStates.Invisible; SetupVerticalRecyclerView(); //if(expenseadapter!=null) //{ // expenseadapter.NotifyDataSetChanged(); //} } else { nodataicon.Visibility = ViewStates.Visible; parentObjects = new List <IParentObject>(); SetupVerticalRecyclerView(); } }