Exemplo n.º 1
0
        void AddNewItem(object sender, TextView.EditorActionEventArgs e)
        {
            if (e.ActionId != ImeAction.Done)
            {
                return;
            }

            ItemClass newItem = new ItemClass()
            {
                Name      = newItemEditText.Text,
                Purchased = false.ToString(),
                Time      = DateTime.UtcNow.ToString()
            };

            curList.Items.Add(newItem);
            //save item locally
            ReadWrite.WriteData();

            //save item online
            SaveItemOnCloud.Save(newItem, curList);


            itemsAdapter.NotifyDataSetChanged();

            newItemEditText.Text = "";
            newItemEditText.Hint = "+ New Item";

            //FindFocus basically gets the previous focus and uses that after inputing a new item and removing the keyboard
            this.CurrentFocus.FindFocus();
            InputMethodManager inputManager = (InputMethodManager)GetSystemService(Context.InputMethodService);

            inputManager.HideSoftInputFromWindow(this.CurrentFocus.WindowToken, HideSoftInputFlags.None);
        }
Exemplo n.º 2
0
        void ItemClicked(object sender, AdapterView.ItemClickEventArgs e)
        {
            ItemClass thisItem = curList.Items[e.Position];

            bool status = false;

            if (thisItem.Purchased == "True")
            {
                status = true;
            }

            thisItem.Purchased = (!status).ToString();
            thisItem.Time      = DateTime.UtcNow.ToString();

            itemsAdapter.NotifyDataSetChanged();

            //clicked for locally
            ReadWrite.WriteData();
            //for cloud
            SaveItemOnCloud.Save(thisItem, curList);
        }