예제 #1
0
        public static async Task Read(ListsActivity thisActivity)
        {
            ReadWrite.ReadUser();

            //for offline user
            if (AppData.currentUser == null)
            {
                AppData.currentUser = new UserClass()
                {
                    Name  = "Me",
                    Email = "defEmail",
                    Uid   = "defUid"
                };

                PrepareFirstList.Prepare();

                ReadWrite.WriteData();
                ReadWrite.WriteUser();
            }
            else
            {
                ReadWrite.ReadData();
                AppData.currentLists = AppData.offlineLists;
            }

            thisActivity.SetProfileButton("Login!", Color.Orange);



            //for online user
            if (AppData.auth.CurrentUser != null)
            {
                thisActivity.SetProfileButton("Online!", Color.Green);

                await ReadDataFromCloud.Read();

                AppData.currentLists = CompareLists.Compare(AppData.onlineLists, AppData.offlineLists);

                ReadWrite.WriteData();
                foreach (GroceryListClass any in AppData.currentLists)
                {
                    SaveListOnCloud.Save(any);
                }

                await ReadInvitations.Read();

                await FetchInvitations.Fetch();

                foreach (GroceryListClass any in AppData.invitationLists)
                {
                    AppData.currentLists.Add(any);
                }
            }
        }
예제 #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();
        }
예제 #3
0
        void SaveNewChat(string inputNewChatName)
        {
            ChatListClass newChat = new ChatListClass
            {
                ChatName  = inputNewChatName,
                ChatOwner = AppData.curUser,
                ChatItems = new List <MessageClass>()
            };

            AppData.currentLST.Add(newChat);

            ReadWriteDisk.WriteData();

            SaveListOnCloud.Save(newChat);

            chatsTableView.ReloadData();
        }