Exemple #1
0
        private void ShowAlert(object sender, PopupMenu.MenuItemClickEventArgs e)
        {
            switch (e.Item.ItemId)
            {
            case (Resource.Id.action_add_fav_query):
                ShowAddToFavAlert((name) =>
                {
                    string key  = ApplicationContext.GetString(Resource.String.fav_query_storage_key);
                    var storage = new FavoritesStorage <FavoriteQuery>(ApplicationContext, key);
                    storage.AddItem(new FavoriteQuery()
                    {
                        Id = storage.GetUniqueId(), Name = name, Query = searchTextView.Text
                    });

                    AWidget.Toast.MakeText(this, GetString(Resource.String.saved),
                                           AWidget.ToastLength.Short).Show();
                });
                break;

            case (Resource.Id.action_add_fav_place):
                ShowAddToFavAlert((name) =>
                {
                    string key  = ApplicationContext.GetString(Resource.String.fav_places_storage_key);
                    var storage = new FavoritesStorage <FavoritePlace>(ApplicationContext, key);
                    storage.AddItem(new FavoritePlace()
                    {
                        Id = storage.GetUniqueId(), Name = name, Place = nearestPlace
                    });

                    AWidget.Toast.MakeText(this, GetString(Resource.String.saved),
                                           AWidget.ToastLength.Short).Show();
                });
                break;
            }
        }