public void setListViewHeightBasedOnChildren1(ListView listView1) { reviewAdapter listAdapter = (reviewAdapter)listView1.Adapter; if (listAdapter == null) { return; } int desiredWidth = View.MeasureSpec.MakeMeasureSpec(listView1.Width, MeasureSpecMode.Unspecified); int heightMeasureSpec = View.MeasureSpec.MakeMeasureSpec(ViewGroup.LayoutParams.WrapContent, MeasureSpecMode.Exactly); int totalHeight = 0; View view = null; for (int i = 0; i < listAdapter.Count; i++) { view = listAdapter.GetView(i, view, listView1); if (i == 0) { view.LayoutParameters = new ViewGroup.LayoutParams(desiredWidth, WindowManagerLayoutParams.WrapContent); } view.Measure(desiredWidth, heightMeasureSpec); totalHeight += view.MeasuredHeight; } ViewGroup.LayoutParams params1 = listView1.LayoutParameters; params1.Height = totalHeight + (listView1.DividerHeight * (listAdapter.Count - 1)); listView1.LayoutParameters = params1; }
public void RefreshParent() { ServiceWrapper svc = new ServiceWrapper(); //int wineid = Intent.GetIntExtra("WineID", 138); ItemDetailsResponse myData = svc.GetItemDetails(WineBarcode, storeid).Result; var SkuRating = svc.GetItemReviewsByWineBarcode(WineBarcode).Result; comments = new reviewAdapter(this, SkuRating.Reviews.ToList()); commentsview.Adapter = comments; comments.NotifyDataSetChanged(); }
public void RefreshParent() { ServiceWrapper svc = new ServiceWrapper(); int wineid = Intent.GetIntExtra("WineID", 138); ItemDetailsResponse myData = svc.GetItemDetails(wineid).Result; var SkuRating = svc.GetItemReviewsByWineID(wineid).Result; this.Title = "Wine Details"; var commentsView = FindViewById <ListView>(Resource.Id.listView2); reviewAdapter comments = new reviewAdapter(this, SkuRating.Reviews.ToList()); commentsView.Adapter = comments; comments.NotifyDataSetChanged(); }
public void Internal_ViewDidLoad() { try { WineBarcode = Intent.GetStringExtra("WineBarcode"); storeid = Intent.GetIntExtra("storeid", 1); ActionBar.SetHomeButtonEnabled(true); ActionBar.SetDisplayHomeAsUpEnabled(true); ServiceWrapper svc = new ServiceWrapper(); myData = new ItemDetailsResponse(); ItemReviewResponse SkuRating = new ItemReviewResponse(); this.Title = "Wine Details"; try { DownloadAsync(this, System.EventArgs.Empty, WineBarcode); myData = svc.GetItemDetails(WineBarcode, storeid).Result; SkuRating = svc.GetItemReviewsByWineBarcode(WineBarcode).Result; ReviewArray = SkuRating.Reviews.ToList(); var tempReview = SkuRating.Reviews.ToList().Find(x => x.ReviewUserId == Convert.ToInt32(CurrentUser.getUserId())); if (tempReview != null) { editPopup._editObj.RatingText = tempReview.RatingText; } comments = new reviewAdapter(this, ReviewArray); if (comments.Count == 0) { ErrorDescription.Visibility = ViewStates.Visible; ErrorDescription.Text = SkuRating.ErrorDescription; ErrorDescription.SetTextColor(Android.Graphics.Color.Black); } else { commentsview.Adapter = comments; } setListViewHeightBasedOnChildren1(commentsview); WineName.Text = myData.ItemDetails.Name; WineName.InputType = Android.Text.InputTypes.TextFlagNoSuggestions; Vintage.Text = myData.ItemDetails.Vintage.ToString(); if (Vintage.Text == null || Vintage.Text == "0") { Vintage.Text = ""; } else { Vintage.Text = myData.ItemDetails.Vintage.ToString(); } if (myData.ItemDetails.Producer == null || myData.ItemDetails.Producer == "") { WineProducer.Text = "Not Available"; } else { WineProducer.Text = myData.ItemDetails.Producer; } if (myData.ItemDetails.Description == null || myData.ItemDetails.Description == "") { WineDescription.Text = "Not Available"; } else { WineDescription.Text = myData.ItemDetails.Description; } AvgRating.Rating = (float)myData.ItemDetails.AverageRating; //ReviewPopup editPopup = new ReviewPopup(this, edit); //RatingBar RatingInput = FindViewById<RatingBar>(Resource.Id.ratingInput);//Taking rating stars input //RatingInput.RatingBarChange += editPopup.CreatePopup; var metrics = Resources.DisplayMetrics; var widthInDp = ConvertPixelsToDp(metrics.WidthPixels); var heightInDp = ConvertPixelsToDp(metrics.HeightPixels); HighImageWine = FindViewById <ImageView>(Resource.Id.WineImage); BitmapFactory.Options options = new BitmapFactory.Options { InJustDecodeBounds = false, OutHeight = 75, OutWidth = 75 }; ProgressIndicator.Hide(); LoggingClass.LogInfo("Entered into detail view" + WineBarcode, screenid); Bitmap result = BitmapFactory.DecodeResource(Resources, Resource.Drawable.placeholder_re, options); } catch (Exception exe) { LoggingClass.LogError(exe.Message, screenid, exe.StackTrace.ToString()); AlertDialog.Builder alert = new AlertDialog.Builder(this, Resource.Style.MyDialogTheme); alert.SetTitle("Sorry"); alert.SetMessage("We're under maintainence"); alert.SetNegativeButton("Ok", delegate { }); Dialog dialog = alert.Create(); dialog.Show(); } } catch { } }
protected override void OnCreate(Bundle savedInstanceState) { CheckInternetConnection(); Stopwatch st = new Stopwatch(); st.Start(); base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.detailedView); WineBarcode = Intent.GetStringExtra("WineBarcode"); storeid = Intent.GetIntExtra("storeid", 1); ActionBar.SetHomeButtonEnabled(true); ActionBar.SetDisplayHomeAsUpEnabled(true); ServiceWrapper svc = new ServiceWrapper(); ItemDetailsResponse myData = new ItemDetailsResponse(); ItemReviewResponse SkuRating = new ItemReviewResponse(); this.Title = "Wine Details"; commentsview = FindViewById <ListView>(Resource.Id.listView2); TextView WineName = FindViewById <TextView>(Resource.Id.txtWineName); //Assigning values to respected Textfields WineName.Focusable = false; TextView WineProducer = FindViewById <TextView>(Resource.Id.txtProducer); WineProducer.Focusable = false; TextView Vintage = FindViewById <TextView>(Resource.Id.txtVintage); Vintage.Focusable = false; TextView WineDescription = FindViewById <TextView>(Resource.Id.txtWineDescription); WineDescription.Focusable = false; RatingBar AvgRating = FindViewById <RatingBar>(Resource.Id.avgrating); AvgRating.Focusable = false; TextView ErrorDescription = FindViewById <TextView>(Resource.Id.Error); ErrorDescription.Focusable = false; ErrorDescription.Visibility = ViewStates.Invisible; TableRow tr5 = FindViewById <TableRow>(Resource.Id.tableRow5); try { DownloadAsync(this, System.EventArgs.Empty, WineBarcode); myData = svc.GetItemDetails(WineBarcode, storeid).Result; SkuRating = svc.GetItemReviewsByWineBarcode(WineBarcode).Result; ReviewArray = SkuRating.Reviews.ToList(); comments = new reviewAdapter(this, ReviewArray); if (comments.Count == 0) { ErrorDescription.Text = SkuRating.ErrorDescription; ErrorDescription.Visibility = ViewStates.Visible; //AlertDialog.Builder aler = new AlertDialog.Builder(this, Resource.Style.MyDialogTheme); //aler.SetTitle("No Reviews"); //aler.SetMessage("Be the first one to Review"); //aler.SetNegativeButton("Ok", delegate { }); //Dialog dialog = aler.Create(); //dialog.Show(); } else { commentsview.Adapter = comments; } setListViewHeightBasedOnChildren1(commentsview); WineName.Text = myData.ItemDetails.Name; WineName.InputType = Android.Text.InputTypes.TextFlagNoSuggestions; Vintage.Text = myData.ItemDetails.Vintage.ToString(); if (myData.ItemDetails.Producer == null || myData.ItemDetails.Producer == "") { WineProducer.Text = "Not Available"; } else { WineProducer.Text = myData.ItemDetails.Producer; } if (myData.ItemDetails.Description == null || myData.ItemDetails.Description == "") { WineDescription.Text = "Not Available"; } else { WineDescription.Text = myData.ItemDetails.Description; } AvgRating.Rating = (float)myData.ItemDetails.AverageRating; Review edit = new Review() { Barcode = WineBarcode, RatingText = "", PlantFinal = storeid.ToString() }; var tempReview = ReviewArray.Find(x => x.ReviewUserId == Convert.ToInt32(CurrentUser.getUserId())); if (tempReview != null) { edit.RatingText = tempReview.RatingText; } ReviewPopup editPopup = new ReviewPopup(this, edit); RatingBar RatingInput = FindViewById <RatingBar>(Resource.Id.ratingInput); //Taking rating stars input RatingInput.RatingBarChange += editPopup.CreatePopup; var metrics = Resources.DisplayMetrics; var widthInDp = ConvertPixelsToDp(metrics.WidthPixels); var heightInDp = ConvertPixelsToDp(metrics.HeightPixels); HighImageWine = FindViewById <ImageView>(Resource.Id.WineImage); BitmapFactory.Options options = new BitmapFactory.Options { InJustDecodeBounds = false, OutHeight = 75, OutWidth = 75 }; ProgressIndicator.Hide(); LoggingClass.LogInfo("Entered into detail view" + WineBarcode, screenid); Bitmap result = BitmapFactory.DecodeResource(Resources, Resource.Drawable.placeholder_re, options); } catch (Exception exe) { LoggingClass.LogError(exe.Message, screenid, exe.StackTrace.ToString()); AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.SetTitle("Sorry"); alert.SetMessage("We're under maintainence"); alert.SetNegativeButton("Ok", delegate { }); Dialog dialog = alert.Create(); dialog.Show(); } //downloadButton = FindViewById<Button>(Resource.Id.Download); //try //{ // //downloadButton.Enabled = true; // downloadButton.Click += downloadAsync; // //downloadButton.Enabled = false; //} //catch (Exception e) { } st.Stop(); LoggingClass.LogTime("Detail activity", st.Elapsed.TotalSeconds.ToString()); TokenModel devInfo = new TokenModel(); var activityManager = (ActivityManager)this.GetSystemService(Context.ActivityService); ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo(); activityManager.GetMemoryInfo(memInfo); System.Diagnostics.Debug.WriteLine("GetDeviceInfo - Avail {0} - {1} MB", memInfo.AvailMem, memInfo.AvailMem / 1024 / 1024); System.Diagnostics.Debug.WriteLine("GetDeviceInfo - Low {0}", memInfo.LowMemory); System.Diagnostics.Debug.WriteLine("GetDeviceInfo - Total {0} - {1} MB", memInfo.TotalMem, memInfo.TotalMem / 1024 / 1024); devInfo.AvailableMainMemory = memInfo.AvailMem; devInfo.IsLowMainMemory = memInfo.LowMemory; devInfo.TotalMainMemory = memInfo.TotalMem; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.detailedView); //Top detailed view string[] arr1 = new string[] { "Silver napa valley", "Cabernet ", "2011", " This is the description about wine,This is the description about wine,This is the description about wine" }; var detailView = FindViewById <ListView>(Resource.Id.listView1); DetailsArray = DetailsData(); DetailsViewAdapter Details = new DetailsViewAdapter(this, DetailsArray); detailView.Adapter = Details; var commentsView = FindViewById <ListView>(Resource.Id.listView2); ReviewArray = ReviewData(); reviewAdapter comments = new reviewAdapter(this, ReviewArray); commentsView.Adapter = comments; DetailsArray = DetailsData(); ReviewArray = ReviewData(); setListViewHeightBasedOnChildren(detailView); setListViewHeightBasedOnChildren1(commentsView); TextView TopName = FindViewById <TextView>(Resource.Id.textView6); //Assigning to respected Textfield TextView TopBrand = FindViewById <TextView>(Resource.Id.textView7); TextView TopVintage = FindViewById <TextView>(Resource.Id.textView8); TextView WineDescription = FindViewById <TextView>(Resource.Id.textView36); TableRow tr5 = FindViewById <TableRow>(Resource.Id.tableRow5); RatingBar rb = FindViewById <RatingBar>(Resource.Id.rating); rb.RatingBarChange += Rb_RatingBarChange; //String x; //rb.RatingBarChange += (o, e) => //{ // Toast.MakeText(this, "You have selected " + rb.Rating.ToString() + " Stars", ToastLength.Short).Show(); // x = rb.Rating.ToString(); //}; var metrics = Resources.DisplayMetrics; var widthInDp = ConvertPixelsToDp(metrics.WidthPixels); //var heightInDp = ConvertPixelsToDp(metrics.HeightPixels); //ImageView iv = new ImageView(this); //iv.LayoutParameters = new LinearLayout.LayoutParams(widthInDp, widthInDp); ImageButton ib = FindViewById <ImageButton>(Resource.Id.imageButton1); var pa = ib.LayoutParameters; pa.Height = PixelsToDp(widthInDp); pa.Width = PixelsToDp(widthInDp); ib.SetImageResource(Resource.Drawable.wine1); //placeholder.LayoutParameters = new TableRow.LayoutParams(heightInDp, widthInDp); //tr5.Layout(0, 0, 100,100 ); //placeholder.Layout(0, 0, widthInDp, widthInDp); //placeholder.LayoutParameters.Width = widthInDp; //Java.Lang.ClassCastException: android.widget.TableLayout$LayoutParams cannot be cast to android.widget.TableRow$LayoutParams //rb.NumStars = 5; //placeholder.Visibility = ViewStates.Visible; // iv.SetImageResource(Resource.Drawable.placeholder_bottiglia_lista); //tr5.AddView(iv); TopName.Focusable = false; TopBrand.Focusable = false; TopVintage.Focusable = false; WineDescription.Focusable = false; //placeholder.Focusable = false; TopName.Text = arr1[0]; //Assigning value TopBrand.Text = arr1[1]; TopVintage.Text = arr1[2]; WineDescription.Text = arr1[3]; BitmapFactory.Options options = new BitmapFactory.Options { InJustDecodeBounds = false, OutHeight = 75, OutWidth = 75 }; // The result will be null because InJustDecodeBounds == true. Bitmap result = BitmapFactory.DecodeResource(Resources, Resource.Drawable.placeholder_re, options); //placeholder.SetImageBitmap(result); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.detailedView); wineid = Intent.GetIntExtra("WineID", 123); ActionBar.SetHomeButtonEnabled(true); ActionBar.SetDisplayHomeAsUpEnabled(true); ServiceWrapper svc = new ServiceWrapper(); ItemDetailsResponse myData = new ItemDetailsResponse(); ItemReviewResponse SkuRating = new ItemReviewResponse(); this.Title = "Wine Details"; var commentsView = FindViewById <ListView>(Resource.Id.listView2); TextView WineName = FindViewById <TextView>(Resource.Id.txtWineName); //Assigning values to respected Textfields WineName.Focusable = false; TextView WineProducer = FindViewById <TextView>(Resource.Id.txtProducer); WineProducer.Focusable = false; TextView Vintage = FindViewById <TextView>(Resource.Id.txtVintage); Vintage.Focusable = false; TextView WineDescription = FindViewById <TextView>(Resource.Id.txtWineDescription); WineDescription.Focusable = false; RatingBar AvgRating = FindViewById <RatingBar>(Resource.Id.avgrating); AvgRating.Focusable = false; TableRow tr5 = FindViewById <TableRow>(Resource.Id.tableRow5); try { downloadAsync(this, System.EventArgs.Empty, wineid); myData = svc.GetItemDetails(wineid).Result; SkuRating = svc.GetItemReviewsByWineID(wineid).Result; reviewAdapter comments = new reviewAdapter(this, SkuRating.Reviews.ToList()); commentsView.Adapter = comments; setListViewHeightBasedOnChildren1(commentsView); WineName.Text = myData.ItemDetails.Name; WineName.InputType = Android.Text.InputTypes.TextFlagNoSuggestions; Vintage.Text = myData.ItemDetails.Vintage.ToString(); WineProducer.Text = myData.ItemDetails.Producer; WineDescription.Text = myData.ItemDetails.Description; AvgRating.Rating = (float)myData.ItemDetails.AverageRating; Review edit = new Review(); edit.WineId = wineid; ReviewPopup editPopup = new ReviewPopup(this, edit); RatingBar RatingInput = FindViewById <RatingBar>(Resource.Id.ratingInput);//Taking rating stars input RatingInput.RatingBarChange += editPopup.CreatePopup; var metrics = Resources.DisplayMetrics; var widthInDp = ConvertPixelsToDp(metrics.WidthPixels); var heightInDp = ConvertPixelsToDp(metrics.HeightPixels); //imgWine = FindViewById<ImageView>(Resource.Id.imgWine12); HighImageWine = FindViewById <ImageView>(Resource.Id.WineImage); //ProfilePicturePickDialog pppd = new ProfilePicturePickDialog(); //string path = pppd.CreateDirectoryForPictures(); //var filePath = System.IO.Path.Combine(path + "/" + wineid + ".jpg"); //if (System.IO.File.Exists(filePath)) //{ // Bitmap imageBitmap = BitmapFactory.DecodeFile(filePath); // imgWine.SetImageBitmap(imageBitmap); //} //else //{ // Bitmap imageBitmap = BlobWrapper.Bottleimages(wineid); // imgWine.SetImageBitmap(imageBitmap); //} //imgWine.LayoutParameters = new RelativeLayout.LayoutParams(1100, 1100); BitmapFactory.Options options = new BitmapFactory.Options { InJustDecodeBounds = false, OutHeight = 75, OutWidth = 75 }; ProgressIndicator.Hide(); Bitmap result = BitmapFactory.DecodeResource(Resources, Resource.Drawable.placeholder_re, options); } catch (Exception ex) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.SetTitle("Sorry"); alert.SetMessage("We're under maintainence"); alert.SetNegativeButton("Ok", delegate { }); Dialog dialog = alert.Create(); dialog.Show(); } //downloadButton = FindViewById<Button>(Resource.Id.Download); //try //{ // //downloadButton.Enabled = true; // downloadButton.Click += downloadAsync; // //downloadButton.Enabled = false; //} //catch (Exception e) { } }