private void MAdapter_ItemClick(object sender, int i)
 {
     //Toast.MakeText(Activity, "This is item number " + (i + 1), ToastLength.Short).Show();
     MainActivity.IsNavDisabled = true;
     Android.App.DialogFragment dialog = MenuItemTypeDialogFragment.NewInstance(menuItemTypes[i].Id);
     dialog.Show(FragmentManager, "fragmentDialog");
 }
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            if (IsActive)
            {
                int id = item.ItemId;

                if (id == Android.Resource.Id.Home)
                {
                    MainActivity.IsNavDisabled = false;
                    Activity.OnBackPressed();
                    return(true);
                }
                else if (id == Resource.Id.book_table)
                {
                    if (GenericFacade.UserName != null && GenericFacade.UserName != "")
                    {
                        MainActivity.IsNavDisabled = true;
                        IsActive = false;
                        Android.App.DialogFragment dialog = BookingNewDialogFragment.NewInstance(restaurant.Id);
                        dialog.Show(FragmentManager, "fragmentDialog");
                    }
                    else
                    {
                        Toast.MakeText(Activity, "Please login before booking a table", ToastLength.Long).Show();
                    }
                }
            }

            return(base.OnOptionsItemSelected(item));
        }
        public void StartDialogFragment(Android.App.DialogFragment fragment, string tag)
        {
            var ft   = FragmentManager.BeginTransaction();
            var prev = FragmentManager.FindFragmentByTag(tag);

            if (prev != null)
            {
                ft.Remove(prev);
            }
            ft.AddToBackStack(null);
            fragment.Show(ft, tag);
        }
        private void Setup()
        {
            if (restaurant != null)
            {
                LinearLayout imageLayout = view.FindViewById <LinearLayout>(Resource.Id.restaurant_view_images);

                if (restaurant.ImageIds.Any())
                {
                    foreach (int imageId in restaurant.ImageIds)
                    {
                        View      imgView = LayoutInflater.From(Activity).Inflate(Resource.Layout.restaurant_view_image, null);
                        ImageView img     = imgView.FindViewById <ImageView>(Resource.Id.restaurant_view_img);
                        Image     dbImg   = _imageFacade.LoadImage(imageId).Result;

                        if (dbImg == null)
                        {
                            img.SetImageResource(Resource.Drawable.nophoto);
                        }
                        else
                        {
                            img.SetImageBitmap(BitmapFactory.DecodeByteArray(dbImg.FileContent, 0, dbImg.FileContent.Length));
                        }

                        imageLayout.AddView(img);
                        View divider = LayoutInflater.From(Activity).Inflate(Resource.Layout.vertical_divider_full, null);
                        imageLayout.AddView(divider);
                    }
                }
                else
                {
                    View      imgView = LayoutInflater.From(Activity).Inflate(Resource.Layout.restaurant_view_image, null);
                    ImageView img     = imgView.FindViewById <ImageView>(Resource.Id.restaurant_view_img);
                    img.SetImageResource(Resource.Drawable.nophoto);

                    imageLayout.AddView(img);
                }

                view.FindViewById <TextView>(Resource.Id.restaurant_view_name).Text    = restaurant.Name;
                view.FindViewById <TextView>(Resource.Id.restaurant_view_phone).Text   = restaurant.PhoneNo;
                view.FindViewById <TextView>(Resource.Id.restaurant_view_address).Text = restaurant.AddressStreet + ", " + restaurant.AddressTown + ", " + restaurant.AddressCounty + ", " + restaurant.AddressPostalCode;

                LinearLayout container = view.FindViewById <LinearLayout>(Resource.Id.restaurant_view_menu_container);

                foreach (var cat in types)
                {
                    View viewCat = LayoutInflater.From(Activity).Inflate(Resource.Layout.restaurant_view_menu, null);
                    LinearLayout.LayoutParams layout = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent)
                    {
                        TopMargin = 16
                    };
                    viewCat.LayoutParameters = layout;
                    viewCat.FindViewById <TextView>(Resource.Id.restaurant_view_menu_type).Text = cat.Name;

                    container.AddView(viewCat);

                    viewCat.Click += delegate
                    {
                        MainActivity.IsNavDisabled = true;
                        IsActive = false;
                        Android.App.DialogFragment dialog = RestaurantMenuItemDialogFragment.NewInstance(cat.Id, restaurant.Id);
                        dialog.Show(FragmentManager, "fragmentDialog");
                    };
                }
            }
        }