public void FinishCarpool(System.Object sender, EventArgs e) { if (iTripDetail.Member.type.Equals("Driver")) { int i = iTripDetail.TripPassengers.Count; foreach (TripPassenger tp in iTripDetail.TripPassengers) { Dialog dialog = new Dialog(this); dialog.SetContentView(Resource.Layout.Custom_Dialog_Rating); TextView tvTitle = (TextView)dialog.FindViewById(Resource.Id.title); RatingBar ratingbar = (RatingBar)dialog.FindViewById(Resource.Id.ratingbar); EditText etComment = (EditText)dialog.FindViewById(Resource.Id.comment); Button btnSubmit = (Button)dialog.FindViewById(Resource.Id.btn_submit); Button btnCancel = (Button)dialog.FindViewById(Resource.Id.btn_cancel); tvTitle.Text = "Rate " + tp.Member.username; btnSubmit.Click += async(sender2, e2) => { string comment = etComment.Text.ToString(); int rating = (int)ratingbar.Rating; int rater = iTripDetail.Member.MemberID; int member = tp.Member.MemberID; if (rating != 0) { progress.SetMessage("Submitting..."); RunOnUiThread(() => { progress.Show(); }); Rating rate = new Rating(rater, member, rating, comment); await RESTClient.CreateRatingAsync(this, rate); RunOnUiThread(() => { progress.Dismiss(); }); } else { Toast.MakeText(this, "Set the rating star", ToastLength.Short).Show(); } if (i == 1) { Intent intent = new Intent(this, typeof(MainActivity)); intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask); StartActivity(intent); Finish(); } i--; ClearPreference(); dialog.Dismiss(); }; btnCancel.Click += (sender2, e2) => { if (i == 1) { ClearPreference(); Intent intent = new Intent(this, typeof(MainActivity)); intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask); StartActivity(intent); Finish(); } i--; dialog.Dismiss(); }; dialog.Show(); } } else { Dialog dialog = new Dialog(this); dialog.SetContentView(Resource.Layout.Custom_Dialog_Rating); TextView tvTitle = (TextView)dialog.FindViewById(Resource.Id.title); RatingBar ratingbar = (RatingBar)dialog.FindViewById(Resource.Id.ratingbar); EditText etComment = (EditText)dialog.FindViewById(Resource.Id.comment); Button btnSubmit = (Button)dialog.FindViewById(Resource.Id.btn_submit); Button btnCancel = (Button)dialog.FindViewById(Resource.Id.btn_cancel); tvTitle.Text = "Rate " + iTripDetail.TripDriver.Member.username; btnSubmit.Click += async(sender2, e2) => { string comment = etComment.Text.ToString(); int rating = (int)ratingbar.Rating; int rater = iTripDetail.Member.MemberID; int member = iTripDetail.TripDriver.Member.MemberID; if (rating != 0) { progress.SetMessage("Submitting..."); RunOnUiThread(() => { progress.Show(); }); Rating rate = new Rating(rater, member, rating, comment); await RESTClient.CreateRatingAsync(this, rate); RunOnUiThread(() => { progress.Dismiss(); }); Intent intent = new Intent(this, typeof(MainActivity)); intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask); StartActivity(intent); Finish(); ClearPreference(); dialog.Dismiss(); } else { Toast.MakeText(this, "Set the rating star", ToastLength.Short).Show(); } }; btnCancel.Click += (sender2, e2) => { ClearPreference(); Intent intent = new Intent(this, typeof(MainActivity)); intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask); StartActivity(intent); Finish(); dialog.Dismiss(); }; dialog.Show(); } }