public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { MenuItemViewHolder vh = holder as MenuItemViewHolder; vh.Item = Items[position]; Image img = _imageFacade.LoadImage(vh.Item.ImageId.Value).Result; vh.Img.SetImageBitmap(BitmapFactory.DecodeByteArray(img.FileContent, 0, img.FileContent.Length)); vh.Name.Text = vh.Item.Name; vh.Description.Text = vh.Item.Description; vh.Price.Text = "£" + string.Format("{0:N2}", Math.Round(vh.Item.Price, 2, MidpointRounding.AwayFromZero)); }
public async Task <ActionResult> ImageFromId(int id) { Image i = _imageFacade.LoadImage(id); return(File(i.FileContent, i.Type)); }
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"); }; } } }