Ejemplo n.º 1
0
        void DeleteList(GroceryListClass inputList, AdapterView.ItemLongClickEventArgs e)
        {
            e.View.Animate()
            .SetDuration(750)
            .Alpha(0)
            .WithEndAction(new Runnable(() =>
            {
                //local list delete
                AppData.currentLists.Remove(inputList);

                if (inputList.Owner.Uid == AppData.currentUser.Uid)
                {
                    //deleting list from cloud
                    DeleteListFromCloud.Delete(inputList);
                    ReadWrite.WriteData();
                }
                else    // if its not the current users list
                {
                    InvitationClass thisInvite = new InvitationClass()
                    {
                        Name  = inputList.Name,
                        Owner = inputList.Owner
                    };
                    RemoveInvitation.Remove(thisInvite);
                }

                groceryAdapter.NotifyDataSetChanged();

                e.View.Alpha = 1;
            }));
        }
Ejemplo n.º 2
0
        void NewListSave(string inputListName)
        {
            GroceryListClass newList = new GroceryListClass
            {
                Name  = inputListName,
                Items = new List <ItemClass>(),
                Owner = AppData.currentUser
            };

            AppData.currentLists.Add(newList);
            ReadWrite.WriteData();         //write offline

            SaveListOnCloud.Save(newList); //save online

            groceryAdapter.NotifyDataSetChanged();
        }
Ejemplo n.º 3
0
        private void DeleteListAlert(object sender, AdapterView.ItemLongClickEventArgs e)
        {
            GroceryListClass toDeleteList = AppData.currentLists[e.Position];

            AlertDialog.Builder alert = new AlertDialog.Builder(this);

            if (toDeleteList.Owner.Uid == AppData.currentUser.Uid)
            {
                alert.SetTitle("Confirm Delete");
                alert.SetMessage("Are you sure you want to delete the list " + toDeleteList.Name + "?");
            }
            else
            {
                alert.SetTitle("Remove Invitation");
                alert.SetMessage("Are you sure you want to remove this invitation from " + toDeleteList.Owner.Name + "?");
            }

            alert.SetPositiveButton("Delete", (senderAlert, eAlert) => DeleteList(toDeleteList, e));
            alert.SetNegativeButton("Cancel", (senderAlert, eAlert) => { });
            Dialog dialog = alert.Create();

            dialog.Show();
        }