public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { MyTastingCellView cell = tableView.DequeueReusableCell(CellIdentifier) as MyTastingCellView; Tastings item = TableItems[indexPath.Row]; //---- if there are no cells to reuse, create a new one NSString name = new NSString(CellIdentifier); if (cell == null) { cell = new MyTastingCellView(name); } cell.NavController = NavController; cell.Parent = Parent; cell.taste = item; cell.UpdateCell(item); cell.SetNeedsDisplay(); return(cell); }
public void UpdateCell(Tastings tasting) { try { string url = tasting.SmallImageUrl; if (url == null) { url = tasting.Barcode + ".jpg"; } imageView.SetImage(BlobWrapper.GetResizedImage(url, new CGRect(0, 0, 100, 155), tasting.PlantFinal.ToString()), UIControlState.Normal); separator.Image = UIImage.FromFile("separator.png"); WineName.Text = tasting.Name; ReviewDate.Text = "Tasted on :" + tasting.TastingDate.ToString("MM-dd-yyyy"); double l = Math.Floor(Math.Log10(tasting.Vintage) + 1); if (l < 4) { Vintage.Text = " "; } else { Vintage.Text = tasting.Vintage.ToString(); } if (tasting.PlantFinal == 1) { location.Text = "Tasted at : " + LoggingClass.txtstore1; } else { location.Text = "Tasted at : " + LoggingClass.txtstore2; } WineIdLabel.Text = tasting.Barcode; btnItemname.SetTitle(tasting.Name, UIControlState.Normal); btnItemname.LineBreakMode = UILineBreakMode.WordWrap; btnItemname.HorizontalAlignment = UIControlContentHorizontalAlignment.Left; storeid = tasting.PlantFinal; if (tasting.IsLike == true) { heartImage.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal); // heartImage.TouchUpInside +=async delegate { // heartImage.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal); // SKULike like = new SKULike(); // like.UserID = Convert.ToInt32(CurrentUser.RetreiveUserId()); // like.BarCode = WineIdLabel.Text; // like.Liked = Convert.ToBoolean(0); // myItem.IsLike = Convert.ToBoolean(0); // ServiceWrapper sw = new ServiceWrapper(); // await sw.InsertUpdateLike(like); // }; } else { heartImage.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal); } } catch (Exception ex) { UIAlertView alert = new UIAlertView() { Title = "Sorry", Message = "Something went wrong. We are on it" }; alert.AddButton("OK"); alert.Show(); LoggingClass.LogError(ex.Message, screen, ex.StackTrace); } }