private void MSaveButton_Click(object sender, EventArgs e) { mCheckedRadioButton = mMainView.FindViewById <RadioButton>(mPricingTypeRadioGrp.CheckedRadioButtonId); if (mCurrentPricingType != SelectedPrice(mCheckedRadioButton.Text) && GlobalVariables.globalProductsOnCart.Count > 0) { Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(this.Context); Android.App.AlertDialog alert = builder.Create(); alert.SetTitle("Warning"); alert.SetMessage("Changing the price type will clear the cart. Continue?"); alert.SetButton2("CANCEL", (c, ev) => { //cancel button }); alert.SetButton("YES", (c, ev) => { SelectPricingType(); this.Dismiss(); }); alert.Show(); } else { SelectPricingType(); this.Dismiss(); } }
//public async Task sendToServiceAsync() //{ // try // { // string l_id = prefs.GetString("LicenceId", ""); // dynamic value = new ExpandoObject(); // // value.GeoLocation = loc; // string json = JsonConvert.SerializeObject(value); // string item = await restService.RegisterUser(l_id, number, username, location_geo, // "0", "0").ConfigureAwait(false); // if (item.Contains("Success")) // { // ISharedPreferencesEditor editor = prefs.Edit(); // editor.PutString("register_status", "yes"); // editor.PutString("username1", username); // editor.PutString("mobile", number); // editor.Commit(); // Intent intent = new Intent(Activity, typeof(DetailActivity)); // //intent.PutExtra("username", username); // StartActivity(intent); // Activity.Finish(); // //Intent intent = new Intent(this, typeof(MainActivity)); // //// intent.AddFlags(ActivityFlags.NewTask); // //StartActivity(intent); // //// Finish(); // } // else // { // // Toast.MakeText(Activity, "Oops! Something went wrong, Please try later. ", ToastLength.Long).Show(); // } // } // catch (Exception ex) // { // } //} public void AlertBox() { Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(Activity); Android.App.AlertDialog alert = dialog.Create(); alert.SetTitle("Alert"); alert.SetMessage("Phone Number is not registered"); alert.SetButton("OK", (c, ev) => { alert.Dismiss(); }); alert.Show(); }
static public void InfoMessage(Context context, string caption, string message, Func <bool> onOkClick) { Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(context); Android.App.AlertDialog alert = dialog.Create(); alert.SetTitle(caption); alert.SetMessage(message); alert.SetButton("OK", (c, ev) => { onOkClick?.Invoke(); return; }); alert.Show(); }
private void List_ItemClick(object sender, AdapterView.ItemClickEventArgs e) { // Item Medicamento _medicamento = _listMedicamentos[e.Position]; if (_medicamento.confirmar == true) { Android.App.AlertDialog.Builder dialog = new AlertDialog.Builder(Activity); AlertDialog alert = dialog.Create(); alert.SetTitle("Medicamento"); alert.SetMessage("Ya ha sido confirmado!"); alert.SetButton("Cerrar", delegate { alert.Dispose(); }); alert.Show(); } else { AlertDialog.Builder dialog = new AlertDialog.Builder(Activity); AlertDialog alert = dialog.Create(); alert.SetTitle("Medicamento"); alert.SetIcon(Resource.Drawable.logo); alert.SetButton("Confirmar", (c, ev) => { //_medicamento = _listMedicamentos[e.Position]; _medicamento.confirmar = true; // Confirmar Medicamento _medicamentoService.updateMedicamento(_medicamento); // Actualiza el registro en la base de datos // Para refresh Activity.Finish(); StartActivity(Activity.Intent); GC.Collect(); }); alert.SetButton2("Omitir", (c, ev) => { }); alert.Show(); } }
public Task <(bool, int)> ShowPicker(string title, string okButtonText, string cancelButtonText, NumberPickerOptions options) { var tcs = new TaskCompletionSource <(bool, int)>(); Task.Run(() => { Application.SynchronizationContext.Post(ignored => { var view = Activity.LayoutInflater.Inflate(Resource.Layout.number_picker_dialog, null); var numberPicker = view.FindViewById <NumberPicker>(Resource.Id.number_picker); numberPicker.MaxValue = options.Maximum - 1; numberPicker.MinValue = options.Minimum; numberPicker.Value = options.Initial <= options.Minimum ? options.Minimum : options.Initial; var values = new List <string>(); for (var i = options.Minimum; i < options.Maximum; i += 1) { values.Add((i * options.Step) + options.DisplaySuffix); } numberPicker.SetDisplayedValues(values.ToArray()); var builder = new AlertDialog.Builder(Activity)//todo here we have bug!!! .SetTitle(title) .SetView(view) .SetPositiveButton(okButtonText, (x, y) => tcs.TrySetResult((true, numberPicker.Value))) .SetNegativeButton(cancelButtonText, (x, y) => tcs.TrySetResult((false, numberPicker.MinValue))); _dialog = null; _dialog = builder.Create(); _dialog.Show(); }, null); }); return(tcs.Task); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.Inflate(Resource.Layout.PropertyDetailView, container, false); accomId = int.Parse(Arguments.GetString("accomID")); addReview = v.FindViewById <Button>(Resource.Id.addReview); displayAccom = v.FindViewById <Button>(Resource.Id.displayAccom); displayAddress = v.FindViewById <TextView>(Resource.Id.displayAddress); displayBills = v.FindViewById <TextView>(Resource.Id.displayBills); displayWifi = v.FindViewById <TextView>(Resource.Id.displayWifi); displayPrice = v.FindViewById <TextView>(Resource.Id.displayPrice); displayBedrooms = v.FindViewById <TextView>(Resource.Id.displayBedrooms); displayBathrooms = v.FindViewById <TextView>(Resource.Id.displayBathrooms); displayRating = v.FindViewById <TextView>(Resource.Id.displayRating); LinearLayout reviewLayout = v.FindViewById <LinearLayout>(Resource.Id.reviewLayout); Button addToFavourites = v.FindViewById <Button>(Resource.Id.addFavourite); addressList = new List <Address>(); // Gets all the views addReview.Click += delegate { FragmentTransaction fragmentTx = FragmentManager.BeginTransaction(); addReview addReview = new addReview(); Bundle bundle = new Bundle(); bundle.PutString("accomID", accomId.ToString()); addReview.Arguments = bundle; fragmentTx.Replace(Resource.Id.content_frame, addReview); fragmentTx.Commit(); }; // Takes you to the add a review page displayAccom.Click += async(sender, e) => { string url = "http://housechecker.co.uk/api/export_property.php"; JsonValue json = await FetchUserAsync(url); string jsonString = json.ToString(); addressList = JsonConvert.DeserializeObject <List <Address> >(jsonString); Address accomodation = addressList.Where(a => a.id == accomId).FirstOrDefault(); ImageView imageView = v.FindViewById <ImageView>(Resource.Id.propertyImage); // Finds the accomodation that matches the ID that you have passed in try { string imageURL = accomodation.image.Remove(0, 2); imageURL = "http://housechecker.co.uk" + imageURL; WebRequest request = WebRequest.Create(imageURL); WebResponse resp = request.GetResponse(); Stream respStream = resp.GetResponseStream(); Bitmap bmp = BitmapFactory.DecodeStream(respStream); Bitmap image = Bitmap.CreateScaledBitmap(bmp, 500, 500, false); respStream.Dispose(); imageView.SetImageBitmap(image); imageView.RefreshDrawableState(); } catch (Exception error) { imageView.SetImageDrawable(Resources.GetDrawable(Resource.Drawable.propertyStock)); } // Finds and displays the image string ratingUrl = "http://housechecker.co.uk/api/export_review.php"; json = await FetchUserAsync(ratingUrl); jsonString = json.ToString(); var reviewList = JsonConvert.DeserializeObject <List <Review> >(jsonString); // Gets all the reviewws and puts it into a review list List <Review> review = reviewList.Where(a => a.property_id == accomodation.id).ToList(); if (review.Count > 0) { accomodation.rating = review.Average(a => a.rating); } else { accomodation.rating = 0; } // Gets the rating from each review that is linked to the property and averages it displayRating.Text = "Average Rating: " + accomodation.rating; displayRating.Click += async delegate { await CrossTextToSpeech.Current.Speak(displayRating.Text); }; displayBills.Text = "Bills included: " + accomodation.bills; displayBills.Click += async delegate { await CrossTextToSpeech.Current.Speak(displayBills.Text); }; displayWifi.Text = "Wifi included: " + accomodation.wifi; displayWifi.Click += async delegate { await CrossTextToSpeech.Current.Speak(displayWifi.Text); }; displayPrice.Text = "Price per week: " + accomodation.price; displayPrice.Click += async delegate { await CrossTextToSpeech.Current.Speak(displayPrice.Text); }; displayBathrooms.Text = "Number of bathrooms: " + accomodation.bathrooms; displayBathrooms.Click += async delegate { await CrossTextToSpeech.Current.Speak(displayBathrooms.Text); }; displayBedrooms.Text = "Number of bedrooms: " + accomodation.bedrooms; displayBedrooms.Click += async delegate { await CrossTextToSpeech.Current.Speak(displayBedrooms.Text); }; displayAddress.Text = "Address: " + accomodation.address1 + ", " + accomodation.address2 + ", " + accomodation.city + ", " + accomodation.postcode; displayAddress.Click += async delegate { await CrossTextToSpeech.Current.Speak(displayAddress.Text); }; // Creates an on click event that reads out whatever the text says TextView reviewTitle = new TextView(this.Context); reviewTitle.Text = "Most recent reviews: "; reviewTitle.TextSize = 32; reviewTitle.Typeface = Typeface.DefaultBold; reviewTitle.Gravity = GravityFlags.Center; reviewLayout.AddView(reviewTitle); // Creates a title for the reviews section foreach (var accomReview in review.OrderBy(a => a.date_of_review).Take(20)) { TextView newReviewText = new TextView(this.Context); newReviewText.Text = "Title: " + accomReview.title + "\nComment: " + accomReview.comment + "\nRating: " + accomReview.rating; newReviewText.TextSize = 24; newReviewText.Gravity = GravityFlags.Center; reviewLayout.AddView(newReviewText); // Gets the top 20 reviews for this accomodation, ordered by date, and creates a text view for them } url = "http://housechecker.co.uk/api/export_favourite.php"; json = await FetchUserAsync(url); jsonString = json.ToString(); var favouriteList = JsonConvert.DeserializeObject <List <Favourite> >(jsonString); int userID = Int32.Parse(ap.getAccessKey()); url = "http://housechecker.co.uk/api/export.php"; json = await FetchUserAsync(url); jsonString = json.ToString(); Student user = JsonConvert.DeserializeObject <List <Student> >(jsonString).Where(a => a.Id == userID).FirstOrDefault(); // Gets the favourite list and decides if the user is a student or not if (user.Type == "Student") { addToFavourites.Visibility = ViewStates.Visible; } if (user.Type == "Landlord") { addReview.Visibility = ViewStates.Invisible; } // Landlords cant add a favourite var accomFavourite = favouriteList.Where(a => a.user_id == userID && a.accom_id == accomodation.id).FirstOrDefault(); // Gets the value for a saved favourite for that accomodation and user if (accomFavourite != null) { // If a favourite exists it means the user has added it to their favourites addToFavourites.Text = "Remove from favourites"; addToFavourites.Click += async delegate { url = "http://housechecker.co.uk/api/delete_favourite.php"; json = await DeleteFavourite(url, accomFavourite.favourite_id); // This will remove the favourited accomodation from their list Activity.RunOnUiThread(() => { Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(Activity); Android.App.AlertDialog alert = dialog.Create(); dialog.SetCancelable(false); alert.SetTitle("Complete"); alert.SetMessage("Successfully removed from favourites"); alert.SetButton("OK", (c, ev) => { // Ok button click task }); alert.Show(); }); // Shows a pop up window informing the user it has worked }; } else { addToFavourites.Text = "Add to Favourites"; addToFavourites.Click += async delegate { url = "http://housechecker.co.uk/api/import_favourite.php"; json = await AddFavourite(url, accomodation.id); // This will add the property to the list Activity.RunOnUiThread(() => { Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(Activity); Android.App.AlertDialog alert = dialog.Create(); dialog.SetCancelable(false); alert.SetTitle("Complete"); alert.SetMessage("Successfully added to favourites"); alert.SetButton("OK", (c, ev) => { // Ok button click task }); alert.Show(); }); }; } }; displayAccom.CallOnClick(); return(v); }