async Task RegistrationAsync() { ShowProgressDialogue("Registering...please wait!"); try { var HttpClient = SessionManager.GetHttpClient(); var json = JsonConvert.SerializeObject(CurMember); var content = new StringContent(json, Encoding.UTF8, "application/json"); var url = SessionManager.GetAPIURL("farmerRegistrations"); var req = new HttpRequestMessage(HttpMethod.Post, url) { Content = content, }; var response = await HttpClient.PostAsync(url, content); var responseMsg = await response.Content.ReadAsStringAsync(); if (!string.IsNullOrWhiteSpace(responseMsg)) { var json1 = JsonConvert.DeserializeObject <dynamic>(responseMsg); if (response.IsSuccessStatusCode) { CurMember.IsSynced = true; Farmer.DB.Update(CurMember); Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this); Android.App.AlertDialog alert = dialog.Create(); alert.SetTitle("Registration"); alert.SetCanceledOnTouchOutside(false); alert.SetMessage("Registration was successful. You can now login. Your username is your mobile number. Use any PIN or password of choice."); alert.SetIcon(Resource.Drawable.ic_account_key); alert.SetButton("OK", (c, ev) => { alert.Dismiss(); var intent = new Intent(this, typeof(LoginActivity)); intent.PutExtra("Username", CurMember.Mobile); StartActivity(intent); Finish(); OverridePendingTransition(Resource.Animation.side_in_right, Resource.Animation.side_out_left); }); alert.Show(); } else { CloseProgressDialogue(); MessageBox.Show(this, "Regidtration Error", (string)json1.error_description); } } } catch (Exception e) { CloseProgressDialogue(); this.Show("Error", e.Message); } }
/// <summary> /// 申请理由对话框 /// </summary> private void ShowRationalDialog(string[] permissions) { lock (this) { AlertDialog alertDialog = (new AlertDialog.Builder(mActivity)) .SetMessage(mOptions.RationalMessage) .SetPositiveButton(mOptions.RationalBtnText, (s, e) => RequestPermissions(permissions)) .Create(); alertDialog.SetCancelable(mOptions.DialogCancelable); alertDialog.SetCanceledOnTouchOutside(mOptions.DialogCanceledOnTouchOutside); alertDialog.Show(); } }
protected override void OnElementChanged(ElementChangedEventArgs<Page> e) { base.OnElementChanged(e); var page = e.NewElement as MainPage; if (page != null) { MessagingCenter.Subscribe(page, "KillActionSheet", (MainPage sender) => { if (actionSheet != null) actionSheet.Dismiss(); }); MessagingCenter.Subscribe(page, "DisplayCustomAndroidActionSheet", (MainPage sender, CustomAndroidActionSheetArguments args) => { var builder = new AlertDialog.Builder (Forms.Context); builder.SetTitle(args.Title); var items = args.Buttons.ToArray(); builder.SetItems(items, (sender2, args2) => args.Result.TrySetResult(items[args2.Which])); if (args.Cancel != null) builder.SetPositiveButton(args.Cancel, delegate { args.Result.TrySetResult(args.Cancel); }); if (args.Destruction != null) builder.SetNegativeButton(args.Destruction, delegate { args.Result.TrySetResult(args.Destruction); }); actionSheet = builder.Create(); builder.Dispose(); actionSheet.SetCanceledOnTouchOutside(true); actionSheet.CancelEvent += (sender3, ee) => args.SetResult(null); actionSheet.Show(); }); } }
private void CallAlert() { var layoutInflater = LayoutInflater.From(this); var mview = layoutInflater.Inflate(Resource.Layout._alertRateAppDialog, null); var alertDialogBuilder = new Android.App.AlertDialog.Builder(this); alertDialogBuilder.SetView(mview); alertDialogAndroid = alertDialogBuilder.Create(); alertDialogAndroid.Show(); alertDialogAndroid.SetCanceledOnTouchOutside(false); alertDialogAndroid.SetCancelable(false); var rateButtonYes = mview.FindViewById <Button>(Resource.Id.buttonYes); var rateButtonNo = mview.FindViewById <Button>(Resource.Id.buttonNo); rateButtonNo.Click += (s, e) => alertDialogAndroid.Dismiss(); rateButtonYes.Click += RateButtonYes_Click; }
/// <summary> /// 拒绝权限提示框 /// </summary> private void ShowDeniedDialog(LinkedList <string> permissions) { lock (this) { AlertDialog alertDialog = (new AlertDialog.Builder(mActivity)).SetMessage(mOptions.DeniedMessage) .SetNegativeButton(mOptions.DeniedCloseBtn, (s, e) => { if (this.mCallback != null) { this.mCallback.OnDenied(permissions); } this.OnDestroy(); }).SetPositiveButton(mOptions.DeniedSettingBtn, (s, e) => this.StartSetting()).Create(); alertDialog.SetCancelable(mOptions.DialogCancelable); alertDialog.SetCanceledOnTouchOutside(mOptions.DialogCanceledOnTouchOutside); alertDialog.Show(); } }
public void PresentAlert(string content, bool backActivity) { var dialogVal = new AlertDialog.Builder(this, Resource.Style.AlertDialog); AlertDialog alertVal = dialogVal.Create(); alertVal.SetCanceledOnTouchOutside(false); alertVal.SetTitle("Información"); alertVal.SetMessage(content); alertVal.SetButton("Aceptar", (c, ev) => { alertVal.Hide(); if (backActivity) { StartActivity(new Intent(Application.Context, typeof(HomeActivity))); Finish(); } }); alertVal.Show(); }
void SignOut() { Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this); Android.App.AlertDialog alert = dialog.Create(); alert.SetTitle("Sign out"); alert.SetCanceledOnTouchOutside(false); alert.SetMessage("Are you sure you want to sign out"); alert.SetIcon(Resource.Drawable.ic_account_key); alert.SetButton("Yes", (c, ev) => { Action = 3; alert.Dismiss(); // if (Xamarin.Essentials.Connectivity.NetworkAccess.HasInternetAccess()) SyncData(); if (!IsSyncing) { SessionManager.User.Logout(); } FinishAffinity(); // StartActivity(typeof(LoginOptionsActivity)); // OverridePendingTransition(Resource.Animation.side_in_right, Resource.Animation.side_out_left); }); alert.SetButton2("Cancel", (c, ev) => { alert.Dismiss(); }); alert.SetButton3("Lock", (c, ev) => { if (!string.IsNullOrWhiteSpace(SessionManager.SecretLock)) { SessionManager.IsLocked = true; FinishAffinity(); } else { StartActivityForResult(typeof(AuthTemp.AddTemporaryPinActivity), 0); OverridePendingTransition(Resource.Animation.side_in_right, Resource.Animation.side_out_left); } }); alert.Show(); }
protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.Elevation = 0; SetContentView(Resource.Layout.generic_list); Recycler = FindViewById <RecyclerView>(Resource.Id.gridView_items); Recycler.SetLayoutManager(new LinearLayoutManager(this)); SelectMode = Intent.GetBooleanExtra(nameof(SelectMode), false); CourseID = Intent.GetIntExtra(nameof(CourseID), 1); CurCourse = await Course.DB.RowsAsync.FirstOrDefaultAsync(c => c.ID == CourseID); TitlesLayout = FindViewById <LinearLayout>(Resource.Id.layout_title); TextOne = FindViewById <TextView>(Resource.Id.text_title1); TextTwo = FindViewById <TextView>(Resource.Id.text_title2); ExamBtn = FindViewById <Button>(Resource.Id.btn_floating_action2); ExamBtn.Visibility = ViewStates.Visible; ExamBtn.Click += async(o, e) => { await CurCourse.LoadUserExaminations(); await CurCourse.LoadAllExercises(); var allexercises = CurCourse.AllExercises; var exercises = CurCourse.UserExaminations; var passes = new List <UserExamination>(); foreach (var item in exercises) { await item.LoadUserExaminationDetails(); var details = item.UserExaminationDetails; foreach (var item2 in details) { await item2.LoadQuestion(); var q = item2.Question; await q.LoadAnswers(); await item2.LoadAnswer(); } var correctanswers = details.Where(c => c.AnswerID != null && c.Answer.IsCorrect); var wronganswers = details.Where(c => c.AnswerID != null && !c.Answer.IsCorrect); var percentage = 100 * correctanswers.Count() / details.Count; if (percentage >= 70) { passes.Add(item); } } var overalpercentage = allexercises.Count > 0 ? 100 * passes.Count / allexercises.Count : 0; var requiredExercises = allexercises.Count * 70 / 100; if (overalpercentage >= 70) { var intent = new Intent(this, typeof(InstructionActivity)); intent.PutExtra(nameof(CourseID), CourseID); intent.PutExtra("ExamTypeID", (int)ExaminationType.EXAMINATION); StartActivity(intent); OverridePendingTransition(Resource.Animation.side_in_right, Resource.Animation.side_out_left); Finish(); } else { Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this); Android.App.AlertDialog alert = dialog.Create(); alert.SetTitle("Information"); alert.SetCanceledOnTouchOutside(false); alert.SetMessage($"Number of attempted exercises: {exercises.Count}.\nPassed exercises: {passes.Count}\nOveral Pass rate: {overalpercentage}%\nYou need to pass at least {requiredExercises} short exercises to qualify for the final exam"); alert.SetIcon(Resource.Drawable.ic_account_key); alert.SetButton("OK", (c, ev) => { alert.Dismiss(); }); alert.Show(); } }; TitlesLayout.Visibility = ViewStates.Visible; TextOne.Visibility = ViewStates.Visible; TextTwo.Visibility = ViewStates.Visible; if (SelectMode) { Title = "Select module.."; } }
protected override void OnCreate(Bundle savedInstanceState) { CrossCurrentActivity.Current.Activity = this; base.OnCreate(savedInstanceState); startServiceIntent = new Intent(this, typeof(TriTrackService)); user_id = Intent.GetIntExtra("user_id", 0); SetContentView(Resource.Layout.Map); daToolbar = FindViewById <SupportToolbar>(Resource.Id.toolbar); SetSupportActionBar(daToolbar); daLeftDrawer = FindViewById <ListView>(Resource.Id.left_drawer); daDrawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); drawerOptions = new List <string>(); drawerOptions.Add("Home"); drawerOptions.Add("History"); drawerOptions.Add("Log Out"); drawerOptionsAdapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, drawerOptions); daLeftDrawer.Adapter = drawerOptionsAdapter; daLeftDrawer.ItemClick += DaLeftDrawer_ItemClick; daDrawerToggle = new MyActionBarDrawerToggle( this, daDrawerLayout, Resource.String.openDrawer, Resource.String.closeDrawer); SetSupportActionBar(daToolbar); daDrawerLayout.AddDrawerListener(daDrawerToggle); SupportActionBar.SetHomeButtonEnabled(true); SupportActionBar.SetDisplayHomeAsUpEnabled(true); daDrawerToggle.SyncState(); MapFragment mapFragment = (MapFragment)FragmentManager.FindFragmentById(Resource.Id.the_fucking_map); mapFragment.GetMapAsync(this); switchB = FindViewById <Button>(Resource.Id.switch_button); switchB.Enabled = false; distanceText = FindViewById <TextView>(Resource.Id.distance); WorkOutMode = FindViewById <Switch>(Resource.Id.type); //latlonglist = FindViewById<TextView>(Resource.Id.LATLONG); getPos(); switchB.Click += delegate { if (WorkoutInProgress == false) { if (WorkOutMode.Checked == false) { workoutMode = "BIKE"; } else { workoutMode = "RUN"; } getPos(); switchB.SetBackgroundColor(Android.Graphics.Color.Red); daMap.Clear(); polyline = new PolylineOptions().InvokeWidth(20).InvokeColor(Color.Red.ToArgb()); sec = 0; min = 0; hour = 0; distance = 0; timer = new Timer(); timer.Interval = 1000; timer.Elapsed += Timer_Elapsed; timer.Start(); TimerText = FindViewById <TextView>(Resource.Id.timer_text); TimerText.Text = ("0:00:00"); WorkoutInProgress = true; start.SetPosition(new LatLng(position.Latitude, position.Longitude)); start.SetTitle("Start"); daMap.AddMarker(start); polyline.Add(new LatLng(position.Latitude, position.Longitude)); StartListening(); //LatLng latlng = new LatLng(position.Latitude, position.Longitude); //CameraUpdate camera = CameraUpdateFactory.NewLatLngZoom(latlng, 15); //daMap.MoveCamera(camera); switchB.Text = "FINISH WORKOUT"; } else if (WorkoutInProgress == true) { // THIS GETS A STRING OF THE POLYLINE //MAYBE STORE THIS A BLOB IN THE SQL DATABASE String.Join(":", polyline.Points); switchB.SetBackgroundColor(Android.Graphics.Color.ParseColor("#219653")); switchB.Enabled = false; switchB.Text = "START NEW WORKOUT"; WorkoutInProgress = false; timer.Stop(); finish.SetPosition(new LatLng(position.Latitude, position.Longitude)); finish.SetTitle("Finish"); daMap.AddMarker(finish); StopListening(); Android.App.AlertDialog.Builder diaglog = new Android.App.AlertDialog.Builder(this); Android.App.AlertDialog alert = diaglog.Create(); alert.SetCanceledOnTouchOutside(false); alert.SetCancelable(false); alert.SetTitle("Good Work"); alert.SetMessage("Your workout is complete, would you like to record it?"); alert.SetButton("Yes", (c, ev) => { switchB.Enabled = true; SubmitWorkoutToDatabase(); switchB.Text = "START NEW WORKOUT"; //TODO: SEND WORKOUT INFO TO THE DATABASE! alert.Dismiss(); //TODO: save polyine data to new table in the database. }); alert.SetButton2("No", (c, ev) => { switchB.Enabled = true; daMap.Clear(); alert.Dismiss(); sec = 0; min = 0; hour = 0; distance = 0; TimerText.Text = ("0:00:00"); switchB.Text = "START NEW WORKOUT"; }); alert.Show(); } }; }
async Task RegistrationAsync() { ProgressBar.Visibility = ViewStates.Visible; BtnLogin.Enabled = false; try { var HttpClient = SessionManager.GetHttpClient(); var json = JsonConvert.SerializeObject(CurMember); var content = new StringContent(json, Encoding.UTF8, "application/json"); var url = SessionManager.GetAPIURL("extensionOfficerRegistrations"); var req = new HttpRequestMessage(HttpMethod.Post, url) { Content = content, }; var response = await HttpClient.PostAsync(url, content); var responseMsg = await response.Content.ReadAsStringAsync(); if (!string.IsNullOrWhiteSpace(responseMsg)) { var json1 = JsonConvert.DeserializeObject <ExtensionOfficer>(responseMsg); if (response.IsSuccessStatusCode) { if (json1.ErrorCode.HasValue) { if (json1.ErrorCode == -1) { MessageBox.Show(this, "Record not found", json1.Firstname); } if (json1.ErrorCode == 1) { Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this); Android.App.AlertDialog alert = dialog.Create(); alert.SetTitle("Record found"); alert.SetCanceledOnTouchOutside(false); alert.SetMessage(json1.Firstname); alert.SetIcon(Resource.Drawable.ic_account_key); alert.SetButton("OK", (c, ev) => { alert.Dismiss(); var intent = new Intent(this, typeof(LoginActivity)); intent.PutExtra("Username", CurMember.ECNumber); StartActivity(intent); Finish(); OverridePendingTransition(Resource.Animation.side_in_right, Resource.Animation.side_out_left); }); alert.Show(); } } else { CurMember.IsSynced = true; ExtensionOfficer.DB.Update(CurMember); Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this); Android.App.AlertDialog alert = dialog.Create(); alert.SetTitle("Registration"); alert.SetCanceledOnTouchOutside(false); alert.SetMessage("Registration was successful. You can now login. Your username is your EC number. Use any PIN or password of choice."); alert.SetIcon(Resource.Drawable.ic_account_key); alert.SetButton("OK", (c, ev) => { alert.Dismiss(); var intent = new Intent(this, typeof(LoginActivity)); intent.PutExtra("Username", CurMember.ECNumber); StartActivity(intent); Finish(); OverridePendingTransition(Resource.Animation.side_in_right, Resource.Animation.side_out_left); }); alert.Show(); } } else { MessageBox.Show(this, "Regidtration Error", "Unknown error"); } } } catch (Exception e) { this.Show("Error", e.Message); BtnLogin.Enabled = true; ProgressBar.Visibility = ViewStates.Gone; } }
protected override Dialog OnCreateDialog (int id, Bundle args) { AlertDialog.Builder builder; builder = new AlertDialog.Builder (this); builder.SetInverseBackgroundForced (true); switch (id) { case 1: { builder.SetTitle (GetString(Resource.String.gps_request)); builder.SetPositiveButton (GetString(Resource.String.gps_enable), EnableClicked); builder.SetNegativeButton (GetString(Resource.String.gps_cancel), CancelClicked); dialog = builder.Create (); break; } } if (dialog != null) { dialog.SetCanceledOnTouchOutside (false); dialog.SetCancelable (false); } return dialog; }
// Initiate ready alert. private void InitiateReadyAlertDialogue() { readyAlert = new AlertDialog.Builder(this).Create(); readyAlert.SetCanceledOnTouchOutside(false); readyAlert.SetButton("READY", ReadyAlertDialogueConfirm_Click); }