public async Task <int> InsertUpdateLike(SKULike skuLike) { sw.Start(); try { LoggingClass.LogServiceInfo("service called", "InsertUpdateLike"); var uri = new Uri(ServiceURL + "InsertUpdateLike/"); string Token = CurrentUser.GetAuthToken(); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Token); var content = JsonConvert.SerializeObject(skuLike); var cont = new StringContent(content, System.Text.Encoding.UTF8, "application/json"); var response = await client.PostAsync(uri, cont); // In debug mode it do not work, Else it works //var result = response.Content.ReadAsStringAsync().Result; LoggingClass.LogServiceInfo("service response", "InsertUpdateLike"); } catch (Exception exe) { LoggingClass.LogError(exe.Message, screenid, exe.StackTrace.ToString()); } sw.Stop(); LoggingClass.LogTime("The total time to start and end the service InsertUpdateLike", "The timer ran for " + sw.Elapsed.TotalSeconds); return(1); }
public int InsertUpdateSKULike(SKULike skuLike) { try { int result = DBContext.InsertUpdateLike(skuLike.UserID, skuLike.SKU, skuLike.Liked, skuLike.WineId); return(result); } catch (Exception ex) { return(0); } }
public async Task <int> InsertUpdateLike(SKULike skuLike) { try { var uri = new Uri(ServiceURL + "InsertUpdateLike/"); var content = JsonConvert.SerializeObject(skuLike); var cont = new StringContent(content, System.Text.Encoding.UTF8, "application/json"); var response = await client.PostAsync(uri, cont); // In debug mode it do not work, Else it works //var result = response.Content.ReadAsStringAsync().Result; } catch (Exception ex) { throw ex; } return(1); }
public override View GetView(int position, View convertView, ViewGroup parent) { View row = convertView; if (myItems.Count == 0) { row = LayoutInflater.From(myContext).Inflate(Resource.Layout.EmptyTaste, null, false); TextView te = row.FindViewById <TextView>(Resource.Id.textView123a); } else { if (row == null) { row = LayoutInflater.From(myContext).Inflate(Resource.Layout.MyTastingView, null, false); } TextView txtName = row.FindViewById <TextView>(Resource.Id.SkuName); TextView txtYear = row.FindViewById <TextView>(Resource.Id.Vintage); //TextView txtDescription = row.FindViewById<TextView>(Resource.Id.TastingNotes); TextView txtDate = row.FindViewById <TextView>(Resource.Id.Date); TextView txtPrice = row.FindViewById <TextView>(Resource.Id.Price); ImageView heartImg = row.FindViewById <ImageView>(Resource.Id.imageButton4); ImageButton wineimage = row.FindViewById <ImageButton>(Resource.Id.imageButton2); //RatingBar rb = row.FindViewById<RatingBar>(Resource.Id.AvgRating); heartImg.SetImageResource(Resource.Drawable.heart_empty); txtDate.SetTextSize(Android.Util.ComplexUnitType.Dip, 11); txtPrice.SetTextSize(Android.Util.ComplexUnitType.Dip, 11); txtName.Text = myItems[position].Name; txtYear.Text = myItems[position].Vintage.ToString(); if (txtYear.Text == null || txtYear.Text == "0") { txtYear.Text = ""; } else { txtYear.Text = myItems[position].Vintage.ToString(); } //txtDescription.Text = myItems[position].Description; txtDate.Text = "Tasted on :" + myItems[position].TastingDate.ToString("yyyy/MM/dd"); //txtPrice.Text = myItems[position].SalePrice.ToString("C", GridViewAdapter.Cultures.UnitedState); txtPrice.Text = myItems[position].PlantFinal.ToString(); if (txtPrice.Text == "1") { txtPrice.Text = "Tasted at :" + " Wall"; } else if (txtPrice.Text == "2") { txtPrice.Text = "Tasted at :" + " Pt.Pleasant Beach"; } //rb.Rating = (float)myItems[position].AverageRating; //Bitmap imageBitmap = bvb.Bottleimages(myItems[position].WineId); ProfilePicturePickDialog pppd = new ProfilePicturePickDialog(); string path = pppd.CreateDirectoryForPictures(); //string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); var filePath = System.IO.Path.Combine(path + "/" + myItems[position].Barcode + ".jpg"); bool count = Convert.ToBoolean(myItems[position].IsLike); if (count == true) { heartImg.SetImageResource(Resource.Drawable.heart_full); } else { heartImg.SetImageResource(Resource.Drawable.heart_empty); } heartImg.Tag = position; if (convertView == null) { heartImg.Click += async delegate { int actualPosition = Convert.ToInt32(heartImg.Tag); bool x; if (count == false) { heartImg.SetImageResource(Resource.Drawable.heart_full); x = true; count = true; } else { heartImg.SetImageResource(Resource.Drawable.heart_empty); x = false; count = false; } SKULike like = new SKULike(); like.UserID = Convert.ToInt32(CurrentUser.getUserId()); like.SKU = Convert.ToInt32(myItems[actualPosition].SKU); like.Liked = x; myItems[actualPosition].IsLike = x; like.BarCode = myItems[actualPosition].Barcode; ServiceWrapper sw = new ServiceWrapper(); await sw.InsertUpdateLike(like); }; } Bitmap imageBitmap; //if (System.IO.File.Exists(filePath)) //{ // imageBitmap = BitmapFactory.DecodeFile(filePath); // wineimage.SetImageBitmap(imageBitmap); //} string url = myItems[position].SmallImageUrl; if (url == null) { url = myItems[position].Barcode + ".jpg"; } imageBitmap = BlobWrapper.Bottleimages(url, myItems[position].PlantFinal); if (imageBitmap == null) { wineimage.SetImageResource(Resource.Drawable.bottle); } else { wineimage.SetImageBitmap(imageBitmap); } //wineimage.SetScaleType(ImageView.ScaleType.CenterCrop); txtName.Focusable = false; txtYear.Focusable = false; //txtDescription.Focusable = false; txtDate.Focusable = false; txtPrice.Focusable = false; wineimage.Focusable = false; wineimage.FocusableInTouchMode = false; wineimage.Clickable = true; } LoggingClass.LogInfo("Entered into My tastings Adapter", screenid); return(row); }
public override View GetView(int position, View convertView, ViewGroup parent) { View row = convertView; if (row == null) { row = LayoutInflater.From(myContext).Inflate(Resource.Layout.cell, null, false); } //else // return row; TextView txtName = row.FindViewById <TextView>(Resource.Id.txtName); TextView txtVintage = row.FindViewById <TextView>(Resource.Id.txtVintage); TextView AmountLeft = row.FindViewById <TextView>(Resource.Id.txtAmountLeft); TextView txtPrice = row.FindViewById <TextView>(Resource.Id.txtPrice); ImageView imgWine = row.FindViewById <ImageView>(Resource.Id.imgWine); ImageView heartImg = row.FindViewById <ImageView>(Resource.Id.imgHeart); RatingBar rating = row.FindViewById <RatingBar>(Resource.Id.rtbProductRating); rating.Rating = (float)myItems[position].AverageRating; txtName.Text = myItems[position].Name; txtPrice.Text = myItems[position].SalePrice.ToString("C", Cultures.UnitedState); AmountLeft.Text = "Wine left in bottle: " + myItems[position].AvailableVolume.ToString() + ".ml"; txtVintage.Text = myItems[position].Vintage.ToString(); heartImg.SetImageResource(Resource.Drawable.Heart_emp); var heartLP = new FrameLayout.LayoutParams(80, 80); var metrics = myContext.Resources.DisplayMetrics; var widthInDp = ConvertPixelsToDp(metrics.WidthPixels); var heightInDp = ConvertPixelsToDp(metrics.HeightPixels); heartLP.LeftMargin = parent.Resources.DisplayMetrics.WidthPixels / 2 - 110; // 110 = 80 + 30 heartLP.TopMargin = 5; heartImg.LayoutParameters = heartLP; heartImg.Layout(50, 50, 50, 50); bool count = Convert.ToBoolean(myItems[position].IsLike); if (count == true) { heartImg.SetImageResource(Resource.Drawable.HeartFull); } else { heartImg.SetImageResource(Resource.Drawable.Heart_emp); } heartImg.Tag = position; if (convertView == null) { heartImg.Click += async delegate { if (CurrentUser.getUserId() == null) { AlertDialog.Builder aler = new AlertDialog.Builder(myContext, Resource.Style.MyDialogTheme); aler.SetTitle("Sorry"); aler.SetMessage("This Feature is available for VIP Users only"); aler.SetNegativeButton("Ok", delegate { LoggingClass.LogInfo("Closed PoPup", screenid); }); Dialog dialog1 = aler.Create(); dialog1.Show(); } else { int actualPosition = Convert.ToInt32(heartImg.Tag); bool x; if (count == false) { heartImg.SetImageResource(Resource.Drawable.HeartFull); LoggingClass.LogInfoEx("Liked an item------>" + myItems[position].Barcode, screenid); x = true; count = true; } else { heartImg.SetImageResource(Resource.Drawable.Heart_emp); LoggingClass.LogInfoEx("UnLiked an item" + "----->" + myItems[position].Barcode, screenid); x = false; count = false; } SKULike like = new SKULike(); like.UserID = Convert.ToInt32(CurrentUser.getUserId()); like.SKU = Convert.ToInt32(myItems[actualPosition].SKU); like.Liked = x; myItems[actualPosition].IsLike = x; like.BarCode = myItems[actualPosition].Barcode; LoggingClass.LogInfo("Liked an item", screenid); ServiceWrapper sw = new ServiceWrapper(); await sw.InsertUpdateLike(like); } }; // } } Bitmap imageBitmap; imageBitmap = BlobWrapper.Bottleimages(myItems[position].Barcode, storeid); var place = new FrameLayout.LayoutParams(650, 650); //-650 + (parent.Resources.DisplayMetrics.WidthPixels - imageBitmap.Width) / 2; imgWine.LayoutParameters = place; //var place1 = new FrameLayout.LayoutParams(600, 500); ////-650 + (parent.Resources.DisplayMetrics.WidthPixels - imageBitmap.Width) / 2; //imgWine.LayoutParameters = place1; if (imageBitmap != null) { if (heartLP.LeftMargin <= 250) { place.LeftMargin = -140; float ratio = (float)500 / imageBitmap.Height; imageBitmap = Bitmap.CreateScaledBitmap(imageBitmap, Convert.ToInt32(imageBitmap.Width * ratio), 550, true); } else { place.LeftMargin = -70; float ratio = (float)650 / imageBitmap.Height; imageBitmap = Bitmap.CreateScaledBitmap(imageBitmap, Convert.ToInt32(imageBitmap.Width * ratio), 650, true); } imgWine.SetImageBitmap(imageBitmap); imageBitmap.Dispose(); } else { if (heartLP.LeftMargin <= 250) { place.LeftMargin = -140; imgWine.SetImageResource(Resource.Drawable.bottle); } else { place.LeftMargin = -70; imgWine.SetImageResource(Resource.Drawable.bottle); } } txtName.Focusable = false; AmountLeft.Focusable = false; txtVintage.Focusable = false; txtPrice.Focusable = false; imgWine.Focusable = false; imgWine.Dispose(); return(row); }
public APLCollectionViewCell(CGRect frame) : base(frame) { try { //BTProgressHUD.Show("Please wait..."); CGRect box = new CGRect(Bounds.Location, Bounds.Size); box.X = 0; box.Y = 0; box.Height = box.Height - 140; BackgroundColor = UIColor.White; btnBack = new UIButton(); btnBack.BackgroundColor = UIColor.Black; btnBack.Frame = new CGRect(2, 2, Bounds.Width + 1, box.Height - 139); btnBack.UserInteractionEnabled = false; ImageView = new UIButton(box); ImageView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth; ImageView.ContentMode = UIViewContentMode.ScaleAspectFill; //ImageView.Layer.BorderWidth = 3.0f; ImageView.ClipsToBounds = true; ImageView.Layer.BorderColor = UIColor.White.CGColor; ImageView.Layer.EdgeAntialiasingMask = CAEdgeAntialiasingMask.LeftEdge | CAEdgeAntialiasingMask.RightEdge | CAEdgeAntialiasingMask.BottomEdge | CAEdgeAntialiasingMask.TopEdge; box.Y = 3; btlImage = new UIButton(box); btlImage.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth; //btlImage.ContentMode = UIViewContentMode.ScaleAspectFill; btlImage.ClipsToBounds = true; btlImage.Layer.BorderColor = UIColor.White.CGColor; btlImage.Layer.EdgeAntialiasingMask = CAEdgeAntialiasingMask.LeftEdge | CAEdgeAntialiasingMask.RightEdge | CAEdgeAntialiasingMask.BottomEdge | CAEdgeAntialiasingMask.TopEdge; //btlImage.TouchDown += (sender, e) => //{ // BTProgressHUD.Show("Loading..."); //show spinner + text //}; btlImage.TouchUpInside += (object sender, EventArgs e) => { BTProgressHUD.Show("Loading..."); //BTProgressHUD.Dismiss(); NavigationController.PushViewController(new DetailViewController(WineBarcode, storeId, false, false), false); LoggingClass.LogInfo("Clicked on " + WineBarcode + " to enter into Details", screen); }; box.Height = 25; box.Width = 25; box.X = (Bounds.Width - 30); box.Y = 5; heartImage = new UIButton(box); heartImage.ClipsToBounds = true; heartImage.Layer.BorderColor = UIColor.White.CGColor; heartImage.Layer.EdgeAntialiasingMask = CAEdgeAntialiasingMask.LeftEdge | CAEdgeAntialiasingMask.RightEdge | CAEdgeAntialiasingMask.BottomEdge | CAEdgeAntialiasingMask.TopEdge; heartImage.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal); heartImage.Tag = 0; heartImage.TouchUpInside += async(object sender, EventArgs e) => { //Do some actionn if (CurrentUser.RetreiveUserId() != 0) { UIButton temp = (UIButton)sender; if (temp.Tag == 0) { heartImage.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal); temp.Tag = 1; myItem.IsLike = true; LoggingClass.LogInfo("Liked Wine " + WineBarcode, screen); } else { heartImage.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal); temp.Tag = 0; myItem.IsLike = false; LoggingClass.LogInfo("Unliked Wine " + WineBarcode, screen); } //NavigationController.PushViewController(new DetailViewController(), false); SKULike like = new SKULike(); like.UserID = Convert.ToInt32(CurrentUser.RetreiveUserId()); like.BarCode = WineBarcode; like.Liked = Convert.ToBoolean(temp.Tag); ServiceWrapper sw = new ServiceWrapper(); await sw.InsertUpdateLike(like); } else { UIAlertView alert = new UIAlertView() { Title = "This feature is allowed only for VIP Card holders", //Message = "Coming Soon..." }; alert.AddButton("OK"); alert.AddButton("Know more"); alert.Clicked += (senderalert, buttonArgs) => { if (buttonArgs.ButtonIndex == 1) { UIApplication.SharedApplication.OpenUrl(new NSUrl("https://hangoutz.azurewebsites.net/index.html")); } }; //alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput; alert.Show(); } }; //for buy button box.Height = 35; box.Width = 35; box.X = (Bounds.Width - 40); box.Y = 40; btnBuy = new UIButton(box); btnBuy.ClipsToBounds = true; btnBuy.Layer.BorderColor = UIColor.White.CGColor; btnBuy.Layer.EdgeAntialiasingMask = CAEdgeAntialiasingMask.LeftEdge | CAEdgeAntialiasingMask.RightEdge | CAEdgeAntialiasingMask.BottomEdge | CAEdgeAntialiasingMask.TopEdge; btnBuy.SetImage(UIImage.FromFile("buy.png"), UIControlState.Normal); btnBuy.TouchUpInside += delegate { NavigationController.PushViewController(new ExploreViewController("http://www.wineoutlet.com/sku" + Sku + ".html"), false); //UIApplication.SharedApplication.OpenUrl(new NSUrl("http://www.wineoutlet.com/sku"+Sku+".html")); }; CGRect lower = new CGRect(Bounds.Location, Bounds.Size); lower.Y = 50; //lower.Y + (ratio)*(Bounds.Height); btnItemname = new UIButton(lower); btnItemname.SetTitle("", UIControlState.Normal); btnItemname.SetTitleColor(UIColor.Purple, UIControlState.Normal); btnItemname.Font = UIFont.FromName("Verdana-Bold", 13f); btnItemname.LineBreakMode = UILineBreakMode.WordWrap; btnItemname.TouchUpInside += (object sender, EventArgs e) => { BTProgressHUD.Show("Loading..."); //BTProgressHUD.Dismiss(); NavigationController.PushViewController(new DetailViewController(WineBarcode, storeId, false, false), false); LoggingClass.LogInfo("Clicked on " + WineBarcode + " to enter into Details", screen); }; lblName = new UILabel(lower); lblName.Font = UIFont.FromName("Verdana-Bold", 13f); lblName.TextColor = UIColor.Purple; lblName.Text = WineName; lblName.TextAlignment = UITextAlignment.Center; lblName.LineBreakMode = UILineBreakMode.WordWrap; lblName.Lines = 0; lower.Y = 245; lower.Height = 1; lower.Width = lower.Width - 20; lower.X = lower.X + 10; Separator = new UIImageView(lower); Separator.AutoresizingMask = UIViewAutoresizing.FlexibleWidth; Separator.Image = UIImage.FromFile("separator.png"); Separator.ContentMode = UIViewContentMode.ScaleAspectFill; Separator.ClipsToBounds = true; Separator.Layer.BorderColor = UIColor.White.CGColor; Separator.BackgroundColor = UIColor.LightGray; CGRect year = new CGRect(Bounds.Location, Bounds.Size); year.Y = lower.Y - 15; year.X = year.Width / 2 - 25; year.Height = 30; year.Width = 50; lblYear = new UILabel(year); lblYear.Font = UIFont.FromName("Verdana", 12f); lblYear.Text = Vintage; lblYear.TextAlignment = UITextAlignment.Center; lblYear.BackgroundColor = UIColor.White; lblRegPrice = new UILabel(new CGRect(0, Bounds.Height - 60, Bounds.Width, 12f)); lblRegPrice.Text = RegPrice; lblRegPrice.Font = UIFont.FromName("Verdana", 13f); lblRegPrice.TextAlignment = UITextAlignment.Center; var ratingConfig = new RatingConfig(emptyImage: UIImage.FromBundle("Stars/star-silver2.png"), filledImage: UIImage.FromBundle("Stars/star.png"), chosenImage: UIImage.FromBundle("Stars/star.png")); //decimal averageRating = 3.25m; ratingView = new PDRatingView(new CGRect(Bounds.Width * 1 / 4, Bounds.Height - 40, Bounds.Width / 2, 14f), ratingConfig, averageRating); ratingView.UserInteractionEnabled = false; //ratingView.BackgroundColor = UIColor.White; //Console.WriteLine(Sku); //if (Sku != null) //{ //ContentView.AddSubview(btnBuy); //} AmountLeft = new UITextView(new CGRect(0, Bounds.Height - 30, Bounds.Width, 20)); AmountLeft.TextAlignment = UITextAlignment.Center; AmountLeft.Editable = false; //AmountLeft.ProgressTintColor = UIColor.Blue; //AmountLeft.SetProgress(1, true); //AmountLeft.Progress = 30f; //ContentView.AddSubview(btnBack); ContentView.AddSubview(ImageView); ContentView.InsertSubviewAbove(btlImage, ImageView); ContentView.AddSubview(AmountLeft); ContentView.AddSubview(heartImage); //ContentView.AddSubview(lblName); ContentView.AddSubview(btnItemname); ContentView.AddSubview(Separator); ContentView.AddSubview(lblYear); ContentView.AddSubview(lblRegPrice); ContentView.AddSubview(ratingView); ContentView.AddSubview(btnBuy); } catch (Exception ex) { LoggingClass.LogError(ex.ToString(), screen, ex.StackTrace); } }
public MyTastingCellView(NSString cellId) : base(UITableViewCellStyle.Default, cellId) { try { SelectionStyle = UITableViewCellSelectionStyle.Gray; LoggingClass.LogInfo("Entered Into Tasting View", screen); imageView = new UIButton(); imageView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth; imageView.ContentMode = UIViewContentMode.Center; imageView.ClipsToBounds = true; imageView.TouchUpInside += (object sender, EventArgs e) => { BTProgressHUD.Show("Loading..."); NavController.PushViewController(new DetailViewController(WineIdLabel.Text, storeid.ToString(), false, true), false); }; separator = new UIImageView(); btnItemname = new UIButton(); btnItemname.SetTitle("", UIControlState.Normal); btnItemname.SetTitleColor(UIColor.FromRGB(127, 51, 0), UIControlState.Normal); btnItemname.Font = UIFont.FromName("Verdana-Bold", 13f); btnItemname.LineBreakMode = UILineBreakMode.WordWrap; btnItemname.TouchUpInside += delegate { BTProgressHUD.Show("Loading..."); NavController.PushViewController(new DetailViewController(WineIdLabel.Text, storeid.ToString(), false, true), false); }; WineName = new UILabel() { Font = UIFont.FromName("Verdana", 14f), TextColor = UIColor.FromRGB(127, 51, 0), BackgroundColor = UIColor.Clear, }; ReviewDate = new UILabel() { Font = UIFont.FromName("AmericanTypewriter", 10f), TextColor = UIColor.FromRGB(38, 127, 200), //TextAlignment = UITextAlignment.Center, BackgroundColor = UIColor.Clear }; Vintage = new UILabel() { Font = UIFont.FromName("Verdana", 10f), TextColor = UIColor.FromRGB(127, 51, 100), BackgroundColor = UIColor.Clear }; location = new UILabel() { Font = UIFont.FromName("Verdana", 10f), TextColor = UIColor.FromRGB(127, 51, 100), BackgroundColor = UIColor.Clear }; heartImage = new UIButton(); heartImage.ClipsToBounds = true; heartImage.Layer.BorderColor = UIColor.White.CGColor; heartImage.Layer.EdgeAntialiasingMask = CAEdgeAntialiasingMask.LeftEdge | CAEdgeAntialiasingMask.RightEdge | CAEdgeAntialiasingMask.BottomEdge | CAEdgeAntialiasingMask.TopEdge; heartImage.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal); heartImage.Tag = 0; myItem = new Item(); bool count = Convert.ToBoolean(myItem.IsLike); if (count == true) { heartImage.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal); } else { heartImage.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal); } heartImage.TouchUpInside += async(object sender, EventArgs e) => { try { //Do some actionn if (CurrentUser.RetreiveUserId() != 0) { UIButton temp = (UIButton)sender; if (temp.Tag == 0) { heartImage.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal); temp.Tag = 1; myItem.IsLike = true; taste.IsLike = true; LoggingClass.LogInfo("Liked Wine " + WineIdLabel.Text, screen); } else { heartImage.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal); temp.Tag = 0; myItem.IsLike = false; taste.IsLike = false; LoggingClass.LogInfo("Unliked Wine " + WineIdLabel.Text, screen); } //NavigationController.PushViewController(new DetailViewController(), false); SKULike like = new SKULike(); like.UserID = Convert.ToInt32(CurrentUser.RetreiveUserId()); like.BarCode = WineIdLabel.Text; like.Liked = Convert.ToBoolean(temp.Tag); myItem.IsLike = Convert.ToBoolean(temp.Tag); ServiceWrapper sw = new ServiceWrapper(); await sw.InsertUpdateLike(like); } } catch (Exception ex) { LoggingClass.LogError(ex.Message, screen, ex.StackTrace); } }; WineIdLabel = new UILabel(); ContentView.AddSubviews(new UIView[] { btnItemname, ReviewDate, imageView, Vintage, separator, heartImage, location }); } catch (Exception ex) { LoggingClass.LogError(ex.Message, screen, ex.StackTrace); } }
public override View GetView(int position, View convertView, ViewGroup parent) { View row = convertView; if (myItems.Count == 0) { row = LayoutInflater.From(myContext).Inflate(Resource.Layout.ReviewEmpty, null, false); TextView txtName = row.FindViewById <TextView>(Resource.Id.textView1); ImageView Imag = row.FindViewById <ImageView>(Resource.Id.imageView1); } else { if (row == null) { row = LayoutInflater.From(myContext).Inflate(Resource.Layout.MyReviewsCell, null, false); } TextView txtName = row.FindViewById <TextView>(Resource.Id.textView64); TextView txtYear = row.FindViewById <TextView>(Resource.Id.textView65); TextView txtDescription = row.FindViewById <TextView>(Resource.Id.textView66); TextView txtDate = row.FindViewById <TextView>(Resource.Id.textView67); ImageButton edit = row.FindViewById <ImageButton>(Resource.Id.imageButton3); ImageButton delete = row.FindViewById <ImageButton>(Resource.Id.imageButton4); ImageButton wineimage = row.FindViewById <ImageButton>(Resource.Id.imageButton2); var metrics = myContext.Resources.DisplayMetrics; var widthInDp = ConvertPixelsToDp(metrics.WidthPixels); var heightInDp = ConvertPixelsToDp(metrics.HeightPixels); RatingBar rb = row.FindViewById <RatingBar>(Resource.Id.rating); ImageView heartImg = row.FindViewById <ImageView>(Resource.Id.imageButton44); heartImg.SetImageResource(Resource.Drawable.heart_empty); edit.Focusable = false; edit.Clickable = true; delete.Focusable = false; delete.Clickable = true; wineimage.Focusable = false; wineimage.FocusableInTouchMode = false; wineimage.Clickable = true; wineimage.Click += (sender, args) => Console.WriteLine("ImageButton {0} clicked", position); txtDate.SetTextSize(Android.Util.ComplexUnitType.Dip, 12); txtName.Text = myItems[position].Name; txtYear.Text = myItems[position].Vintage; if (txtYear.Text == null || txtYear.Text == "0") { txtYear.Text = ""; } else { txtYear.Text = myItems[position].Vintage; } txtDescription.Text = myItems[position].RatingText; txtDate.Text = myItems[position].Date.ToString("yyyy/MM/dd"); rb.Rating = (float)myItems[position].RatingStars; ProfilePicturePickDialog pppd = new ProfilePicturePickDialog(); string path = pppd.CreateDirectoryForPictures(); var filePath = System.IO.Path.Combine(path + "/" + myItems[position].Barcode + ".jpg"); bool count = Convert.ToBoolean(myItems[position].Liked); if (count == true) { heartImg.SetImageResource(Resource.Drawable.heart_full); } else { heartImg.SetImageResource(Resource.Drawable.heart_empty); } heartImg.Tag = position; edit.Tag = position; delete.Tag = position; if (convertView == null) { edit.Click += (sender, args) => { int tempPosition = Convert.ToInt32(edit.Tag); string WineBarcode = myItems[tempPosition].Barcode; Review _review = new Review(); _review.Barcode = WineBarcode; _review.RatingStars = myItems[tempPosition].RatingStars; _review.RatingText = myItems[tempPosition].RatingText; _review.PlantFinal = myItems[tempPosition].PlantFinal; LoggingClass.LogInfo("clicked on edit an item---->" + WineBarcode + "----->" + _review.RatingStars + "---->" + _review.RatingText, screenid); PerformItemClick(sender, args, _review); }; delete.Click += (sender, args) => { int tempPositio1n = Convert.ToInt32(edit.Tag); string WineBarcode = myItems[tempPositio1n].Barcode; Review _review = new Review(); _review.Barcode = WineBarcode; LoggingClass.LogInfo("clicked on delete item--->" + WineBarcode, screenid); PerformdeleteClick(sender, args, _review); }; heartImg.Click += delegate { int actualPosition = Convert.ToInt32(heartImg.Tag); bool x; if (count == false) { heartImg.SetImageResource(Resource.Drawable.heart_full); x = true; count = true; } else { heartImg.SetImageResource(Resource.Drawable.heart_empty); x = false; count = false; } var TaskA = new System.Threading.Tasks.Task(async() => { SKULike like = new SKULike(); like.UserID = Convert.ToInt32(CurrentUser.getUserId()); like.SKU = Convert.ToInt32(myItems[actualPosition].SKU); like.Liked = x; like.BarCode = myItems[actualPosition].Barcode; ServiceWrapper sw = new ServiceWrapper(); await sw.InsertUpdateLike(like); }); TaskA.Start(); }; } Bitmap imageBitmap; string url = myItems[position].SmallImageURL; if (url == null || url == "") { url = myItems[position].Barcode + ".jpg"; } imageBitmap = BlobWrapper.Bottleimages(url, Convert.ToInt32(myItems[position].PlantFinal)); if (imageBitmap == null) { wineimage.SetImageResource(Resource.Drawable.bottle); } else { wineimage.SetImageBitmap(imageBitmap); } txtName.Focusable = false; txtYear.Focusable = false; txtDescription.Focusable = false; txtDate.Focusable = false; } LoggingClass.LogInfo("Entered into My Review Adapter", screenid); return(row); }
public override View GetView(int position, View convertView, ViewGroup parent) { View row = convertView; if (row == null) { row = LayoutInflater.From(myContext).Inflate(Resource.Layout.ListView, null, false); } //else // return row; TextView txtName = row.FindViewById <TextView>(Resource.Id.txtName); TextView txtVintage = row.FindViewById <TextView>(Resource.Id.txtVintage); TextView AmountLeft = row.FindViewById <TextView>(Resource.Id.txtAmountLeft); TextView txtPrice = row.FindViewById <TextView>(Resource.Id.txtPrice); ImageView imgWine = row.FindViewById <ImageView>(Resource.Id.imgWine); ImageView buy = row.FindViewById <ImageView>(Resource.Id.imgHeart1); //buy.Click += delegate //{ // ProgressIndicator.Show(myContext); // var intent = new Intent(myContext, typeof(Wineoutletweb)); // intent.PutExtra("WineBarcode", WineBarcode); // StartActivity(intent); //}; ImageView heartImg = row.FindViewById <ImageView>(Resource.Id.imgHeart); RatingBar rating = row.FindViewById <RatingBar>(Resource.Id.rtbProductRating); rating.Rating = (float)myItems[position].AverageRating; txtName.Text = myItems[position].Name; txtPrice.Text = myItems[position].SalePrice.ToString("C", Cultures.UnitedState); AmountLeft.Text = "Wine left in bottle: " + myItems[position].AvailableVolume.ToString() + " ml"; txtVintage.Text = myItems[position].Vintage.ToString(); if (txtVintage.Text == "0" || txtVintage.Text == null) { txtVintage.Text = ""; } else { txtVintage.Text = myItems[position].Vintage.ToString(); } heartImg.SetImageResource(Resource.Drawable.heart_empty); //var heartLP = new FrameLayout.LayoutParams(80, 80); //var metrics = myContext.Resources.DisplayMetrics; //var widthInDp = ConvertPixelsToDp(metrics.WidthPixels); //var heightInDp = ConvertPixelsToDp(metrics.HeightPixels); //heartLP.LeftMargin = parent.Resources.DisplayMetrics.WidthPixels / 2 - 110; // 110 = 80 + 30 //heartLP.TopMargin = 5; //heartImg.LayoutParameters = heartLP; //heartImg.Layout(50, 50, 50, 50); bool count = Convert.ToBoolean(myItems[position].IsLike); if (count == true) { heartImg.SetImageResource(Resource.Drawable.heart_full); } else { heartImg.SetImageResource(Resource.Drawable.heart_empty); } heartImg.Tag = position; if (convertView == null) { buy.Click += delegate { ProgressIndicator.Show(myContext); var intent = new Intent(myContext, typeof(Wineoutletweb)); string sku = myItems[position].SKU; intent.PutExtra("sku", sku); intent.PutExtra("Val", "1"); myContext.StartActivity(intent); }; heartImg.Click += delegate { if (CurrentUser.GetGuestId() != null || CurrentUser.getUserId() == "0") { AlertDialog.Builder aler = new AlertDialog.Builder(myContext, Resource.Style.MyDialogTheme); aler.SetTitle("Sorry"); aler.SetMessage("This Feature is available for VIP Users only"); //aler.SetNegativeButton("KnowMore", delegate //{ // var uri = Android.Net.Uri.Parse("https://hangoutz.azurewebsites.net/index.html"); // var intent = new Intent(Intent.ActionView, uri); // StartActivity(intent); //}); aler.SetNegativeButton("Ok", delegate { LoggingClass.LogInfo("Closed PoPup", screenid); }); Dialog dialog1 = aler.Create(); dialog1.Show(); } else { int actualPosition = Convert.ToInt32(heartImg.Tag); bool x; if (count == false) { heartImg.SetImageResource(Resource.Drawable.heart_full); x = true; count = true; } else { heartImg.SetImageResource(Resource.Drawable.heart_empty); x = false; count = false; } var TaskA = new System.Threading.Tasks.Task(async() => { SKULike like = new SKULike(); like.UserID = Convert.ToInt32(CurrentUser.getUserId()); like.SKU = Convert.ToInt32(myItems[actualPosition].SKU); like.Liked = x; myItems[actualPosition].IsLike = x; like.BarCode = myItems[actualPosition].Barcode; //LoggingClass.LogInfo("Liked an item", screenid); ServiceWrapper sw = new ServiceWrapper(); await sw.InsertUpdateLike(like); }); TaskA.Start(); } }; // } } Bitmap imageBitmap; string url = myItems[position].SmallImageUrl; if (url == null || url == "") { url = myItems[position].Barcode + ".jpg"; } imageBitmap = BlobWrapper.Bottleimages(url, storeid); //var place = new RelativeLayout.LayoutParams(650, 650); ////-650 + (parent.Resources.DisplayMetrics.WidthPixels - imageBitmap.Width) / 2; // imgWine.LayoutParameters = place; //var place1 = new FrameLayout.LayoutParams(600, 500); ////-650 + (parent.Resources.DisplayMetrics.WidthPixels - imageBitmap.Width) / 2; //imgWine.LayoutParameters = place1; if (imageBitmap != null) { // if (heartLP.LeftMargin <= 250) // { // place.LeftMargin = -140; float ratio = (float)400 / imageBitmap.Height; imageBitmap = Bitmap.CreateScaledBitmap(imageBitmap, Convert.ToInt32(imageBitmap.Width * ratio), 400, true); // } // else // { // place.LeftMargin = -70; // float ratio = (float)650 / imageBitmap.Height; // imageBitmap = Bitmap.CreateScaledBitmap(imageBitmap, Convert.ToInt32(imageBitmap.Width * ratio), 650, true); // } imgWine.SetImageBitmap(imageBitmap); } else { //if (heartLP.LeftMargin <= 250) //{ // place.LeftMargin = -140; // imgWine.SetImageResource(Resource.Drawable.bottle); //} //else //{ // place.LeftMargin = -70; imgWine.SetImageResource(Resource.Drawable.bottle); } txtName.Focusable = false; AmountLeft.Focusable = false; txtVintage.Focusable = false; txtPrice.Focusable = false; imgWine.Focusable = false; imgWine.Dispose(); //imageBitmap.Dispose(); return(row); }
public override View GetView(int position, View convertView, ViewGroup parent) { View row = convertView; if (row == null) { row = LayoutInflater.From(myContext).Inflate(Resource.Layout.MyFavorite, null, false); } //else // return row; TextView txtName = row.FindViewById <TextView>(Resource.Id.txtName); TextView txtVintage = row.FindViewById <TextView>(Resource.Id.txtVintage); TextView txtPrice = row.FindViewById <TextView>(Resource.Id.txtPrice); ImageView imgWine = row.FindViewById <ImageView>(Resource.Id.imgWine); ImageView heartImg = row.FindViewById <ImageView>(Resource.Id.imgHeart); RatingBar rating = row.FindViewById <RatingBar>(Resource.Id.rtbProductRating); rating.Rating = (float)myItems[position].AverageRating; txtName.Text = myItems[position].Name; txtPrice.Text = myItems[position].SalePrice.ToString("C", Cultures.UnitedState); txtVintage.Text = myItems[position].Vintage.ToString(); if (txtVintage.Text == "0" || txtVintage.Text == null) { txtVintage.Text = ""; } else { txtVintage.Text = myItems[position].Vintage.ToString(); } heartImg.SetImageResource(Resource.Drawable.heart_empty); //var heartLP = new FrameLayout.LayoutParams(80, 80); //var metrics = myContext.Resources.DisplayMetrics; //var widthInDp = ConvertPixelsToDp(metrics.WidthPixels); //var heightInDp = ConvertPixelsToDp(metrics.HeightPixels); //heartLP.LeftMargin = parent.Resources.DisplayMetrics.WidthPixels / 2 - 110; // 110 = 80 + 30 //heartLP.TopMargin = 5; //heartImg.LayoutParameters = heartLP; //heartImg.Layout(50, 50, 50, 50); bool count = Convert.ToBoolean(myItems[position].IsLike); if (count == true) { heartImg.SetImageResource(Resource.Drawable.heart_full); } else { heartImg.SetImageResource(Resource.Drawable.heart_empty); } heartImg.Tag = position; if (convertView == null) { heartImg.Click += async delegate { int actualPosition = Convert.ToInt32(heartImg.Tag); bool x; if (count == false) { heartImg.SetImageResource(Resource.Drawable.heart_full); x = true; count = true; } else { heartImg.SetImageResource(Resource.Drawable.heart_empty); x = false; count = false; } SKULike like = new SKULike(); like.UserID = Convert.ToInt32(CurrentUser.getUserId()); like.SKU = Convert.ToInt32(myItems[actualPosition].SKU); like.Liked = x; myItems[actualPosition].IsLike = x; like.BarCode = myItems[actualPosition].Barcode; ServiceWrapper sw = new ServiceWrapper(); await sw.InsertUpdateLike(like); }; } Bitmap imageBitmap; string url = myItems[position].SmallImageUrl; if (url == null) { url = myItems[position].Barcode + ".jpg"; } imageBitmap = BlobWrapper.Bottleimages(url, storeid); //var place = new FrameLayout.LayoutParams(650, 650); ////-650 + (parent.Resources.DisplayMetrics.WidthPixels - imageBitmap.Width) / 2; //imgWine.LayoutParameters = place; //if (imageBitmap != null) //{ // if (heartLP.LeftMargin <= 250) // { // place.LeftMargin = -140; // float ratio = (float)500 / imageBitmap.Height; // imageBitmap = Bitmap.CreateScaledBitmap(imageBitmap, Convert.ToInt32(imageBitmap.Width * ratio), 550, true); // } // else // { // place.LeftMargin = -70; // float ratio = (float)650 / imageBitmap.Height; // imageBitmap = Bitmap.CreateScaledBitmap(imageBitmap, Convert.ToInt32(imageBitmap.Width * ratio), 650, true); // } // imgWine.SetImageBitmap(imageBitmap); //} //else //{ // imgWine.SetImageResource(Resource.Drawable.bottle); //} if (imageBitmap != null) { // if (heartLP.LeftMargin <= 250) // { // place.LeftMargin = -140; float ratio = (float)400 / imageBitmap.Height; imageBitmap = Bitmap.CreateScaledBitmap(imageBitmap, Convert.ToInt32(imageBitmap.Width * ratio), 400, true); // } // else // { // place.LeftMargin = -70; // float ratio = (float)650 / imageBitmap.Height; // imageBitmap = Bitmap.CreateScaledBitmap(imageBitmap, Convert.ToInt32(imageBitmap.Width * ratio), 650, true); // } imgWine.SetImageBitmap(imageBitmap); //imageBitmap.Dispose(); } else { //if (heartLP.LeftMargin <= 250) //{ // place.LeftMargin = -140; // imgWine.SetImageResource(Resource.Drawable.bottle); //} //else //{ // place.LeftMargin = -70; imgWine.SetImageResource(Resource.Drawable.bottle); } txtName.Focusable = false; txtVintage.Focusable = false; txtPrice.Focusable = false; imgWine.Focusable = false; imgWine.Dispose(); return(row); }
public override View GetView(int position, View convertView, ViewGroup parent) { View row = convertView; if (row == null) { row = LayoutInflater.From(myContext).Inflate(Resource.Layout.PotraitListView, null, false); } TextView txtName = row.FindViewById <TextView>(Resource.Id.SkuName); TextView txtYear = row.FindViewById <TextView>(Resource.Id.Vintage); TextView txtDate = row.FindViewById <TextView>(Resource.Id.Date); ImageButton edit = row.FindViewById <ImageButton>(Resource.Id.imageButton3); ImageButton delete = row.FindViewById <ImageButton>(Resource.Id.imageButton4); ImageButton wineimage = row.FindViewById <ImageButton>(Resource.Id.imageButton2); RatingBar rb = row.FindViewById <RatingBar>(Resource.Id.AvgRating); edit.SetScaleType(ImageView.ScaleType.CenterCrop); //TextView txtPrice = row.FindViewById<TextView>(Resource.Id.txtPrice); //ImageView imgWine = row.FindViewById<ImageView>(Resource.Id.imgWine); //edit.SetTag(1, 5757); //edit.Click += (sender, args) => { // PerformItemClick(sender, args, position, 5757); //}; edit.SetImageResource(Resource.Drawable.heart_empty); bool count = Convert.ToBoolean(myItems[position].IsLike); if (count == true) { edit.SetImageResource(Resource.Drawable.heart_full); } else { edit.SetImageResource(Resource.Drawable.heart_empty); } if (convertView == null) { edit.Click += async delegate { bool x; if (count == false) { edit.SetImageResource(Resource.Drawable.heart_full); x = true; count = true; } else { edit.SetImageResource(Resource.Drawable.heart_empty); x = false; count = false; } SKULike like = new SKULike(); like.UserID = Convert.ToInt32(CurrentUser.getUserId()); like.SKU = Convert.ToInt32(myItems[position].SKU); like.Liked = x; ServiceWrapper sw = new ServiceWrapper(); await sw.InsertUpdateLike(like); }; } txtDate.SetTextSize(Android.Util.ComplexUnitType.Dip, 12); txtName.Text = myItems[position].Name; txtYear.Text = myItems[position].Vintage.ToString();; txtDate.Text = myItems[position].RegPrice.ToString(); txtDate.Text = "$ " + txtDate.Text; rb.Rating = (float)myItems[position].AverageRating; wineimage.SetImageResource(Resource.Drawable.Tes); wineimage.SetScaleType(ImageView.ScaleType.CenterCrop); //txtPrice.Text = myItems[position].Price; //imgWine.SetImageURI(new Uri(myItems[position].imageURL)); txtName.Focusable = false; txtYear.Focusable = false; rb.Focusable = false; txtDate.Focusable = false; //txtRatings.Focusable = false; //txtUserRatings.Focusable = false; //txtPrice.Focusable = false; //imgWine.Focusable = false; return(row); }
//public async Task bindImages() //{ // await //} public override View GetView(int position, View convertView, ViewGroup parent) { View row = convertView; if (row == null) { row = LayoutInflater.From(myContext).Inflate(Resource.Layout.cell, null, false); } //else // return row; TextView txtName = row.FindViewById <TextView>(Resource.Id.txtName); //TextView txtRatings = row.FindViewById<TextView>(Resource.Id.txtRatings); TextView txtVintage = row.FindViewById <TextView>(Resource.Id.txtVintage); //TextView txtUserRatings = row.FindViewById<TextView>(Resource.Id.txtUserRatings); TextView txtPrice = row.FindViewById <TextView>(Resource.Id.txtPrice); ImageView imgWine = row.FindViewById <ImageView>(Resource.Id.imgWine); // ImageView imgPlaceHolder = row.FindViewById<ImageView>(Resource.Id.Placeholder); ImageView heartImg = row.FindViewById <ImageView>(Resource.Id.imgHeart); RatingBar rating = row.FindViewById <RatingBar>(Resource.Id.rtbProductRating); rating.Rating = (float)myItems[position].AverageRating; //RelativeLayout rel = row.FindViewById<RelativeLayout>(Resource.Id.relative); //var place11 = new RelativeLayout.LayoutParams(520, 620) //rel.LayoutParameters = place11; //rel.LayoutParameters = new RelativeLayout.LayoutParams(520, 520); txtName.Text = myItems[position].Name; //txtName.InputType = Android.Text.InputTypes.TextFlagNoSuggestions; //txtRatings.Text = myItems[position].Ratings; //txtUserRatings.Text = myItems[position].UserRatings; txtPrice.Text = myItems[position].SalePrice.ToString("C", Cultures.UnitedState); txtVintage.Text = myItems[position].Vintage.ToString(); //heartImg.t = myItems[position].s; heartImg.SetImageResource(Resource.Drawable.heart_empty); var heartLP = new FrameLayout.LayoutParams(80, 80); var metrics = myContext.Resources.DisplayMetrics; var widthInDp = ConvertPixelsToDp(metrics.WidthPixels); var heightInDp = ConvertPixelsToDp(metrics.HeightPixels); heartLP.LeftMargin = parent.Resources.DisplayMetrics.WidthPixels / 2 - 110; // 110 = 80 + 30 heartLP.TopMargin = 5; heartImg.LayoutParameters = heartLP; heartImg.Layout(50, 50, 50, 50); bool count = Convert.ToBoolean(myItems[position].IsLike); if (count == true) { heartImg.SetImageResource(Resource.Drawable.heart_full); } else { heartImg.SetImageResource(Resource.Drawable.heart_empty); } heartImg.Tag = position; if (convertView == null) { heartImg.Click += async delegate { int actualPosition = Convert.ToInt32(heartImg.Tag); bool x; if (count == false) { heartImg.SetImageResource(Resource.Drawable.heart_full); x = true; count = true; } else { heartImg.SetImageResource(Resource.Drawable.heart_empty); x = false; count = false; } SKULike like = new SKULike(); like.UserID = Convert.ToInt32(CurrentUser.getUserId()); like.SKU = Convert.ToInt32(myItems[actualPosition].SKU); like.Liked = x; myItems[actualPosition].IsLike = x; like.WineId = myItems[actualPosition].WineId; ServiceWrapper sw = new ServiceWrapper(); await sw.InsertUpdateLike(like); }; } //ProfilePicturePickDialog pppd = new ProfilePicturePickDialog(); //string path = pppd.CreateDirectoryForPictures(); //var filePath = System.IO.Path.Combine(path + "/" + myItems[position].WineId + ".jpg"); Bitmap imageBitmap; //if (System.IO.File.Exists(filePath)) //{ // imageBitmap = BitmapFactory.DecodeFile(filePath); //} //else //{ imageBitmap = BlobWrapper.Bottleimages(myItems[position].WineId); //} //var place1 = new FrameLayout.LayoutParams(650, 650); //imgPlaceHolder.SetImageResource(Resource.Drawable.placeholder); //place1.LeftMargin = -70; //imgPlaceHolder.LayoutParameters = place1; var place = new FrameLayout.LayoutParams(650, 650); place.LeftMargin = -70; //-650 + (parent.Resources.DisplayMetrics.WidthPixels - imageBitmap.Width) / 2; imgWine.LayoutParameters = place; if (imageBitmap != null) { float ratio = (float)650 / imageBitmap.Height; imageBitmap = Bitmap.CreateScaledBitmap(imageBitmap, Convert.ToInt32(imageBitmap.Width * ratio), 650, true); //imageBitmap.Recycle(); //Canvas canvas = new Canvas(imageBitmap); //imageBitmap.EraseColor(Color.White); //canvas.DrawColor(Color.Transparent, PorterDuff.Mode.Clear); //canvas.DrawBitmap(imageBitmap, 0, 0, null); imgWine.SetImageBitmap(imageBitmap); imageBitmap.Dispose(); } else { imgWine.SetImageResource(Resource.Drawable.wine7); } txtName.Focusable = false; txtVintage.Focusable = false; txtPrice.Focusable = false; imgWine.Focusable = false; //imgPlaceHolder.Focusable = false; return(row); }
public override View GetView(int position, View convertView, ViewGroup parent) { View row = convertView; if (row == null) { row = LayoutInflater.From(myContext).Inflate(Resource.Layout.MyFavorite, null, false); } else { return(row); } TextView Name = row.FindViewById <TextView>(Resource.Id.txtNamefav); TextView Vintage = row.FindViewById <TextView>(Resource.Id.txtVintagefav); ImageView Wine = row.FindViewById <ImageView>(Resource.Id.imgWinefav); TextView Price = row.FindViewById <TextView>(Resource.Id.txtPricefav); RatingBar Avgrating = row.FindViewById <RatingBar>(Resource.Id.rtbProductRatingfav); // ImageView place = row.FindViewById<ImageView>(Resource.Id.placeholdefavr); ImageView Heart = row.FindViewById <ImageView>(Resource.Id.imgHeartfav); //String str = "lokesh"; Name.Text = myItems[position].Name; Name.InputType = Android.Text.InputTypes.TextFlagNoSuggestions; Price.Text = myItems[position].SalePrice.ToString("C", GridViewAdapter.Cultures.UnitedState); Avgrating.Rating = (float)myItems[position].AverageRating; Vintage.Text = myItems[position].Vintage.ToString(); Heart.SetImageResource(Resource.Drawable.heart_empty); var heartLP = new RelativeLayout.LayoutParams(80, 80); var metrics = myContext.Resources.DisplayMetrics; var widthInDp = ConvertPixelsToDp(metrics.WidthPixels); var heightInDp = ConvertPixelsToDp(metrics.HeightPixels); heartLP.LeftMargin = parent.Resources.DisplayMetrics.WidthPixels / 2; Heart.LayoutParameters = heartLP; bool count = Convert.ToBoolean(myItems[position].IsLike); if (count == true) { Heart.SetImageResource(Resource.Drawable.heart_full); } else { Heart.SetImageResource(Resource.Drawable.heart_empty); } Heart.Click += async delegate { bool x; if (count == false) { Heart.SetImageResource(Resource.Drawable.heart_full); x = true; count = true; } else { Heart.SetImageResource(Resource.Drawable.heart_empty); x = false; count = false; } SKULike like = new SKULike(); like.UserID = Convert.ToInt32(CurrentUser.getUserId()); like.SKU = Convert.ToInt32(myItems[position].SKU); like.Liked = x; ServiceWrapper sw = new ServiceWrapper(); like.WineId = myItems[position].WineId; await sw.InsertUpdateLike(like); }; //Bitmap imageBitmap = bvb.Bottleimages(myItems[position].WineId); // place.SetImageResource(Resource.Drawable.placeholder); ProfilePicturePickDialog pppd = new ProfilePicturePickDialog(); string path = pppd.CreateDirectoryForPictures(); //string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); var filePath = System.IO.Path.Combine(path + "/" + myItems[position].WineId + ".jpg"); Bitmap imageBitmap; if (System.IO.File.Exists(filePath)) { imageBitmap = BitmapFactory.DecodeFile(filePath); Wine.SetImageBitmap(imageBitmap); } else { imageBitmap = BlobWrapper.Bottleimages(myItems[position].WineId); Wine.SetImageBitmap(imageBitmap); } //Wine.SetImageBitmap(imageBitmap); var place1 = new RelativeLayout.LayoutParams(520, 520); // var place = new RelativeLayout.LayoutParams(520, 620); place1.LeftMargin = parent.Resources.DisplayMetrics.WidthPixels / 2 - 430; Wine.LayoutParameters = place1; var place2 = new RelativeLayout.LayoutParams(520, 520); place2.LeftMargin = parent.Resources.DisplayMetrics.WidthPixels / 2 - 430; // place.LayoutParameters = place2; //imgPlaceHolder.LayoutParameters = new RelativeLayout.LayoutParams(520, 520); //imgWine.LayoutParameters = new RelativeLayout.LayoutParams(520, 520); Name.Focusable = false; Vintage.Focusable = false; Price.Focusable = false; Wine.Focusable = false; NotifyDataSetChanged(); return(row); }
public override View GetView(int position, View convertView, ViewGroup parent) { View row = convertView; if (row == null) { row = LayoutInflater.From(myContext).Inflate(Resource.Layout.MyTastingView, null, false); //else // return convertView; if (myItems.Count == 0) { AlertDialog.Builder aler = new AlertDialog.Builder(myContext); //aler.SetTitle("No Reviews Avalilable"); aler.SetMessage("Sorry you haven't Tasted our wines"); aler.SetNegativeButton("Ok", delegate { }); LoggingClass.LogInfo("Clicked on Secaucus", screenid); Dialog dialog = aler.Create(); dialog.Show(); } else { TextView txtName = row.FindViewById <TextView>(Resource.Id.SkuName); TextView txtYear = row.FindViewById <TextView>(Resource.Id.Vintage); TextView txtDescription = row.FindViewById <TextView>(Resource.Id.TastingNotes); TextView txtDate = row.FindViewById <TextView>(Resource.Id.Date); TextView txtPrice = row.FindViewById <TextView>(Resource.Id.Price); ImageView heartImg = row.FindViewById <ImageView>(Resource.Id.imageButton4); ImageButton wineimage = row.FindViewById <ImageButton>(Resource.Id.imageButton2); RatingBar rb = row.FindViewById <RatingBar>(Resource.Id.AvgRating); heartImg.SetImageResource(Resource.Drawable.Heart_emp); txtDate.SetTextSize(Android.Util.ComplexUnitType.Dip, 12); txtName.Text = myItems[position].Name; txtName.InputType = Android.Text.InputTypes.TextFlagNoSuggestions; txtYear.Text = myItems[position].Vintage.ToString(); txtDescription.Text = myItems[position].Description; txtDate.Text = myItems[position].TastingDate.ToString(); txtPrice.Text = myItems[position].SalePrice.ToString("C", GridViewAdapter.Cultures.UnitedState); rb.Rating = (float)myItems[position].AverageRating; //Bitmap imageBitmap = bvb.Bottleimages(myItems[position].WineId); ProfilePicturePickDialog pppd = new ProfilePicturePickDialog(); string path = pppd.CreateDirectoryForPictures(); //string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); var filePath = System.IO.Path.Combine(path + "/" + myItems[position].Barcode + ".jpg"); bool count = Convert.ToBoolean(myItems[position].IsLike); if (count == true) { heartImg.SetImageResource(Resource.Drawable.HeartFull); } else { heartImg.SetImageResource(Resource.Drawable.Heart_emp); } heartImg.Tag = position; if (convertView == null) { heartImg.Click += async delegate { int actualPosition = Convert.ToInt32(heartImg.Tag); bool x; if (count == false) { heartImg.SetImageResource(Resource.Drawable.HeartFull); LoggingClass.LogInfoEx("Liked an item------>" + myItems[position].Barcode, screenid); x = true; count = true; } else { heartImg.SetImageResource(Resource.Drawable.Heart_emp); LoggingClass.LogInfoEx("UnLiked an item" + "----->" + myItems[position].Barcode, screenid); x = false; count = false; } SKULike like = new SKULike(); like.UserID = Convert.ToInt32(CurrentUser.getUserId()); like.SKU = Convert.ToInt32(myItems[actualPosition].SKU); like.Liked = x; myItems[actualPosition].IsLike = x; like.BarCode = myItems[actualPosition].Barcode; LoggingClass.LogInfo("Liked an item", screenid); ServiceWrapper sw = new ServiceWrapper(); await sw.InsertUpdateLike(like); }; } Bitmap imageBitmap; if (System.IO.File.Exists(filePath)) { imageBitmap = BitmapFactory.DecodeFile(filePath); wineimage.SetImageBitmap(imageBitmap); } else { imageBitmap = BlobWrapper.Bottleimages(myItems[position].Barcode, myItems[position].Vintage); wineimage.SetImageBitmap(imageBitmap); } wineimage.SetScaleType(ImageView.ScaleType.CenterCrop); txtName.Focusable = false; txtYear.Focusable = false; txtDescription.Focusable = false; txtDate.Focusable = false; } } LoggingClass.LogInfo("Entered into My tastings Adapter", screenid); return(row); }
public void BindData(APLCollectionViewCell cell, NSIndexPath indexPath, Boolean fav) { try { cell.NavigationController = NavigationController; //cell.btlImage.SetBackgroundImage(UIImage.FromFile("Wines/wine" + indexPath.Item % 8 + ".png"), UIControlState.Normal); cell.parent = this.View; //NavigationController.NavigationBar.TopItem.Title = "Locations"; int index = (int)indexPath.Item; //Data from Model //cell.WineName = myData.ItemList[index].Name; //cell.AmountLeft.SetProgress(Convert.ToSingle(myData.ItemList[index].AvailableVolume),true); double l = Math.Floor(Math.Log10(myData.ItemList[index].Vintage) + 1); if (l > 4) { cell.Vintage = ""; } else { cell.Vintage = myData.ItemList[index].Vintage.ToString(); } cell.AmountLeft.Text = "Wine left in bottle: " + myData.ItemList[index].AvailableVolume.ToString() + ".ml"; cell.RegPrice = myData.ItemList[index].SalePrice.ToString(); cell.averageRating = (decimal)myData.ItemList[index].AverageRating; cell.WineBarcode = myData.ItemList[index].Barcode; //cell.btnBuy.TouchUpInside+= delegate { // UIApplication.SharedApplication.OpenUrl(new NSUrl("http://www.wineoutlet.com/sku"+myData.ItemList[index].SKU+".html")); //}; cell.Sku = myData.ItemList[index].SKU; if (fav == true) { cell.storeId = myData.ItemList[index].PlantFinal.ToString(); cell.AmountLeft.Hidden = true; } else { cell.storeId = storeId.ToString(); } cell.lblName.Text = myData.ItemList[index].Name; if (myData.ItemList[index].Vintage.ToString().Length < 4) { cell.lblYear.Text = " "; } else { cell.lblYear.Text = myData.ItemList[index].Vintage.ToString(); } cell.lblRegPrice.Text = myData.ItemList[index].RegPrice.ToString("C", Cultures.UnitedState); cell.ratingView.AverageRating = (decimal)myData.ItemList[index].AverageRating; cell.myItem = myData.ItemList[index]; //Boolean temp; SKULike like = new SKULike(); ServiceWrapper sw = new ServiceWrapper(); cell.btnItemname.SetTitle(myData.ItemList[index].Name, UIControlState.Normal); if (myData.ItemList[index].IsLike == true) { cell.heartImage.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal); cell.heartImage.Tag = 1; //cell.heartImage.TouchUpInside +=async delegate //{ // if (CurrentUser.RetreiveUserId() != 0) // { // cell.heartImage.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal); // like.UserID = Convert.ToInt32(CurrentUser.RetreiveUserId()); // like.BarCode = cell.WineBarcode; // like.Liked = false; // await sw.InsertUpdateLike(like); // } // else // { // UIAlertView alert = new UIAlertView() // { // Title = "This feature is allowed only for VIP Card holders", // //Message = "Coming Soon..." // }; // alert.AddButton("OK"); // alert.AddButton("Know more"); // alert.Clicked += (senderalert, buttonArgs) => // { // if (buttonArgs.ButtonIndex == 1) // { // UIApplication.SharedApplication.OpenUrl(new NSUrl("http://savvyitdev.com/winehangouts/")); // } // }; // alert.Show(); // } //}; } else { cell.heartImage.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal); cell.heartImage.Tag = 0; //cell.heartImage.TouchUpInside +=async delegate //{ // if (CurrentUser.RetreiveUserId() != 0) // { // cell.heartImage.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal); // like.UserID = Convert.ToInt32(CurrentUser.RetreiveUserId()); // like.BarCode = cell.WineBarcode; // like.Liked = true; // await sw.InsertUpdateLike(like); // } // else // { // UIAlertView alert = new UIAlertView() // { // Title = "This feature is allowed only for VIP Card holders", // //Message = "Coming Soon..." // }; // alert.AddButton("OK"); // alert.AddButton("Know more"); // alert.Clicked += (senderalert, buttonArgs) => // { // if (buttonArgs.ButtonIndex == 1) // { // UIApplication.SharedApplication.OpenUrl(new NSUrl("http://savvyitdev.com/winehangouts/")); // } // }; // alert.Show(); // } //}; } //UIImage image = BlobWrapper.GetImageBitmapFromWineId(myData.ItemList[index].WineId.ToString()); string url = myData.ItemList[index].SmallImageUrl; if (url == null) { url = myData.ItemList[index].Barcode + ".jpg"; } UIImage image = BlobWrapper.GetResizedImage(url, cell.btlImage.Bounds, cell.storeId.ToString()); if (image != null) { cell.btlImage.SetImage(image, UIControlState.Normal); } else { cell.btlImage.SetImage(img, UIControlState.Normal); } } catch (Exception ex) { LoggingClass.LogError(ex.Message, screen, ex.StackTrace.ToString()); UIAlertView alert = new UIAlertView() { Title = "Something went wrong. We are on it." //Message = "Coming Soon..." }; alert.AddButton("OK"); alert.Show(); } }
public override View GetView(int position, View convertView, ViewGroup parent) { ////////////// View row = convertView; ////////////// if (row == null) ////////////// row = LayoutInflater.From(myContext).Inflate(Resource.Layout.MyFavorite, null, false); ////////////// else ////////////// return row; ////////////// if (myItems.Count == 0) ////////////// { ////////////// AlertDialog.Builder aler = new AlertDialog.Builder(myContext); ////////////// aler.SetTitle("No Reviews Avalilable"); ////////////// aler.SetMessage("Sorry you didn't tell us your Favourite wines"); ////////////// aler.SetNegativeButton("Ok", delegate { }); ////////////// LoggingClass.LogInfo("Clicked on Secaucus", screenid); ////////////// Dialog dialog = aler.Create(); ////////////// dialog.Show(); ////////////// } ////////////// else ////////////// { ////////////// TextView Name = row.FindViewById<TextView>(Resource.Id.txtNamefav); ////////////// TextView Vintage = row.FindViewById<TextView>(Resource.Id.txtVintagefav); ////////////// ImageView Wine = row.FindViewById<ImageView>(Resource.Id.imgWinefav); ////////////// TextView Price = row.FindViewById<TextView>(Resource.Id.txtPricefav); ////////////// RatingBar Avgrating = row.FindViewById<RatingBar>(Resource.Id.rtbProductRatingfav); ////////////// //ImageView place = row.FindViewById<ImageView>(Resource.Id.placeholdefavr); ////////////// ImageView Heart = row.FindViewById<ImageView>(Resource.Id.imgHeartfav); ////////////// String str = "lokesh"; ////////////// Name.Text = myItems[position].Name; ////////////// Price.Text = myItems[position].SalePrice.ToString("C", GridViewAdapter.Cultures.UnitedState); ////////////// Avgrating.Rating = (float)myItems[position].AverageRating; ////////////// Vintage.Text = myItems[position].Vintage.ToString(); ////////////// Heart.SetImageResource(Resource.Drawable.Heart_emp); ////////////// var heartLP = new RelativeLayout.LayoutParams(80, 80); ////////////// var metrics = myContext.Resources.DisplayMetrics; ////////////// var widthInDp = ConvertPixelsToDp(metrics.WidthPixels); ////////////// var heightInDp = ConvertPixelsToDp(metrics.HeightPixels); ////////////// heartLP.LeftMargin = parent.Resources.DisplayMetrics.WidthPixels / 2 - 110; // 110 = 80 + 30 ////////////// heartLP.TopMargin = 5; ////////////// Heart.LayoutParameters = heartLP; ////////////// bool count = Convert.ToBoolean(myItems[position].IsLike); ////////////// if (count == true) ////////////// { ////////////// Heart.SetImageResource(Resource.Drawable.HeartFull); ////////////// } ////////////// else ////////////// { ////////////// Heart.SetImageResource(Resource.Drawable.Heart_emp); ////////////// } ////////////// Heart.Click += async delegate ////////////// { ////////////// bool x; ////////////// if (count == false) ////////////// { ////////////// Heart.SetImageResource(Resource.Drawable.HeartFull); ////////////// LoggingClass.LogInfo("Liked an item" + myItems[position].WineId, screenid); ////////////// x = true; ////////////// count = true; ////////////// } ////////////// else ////////////// { ////////////// Heart.SetImageResource(Resource.Drawable.heart_empty); ////////////// LoggingClass.LogInfo("UnLiked an item" + myItems[position].WineId, screenid); ////////////// x = false; ////////////// count = false; ////////////// } ////////////// SKULike like = new SKULike(); ////////////// like.UserID = Convert.ToInt32(CurrentUser.getUserId()); ////////////// like.SKU = Convert.ToInt32(myItems[position].SKU); ////////////// like.Liked = x; ////////////// ServiceWrapper sw = new ServiceWrapper(); ////////////// LoggingClass.LogInfo("Liked an item" + myItems[position].WineId, screenid); ////////////// like.WineId = myItems[position].WineId; ////////////// await sw.InsertUpdateLike(like); ////////////// }; ////////////// ////////////////Bitmap imageBitmap = bvb.Bottleimages(myItems[position].WineId); ////////////// //////////////// place.SetImageResource(Resource.Drawable.placeholder); ////////////// //////////////ProfilePicturePickDialog pppd = new ProfilePicturePickDialog(); ////////////// //////////////string path = pppd.CreateDirectoryForPictures(); ////////////// ////////////////string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); ////////////// //////////////var filePath = System.IO.Path.Combine(path + "/" + myItems[position].WineId + ".jpg"); ////////////// //Bitmap imageBitmap; ////////////// Bitmap imageBitmap; ////////////// imageBitmap = BlobWrapper.Bottleimages(myItems[position].WineId, myItems[position].PlantFinal); ////////////// //if (System.IO.File.Exists(filePath)) ////////////// //{ ////////////// // imageBitmap = BitmapFactory.DecodeFile(filePath); ////////////// // Wine.SetImageBitmap(imageBitmap); ////////////// //} ////////////// //else ////////////// { ////////////// imageBitmap = BlobWrapper.Bottleimages(myItems[position].WineId, myItems[position].PlantFinal); ////////////// Wine.SetImageBitmap(imageBitmap); ////////////// } ////////////// //Wine.SetImageBitmap(imageBitmap); ////////////// var place1 = new RelativeLayout.LayoutParams(620, 620); ////////////// var place = new RelativeLayout.LayoutParams(620, 620); ////////////// //place1.LeftMargin = parent.Resources.DisplayMetrics.WidthPixels / 2 - 430; ////////////// Wine.LayoutParameters = place1; ////////////// //var place2 = new RelativeLayout.LayoutParams(620, 620); ////////////// //place2.LeftMargin = parent.Resources.DisplayMetrics.WidthPixels / 2 - 430; ////////////// //place.LayoutParameters = place2; ////////////// //imgPlaceHolder.LayoutParameters = new RelativeLayout.LayoutParams(520, 520); ////////////// //Wine.LayoutParameters = new RelativeLayout.LayoutParams(520, 520); ////////////// if (imageBitmap != null) ////////////// { ////////////// if (heartLP.LeftMargin <= 250) ////////////// { ////////////// place1.LeftMargin = -140; ////////////// float ratio = (float)500 / imageBitmap.Height; ////////////// imageBitmap = Bitmap.CreateScaledBitmap(imageBitmap, Convert.ToInt32(imageBitmap.Width * ratio), 550, true); ////////////// } ////////////// else ////////////// { ////////////// place1.LeftMargin = -70; ////////////// float ratio = (float)650 / imageBitmap.Height; ////////////// imageBitmap = Bitmap.CreateScaledBitmap(imageBitmap, Convert.ToInt32(imageBitmap.Width * ratio), 650, true); ////////////// } ////////////// Wine.SetImageBitmap(imageBitmap); ////////////// imageBitmap.Dispose(); ////////////// } ////////////// else ////////////// { ////////////// Wine.SetImageResource(Resource.Drawable.wine7); ////////////// } ////////////// Name.Focusable = false; ////////////// Vintage.Focusable = false; ////////////// Price.Focusable = false; ////////////// Wine.Focusable = false; ////////////// Wine.Dispose(); ////////////// Heart.Dispose(); ////////////// heartLP.Dispose(); ////////////// NotifyDataSetChanged(); ////////////// LoggingClass.LogInfo("Entered into my fav Adapter", screenid); ////////////// } ////////////// return row; ////////////// } ////////////// private int ConvertPixelsToDp(float pixelValue) ////////////// { ////////////// var dp = (int)((pixelValue) / myContext.Resources.DisplayMetrics.Density); ////////////// return dp; ////////////// } ////////////// } //////////////} View row = convertView; if (row == null) { row = LayoutInflater.From(myContext).Inflate(Resource.Layout.MyFavorite, null, false); } //else // return row; TextView txtName = row.FindViewById <TextView>(Resource.Id.txtName); TextView txtVintage = row.FindViewById <TextView>(Resource.Id.txtVintage); TextView txtPrice = row.FindViewById <TextView>(Resource.Id.txtPrice); ImageView imgWine = row.FindViewById <ImageView>(Resource.Id.imgWine); ImageView heartImg = row.FindViewById <ImageView>(Resource.Id.imgHeart); RatingBar rating = row.FindViewById <RatingBar>(Resource.Id.rtbProductRating); rating.Rating = (float)myItems[position].AverageRating; txtName.Text = myItems[position].Name; txtPrice.Text = myItems[position].SalePrice.ToString("C", Cultures.UnitedState); txtVintage.Text = myItems[position].Vintage.ToString(); heartImg.SetImageResource(Resource.Drawable.Heart_emp); var heartLP = new FrameLayout.LayoutParams(80, 80); var metrics = myContext.Resources.DisplayMetrics; var widthInDp = ConvertPixelsToDp(metrics.WidthPixels); var heightInDp = ConvertPixelsToDp(metrics.HeightPixels); heartLP.LeftMargin = parent.Resources.DisplayMetrics.WidthPixels / 2 - 110; // 110 = 80 + 30 heartLP.TopMargin = 5; heartImg.LayoutParameters = heartLP; heartImg.Layout(50, 50, 50, 50); bool count = Convert.ToBoolean(myItems[position].IsLike); if (count == true) { heartImg.SetImageResource(Resource.Drawable.HeartFull); } else { heartImg.SetImageResource(Resource.Drawable.Heart_emp); } heartImg.Tag = position; if (convertView == null) { heartImg.Click += async delegate { int actualPosition = Convert.ToInt32(heartImg.Tag); bool x; if (count == false) { heartImg.SetImageResource(Resource.Drawable.HeartFull); LoggingClass.LogInfoEx("Liked an item----->" + myItems[position].Barcode, screenid); x = true; count = true; } else { heartImg.SetImageResource(Resource.Drawable.Heart_emp); LoggingClass.LogInfoEx("UnLiked an item---->" + myItems[position].Barcode, screenid); x = false; count = false; } SKULike like = new SKULike(); like.UserID = Convert.ToInt32(CurrentUser.getUserId()); like.SKU = Convert.ToInt32(myItems[actualPosition].SKU); like.Liked = x; myItems[actualPosition].IsLike = x; like.BarCode = myItems[actualPosition].Barcode; LoggingClass.LogInfo("Liked an item", screenid); //myItems[position].pl ServiceWrapper sw = new ServiceWrapper(); await sw.InsertUpdateLike(like); }; } Bitmap imageBitmap; imageBitmap = BlobWrapper.Bottleimages(myItems[position].Barcode, storeid); var place = new FrameLayout.LayoutParams(650, 650); //-650 + (parent.Resources.DisplayMetrics.WidthPixels - imageBitmap.Width) / 2; imgWine.LayoutParameters = place; if (imageBitmap != null) { if (heartLP.LeftMargin <= 250) { place.LeftMargin = -140; float ratio = (float)500 / imageBitmap.Height; imageBitmap = Bitmap.CreateScaledBitmap(imageBitmap, Convert.ToInt32(imageBitmap.Width * ratio), 550, true); } else { place.LeftMargin = -70; float ratio = (float)650 / imageBitmap.Height; imageBitmap = Bitmap.CreateScaledBitmap(imageBitmap, Convert.ToInt32(imageBitmap.Width * ratio), 650, true); } imgWine.SetImageBitmap(imageBitmap); } else { imgWine.SetImageResource(Resource.Drawable.bottle); } txtName.Focusable = false; txtVintage.Focusable = false; txtPrice.Focusable = false; imgWine.Focusable = false; imgWine.Dispose(); return(row); }
public override View GetView(int position, View convertView, ViewGroup parent) { View row = convertView; if (row == null) { row = LayoutInflater.From(myContext).Inflate(Resource.Layout.MyFavorite, null, false); } TextView txtName = row.FindViewById <TextView>(Resource.Id.txtName); TextView txtVintage = row.FindViewById <TextView>(Resource.Id.txtVintage); TextView txtPrice = row.FindViewById <TextView>(Resource.Id.txtPrice); ImageView imgWine = row.FindViewById <ImageView>(Resource.Id.imgWine); ImageView heartImg = row.FindViewById <ImageView>(Resource.Id.imgHeart); RatingBar rating = row.FindViewById <RatingBar>(Resource.Id.rtbProductRating); rating.Rating = (float)myItems[position].AverageRating; txtName.Text = myItems[position].Name; txtPrice.Text = myItems[position].SalePrice.ToString("C", Cultures.UnitedState); txtVintage.Text = myItems[position].Vintage.ToString(); if (txtVintage.Text == "0" || txtVintage.Text == null) { txtVintage.Text = ""; } else { txtVintage.Text = myItems[position].Vintage.ToString(); } heartImg.SetImageResource(Resource.Drawable.heart_empty); bool count = Convert.ToBoolean(myItems[position].IsLike); if (count == true) { heartImg.SetImageResource(Resource.Drawable.heart_full); } else { heartImg.SetImageResource(Resource.Drawable.heart_empty); } heartImg.Tag = position; if (convertView == null) { heartImg.Click += delegate { int actualPosition = Convert.ToInt32(heartImg.Tag); bool x; if (count == false) { heartImg.SetImageResource(Resource.Drawable.heart_full); x = true; count = true; } else { heartImg.SetImageResource(Resource.Drawable.heart_empty); x = false; count = false; } var TaskA = new System.Threading.Tasks.Task(async() => { SKULike like = new SKULike(); like.UserID = Convert.ToInt32(CurrentUser.getUserId()); like.SKU = Convert.ToInt32(myItems[actualPosition].SKU); like.Liked = x; myItems[actualPosition].IsLike = x; like.BarCode = myItems[actualPosition].Barcode; ServiceWrapper sw = new ServiceWrapper(); await sw.InsertUpdateLike(like); }); TaskA.Start(); }; } Bitmap imageBitmap; string url = myItems[position].SmallImageUrl; if (url == null || url == "") { url = myItems[position].Barcode + ".jpg"; } imageBitmap = BlobWrapper.Bottleimages(url, storeid); if (imageBitmap != null) { float ratio = (float)400 / imageBitmap.Height; imageBitmap = Bitmap.CreateScaledBitmap(imageBitmap, Convert.ToInt32(imageBitmap.Width * ratio), 400, true); imgWine.SetImageBitmap(imageBitmap); } else { imgWine.SetImageResource(Resource.Drawable.bottle); } txtName.Focusable = false; txtVintage.Focusable = false; txtPrice.Focusable = false; imgWine.Focusable = false; imgWine.Dispose(); return(row); }
public int InsertUpdateSKULike(SKULike skuLike) { IItemDBManager itemDBManager = new ItemDBManager(); return(itemDBManager.InsertUpdateSKULike(skuLike)); }
public override View GetView(int position, View convertView, ViewGroup parent) { View row = convertView; if (myItems.Count == 0) { row = LayoutInflater.From(myContext).Inflate(Resource.Layout.ReviewEmpty, null, false); TextView txtName = row.FindViewById <TextView>(Resource.Id.textView1); ImageView Imag = row.FindViewById <ImageView>(Resource.Id.imageView1); // AlertDialog.Builder aler = new AlertDialog.Builder(myContext); ////aler.SetTitle("No Reviews Avalilable"); //aler.SetMessage("Sorry you haven't Reviewed our wines"); //aler.SetNegativeButton("Ok", delegate { }); //LoggingClass.LogInfo("Clicked on Secaucus", screenid); //Dialog dialog = aler.Create(); //dialog.Show(); } else { if (row == null) { row = LayoutInflater.From(myContext).Inflate(Resource.Layout.MyReviewsCell, null, false); //else // return convertView; TextView txtName = row.FindViewById <TextView>(Resource.Id.textView64); TextView txtYear = row.FindViewById <TextView>(Resource.Id.textView65); TextView txtDescription = row.FindViewById <TextView>(Resource.Id.textView66); TextView txtDate = row.FindViewById <TextView>(Resource.Id.textView67); //TextView txtPrice = row.FindViewById<TextView>(Resource.Id.txtPrice); ImageButton edit = row.FindViewById <ImageButton>(Resource.Id.imageButton3); ImageButton delete = row.FindViewById <ImageButton>(Resource.Id.imageButton4); ImageButton wineimage = row.FindViewById <ImageButton>(Resource.Id.imageButton2); var metrics = myContext.Resources.DisplayMetrics; var widthInDp = ConvertPixelsToDp(metrics.WidthPixels); var heightInDp = ConvertPixelsToDp(metrics.HeightPixels); RatingBar rb = row.FindViewById <RatingBar>(Resource.Id.rating); ImageView heartImg = row.FindViewById <ImageView>(Resource.Id.imageButton44); heartImg.SetImageResource(Resource.Drawable.Heart_emp); //edit.SetScaleType(ImageView.ScaleType.Center); //delete.SetScaleType(ImageView.ScaleType.Center); //edit.SetImageResource(Resource.Drawable.edit); //delete.SetImageResource(Resource.Drawable.delete); edit.Focusable = false; //edit.FocusableInTouchMode = false; edit.Clickable = true; delete.Focusable = false; //delete.FocusableInTouchMode = false; delete.Clickable = true; wineimage.Focusable = false; wineimage.FocusableInTouchMode = false; wineimage.Clickable = true; //TextView txtPrice = row.FindViewById<TextView>(Resource.Id.txtPrice); //ImageView imgWine = row.FindViewById<ImageView>(Resource.Id.imgWine); //edit.SetTag(1, 5757); edit.Click += (sender, args) => { string WineBarcode = myItems[position].Barcode; Review _review = new Review(); _review.Barcode = WineBarcode; _review.RatingStars = myItems[position].RatingStars; _review.RatingText = myItems[position].RatingText; _review.PlantFinal = myItems[position].PlantFinal; LoggingClass.LogInfo("clicked on edit an item---->" + WineBarcode + "----->" + _review.RatingStars + "---->" + _review.RatingText, screenid); PerformItemClick(sender, args, _review); }; //delete.Click += Delete_Click; delete.Click += (sender, args) => { string WineBarcode = myItems[position].Barcode; Review _review = new Review(); _review.Barcode = WineBarcode; LoggingClass.LogInfo("clicked on delete item--->" + WineBarcode, screenid); PerformdeleteClick(sender, args, _review); }; wineimage.Click += (sender, args) => Console.WriteLine("ImageButton {0} clicked", position); txtDate.SetTextSize(Android.Util.ComplexUnitType.Dip, 12); txtName.Text = myItems[position].Name; // txtName.InputType = Android.Text.InputTypes.TextFlagNoSuggestions; // txtPrice.Text= myItems[position]. txtYear.Text = myItems[position].Vintage; txtDescription.Text = myItems[position].RatingText; //txtDescription.InputType = Android.Text.InputTypes.TextFlagNoSuggestions; txtDate.Text = myItems[position].Date.ToString("dd/MM/yyyy"); rb.Rating = myItems[position].RatingStars; //Bitmap imageBitmap = bvb.Bottleimages(myItems[position].WineId); ProfilePicturePickDialog pppd = new ProfilePicturePickDialog(); string path = pppd.CreateDirectoryForPictures(); //string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); var filePath = System.IO.Path.Combine(path + "/" + myItems[position].Barcode + ".jpg"); bool count = Convert.ToBoolean(myItems[position].Liked); if (count == true) { heartImg.SetImageResource(Resource.Drawable.HeartFull); } else { heartImg.SetImageResource(Resource.Drawable.Heart_emp); } heartImg.Tag = position; if (convertView == null) { heartImg.Click += async delegate { int actualPosition = Convert.ToInt32(heartImg.Tag); bool x; if (count == false) { heartImg.SetImageResource(Resource.Drawable.HeartFull); LoggingClass.LogInfoEx("Liked an item------>" + myItems[position].Barcode, screenid); x = true; count = true; } else { heartImg.SetImageResource(Resource.Drawable.Heart_emp); LoggingClass.LogInfoEx("UnLiked an item" + "----->" + myItems[position].Barcode, screenid); x = false; count = false; } SKULike like = new SKULike(); like.UserID = Convert.ToInt32(CurrentUser.getUserId()); like.SKU = Convert.ToInt32(myItems[actualPosition].SKU); like.Liked = x; //myItems[actualPosition].IsLike = x; like.BarCode = myItems[actualPosition].Barcode; LoggingClass.LogInfo("Liked an item", screenid); ServiceWrapper sw = new ServiceWrapper(); await sw.InsertUpdateLike(like); }; } Bitmap imageBitmap; if (System.IO.File.Exists(filePath)) { imageBitmap = BitmapFactory.DecodeFile(filePath); wineimage.SetImageBitmap(imageBitmap); } else { imageBitmap = BlobWrapper.Bottleimages(myItems[position].Barcode, Convert.ToInt32(myItems[position].PlantFinal)); wineimage.SetImageBitmap(imageBitmap); } //wineimage.SetImageBitmap(imageBitmap); //wineimage.SetImageResource(Resource.Drawable.wine7); wineimage.SetScaleType(ImageView.ScaleType.CenterCrop); txtName.Focusable = false; txtYear.Focusable = false; txtDescription.Focusable = false; txtDate.Focusable = false; } } LoggingClass.LogInfo("Entered into My Review Adapter", screenid); return(row); }
public MyReviewCellView(NSString cellId) : base(UITableViewCellStyle.Default, cellId) { try { btnBack = new UIButton(); btnBack.BackgroundColor = UIColor.FromRGB(63, 63, 63); btnBack.UserInteractionEnabled = false; SelectionStyle = UITableViewCellSelectionStyle.Gray; imageView = new UIButton(); imageView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth; imageView.ContentMode = UIViewContentMode.Center; imageView.ClipsToBounds = true; //imageView.TouchDown += (object sender, EventArgs e) => //{ // BTProgressHUD.Show("Loading..."); //}; imageView.TouchUpInside += (object sender, EventArgs e) => { BTProgressHUD.Show(LoggingClass.txtloading); NavController.PushViewController(new DetailViewController(WineIdLabel.Text, storeid.ToString(), false, true), false); }; Review review = new Review(); separator = new UIImageView(); btnItemname = new UIButton(); btnItemname.SetTitle("", UIControlState.Normal); btnItemname.SetTitleColor(UIColor.FromRGB(127, 51, 0), UIControlState.Normal); btnItemname.Font = UIFont.FromName("Verdana-Bold", 13f); btnItemname.LineBreakMode = UILineBreakMode.WordWrap; btnItemname.HorizontalAlignment = UIControlContentHorizontalAlignment.Left; btnItemname.TouchUpInside += delegate { BTProgressHUD.Show("Loading..."); NavController.PushViewController(new DetailViewController(WineIdLabel.Text, storeid.ToString(), false, true), false); }; ReviewDate = new UILabel() { Font = UIFont.FromName("AmericanTypewriter", 10f), TextColor = UIColor.FromRGB(38, 127, 200), //TextAlignment = UITextAlignment.Center, BackgroundColor = UIColor.Clear }; Comments = new UITextView() { Font = UIFont.FromName("AmericanTypewriter", 14f), TextColor = UIColor.FromRGB(55, 127, 0), TextAlignment = UITextAlignment.Justified, //TextAlignment = UITextAlignment.Natural, BackgroundColor = UIColor.Clear, //LineBreakMode = UILineBreakMode.WordWrap Editable = false, Selectable = false }; ReadMore = new UIButton() { Font = UIFont.FromName("Verdana", 10f), BackgroundColor = UIColor.White }; Vintage = new UILabel() { Font = UIFont.FromName("Verdana", 10f), TextColor = UIColor.FromRGB(127, 51, 100), BackgroundColor = UIColor.Clear }; decimal averageRating = 0.0m; var ratingConfig = new RatingConfig(emptyImage: UIImage.FromBundle("Stars/star-silver2.png"), filledImage: UIImage.FromBundle("Stars/star.png"), chosenImage: UIImage.FromBundle("Stars/star.png")); stars = new PDRatingView(new CGRect(110, 60, 60, 20), ratingConfig, averageRating); btnEdit = new UIButton(); btnEdit.SetImage(UIImage.FromFile("edit.png"), UIControlState.Normal); btnEdit.TouchUpInside += (sender, e) => { PopupView yourController = new PopupView(WineIdLabel.Text, storeid); yourController.NavController = NavController; yourController.parent = Parent; yourController.StartsSelected = stars.AverageRating; yourController.Comments = Comments.Text; LoggingClass.LogInfo("Edited the review of " + wineId, screenid); //yourController.WineId = Convert.ToInt32(WineIdLabel.Text); yourController.ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext; //this.PresentViewController(yourController, true, null); Parent.PresentModalViewController(yourController, false); }; btnDelete = new UIButton(); btnDelete.SetImage(UIImage.FromFile("delete.png"), UIControlState.Normal); btnDelete.TouchUpInside += (sender, e) => { UIAlertView alert = new UIAlertView() { Title = "Delete Review ", Message = LoggingClass.txtdeletereview, }; alert.AddButton("Yes"); alert.AddButton("No"); alert.Clicked += async(senderalert, buttonArgs) => { if (buttonArgs.ButtonIndex == 0) { review.Barcode = WineIdLabel.Text; review.ReviewUserId = Convert.ToInt32(CurrentUser.RetreiveUserId()); BTProgressHUD.Show("Deleting review"); await sw.DeleteReview(review); LoggingClass.LogInfo("Deleting the review of " + wineId, screenid); BTProgressHUD.ShowSuccessWithStatus("Done"); ((IPopupParent)Parent).RefreshParent(); } }; alert.Show(); }; btnLike = new UIButton(); btnLike.ClipsToBounds = true; btnLike.Layer.BorderColor = UIColor.White.CGColor; btnLike.Layer.EdgeAntialiasingMask = CAEdgeAntialiasingMask.LeftEdge | CAEdgeAntialiasingMask.RightEdge | CAEdgeAntialiasingMask.BottomEdge | CAEdgeAntialiasingMask.TopEdge; btnLike.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal); btnLike.Tag = 0; //myItem = new Item(); //bool count =Convert.ToBoolean( myItem.IsLike); //if (count == true) //{ //btnLike.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal);} //else //{ // btnLike.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal); //} btnLike.TouchUpInside += async(object sender, EventArgs e) => { try { UIButton temp = (UIButton)sender; if (temp.Tag == 0) { btnLike.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal); temp.Tag = 1; Data.Liked = 1; //btnLike.Tag = 1; LoggingClass.LogInfo("Liked Wine " + WineIdLabel.Text, screenid); } else { btnLike.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal); temp.Tag = 0; Data.Liked = 0; LoggingClass.LogInfo("Unliked Wine " + WineIdLabel.Text, screenid); } SKULike like = new SKULike(); like.UserID = Convert.ToInt32(CurrentUser.RetreiveUserId()); like.BarCode = WineIdLabel.Text; like.Liked = Convert.ToBoolean(temp.Tag); Data.Liked = Convert.ToInt32(temp.Tag); await sw.InsertUpdateLike(like); } catch (Exception ex) { LoggingClass.LogError(ex.Message, screenid, ex.StackTrace); } }; WineIdLabel = new UILabel(); ContentView.AddSubviews(new UIView[] { btnBack, btnItemname, ReadMore, ReviewDate, Comments, stars, imageView, Vintage, separator, btnEdit, btnDelete, btnLike }); } catch (Exception ex) { LoggingClass.LogError(ex.ToString(), screenid, ex.StackTrace); } }
public int InsertUpdateLike(SKULike skuLike) { IItemService itemService = new ItemService(); return(itemService.InsertUpdateSKULike(skuLike)); }