public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { base.OnCreateView(inflater, container, savedInstanceState); var view = inflater.Inflate(Resource.Layout.SubmittedFragment, container, false); View header = Activity.LayoutInflater.Inflate(Resource.Layout.SubmittedHeader, null); exportList = view.FindViewById<ListView>(Resource.Id.submitted_list); exportList.AddHeaderView(header, null, false); LoadData(); exportList.ItemClick += delegate(object sender, AdapterView.ItemClickEventArgs args) { // The list's header borks indexing res = results[args.Position - 1]; View alertView = Activity.LayoutInflater.Inflate(Resource.Layout.SubmittedAlert, null); Button feedbackBtn = alertView.FindViewById<Button>(Resource.Id.submittedAlert_feedbackBtn); feedbackBtn.Click += feedbackBtn_Click; Button permissionsBtn = alertView.FindViewById<Button>(Resource.Id.submittedAlert_permission); permissionsBtn.Click += permissionsBtn_Click; Android.Support.V7.App.AlertDialog alert = new Android.Support.V7.App.AlertDialog.Builder(Activity) .SetTitle("What would you like to do with this submission?") .SetView(alertView) .SetCancelable(true) .SetNegativeButton("Delete", (EventHandler<DialogClickEventArgs>)null) .SetNeutralButton("Close", (s, a) => { }) .Create(); alert.Show(); // A second alert dialogue, confirming the decision to delete Button deleteBtn = alert.GetButton((int)DialogButtonType.Negative); deleteBtn.Click += delegate(object s, EventArgs e) { Android.Support.V7.App.AlertDialog.Builder confirm = new Android.Support.V7.App.AlertDialog.Builder(Activity); confirm.SetTitle("Are you sure?"); confirm.SetMessage("The recorded data will be deleted from the server and irrecoverably lost. Continue?"); confirm.SetPositiveButton("Delete", (senderAlert, confArgs) => { ServerData.PushResultDeletion(res); exportList.Adapter = null; LoadData(); alert.Dismiss(); }); confirm.SetNegativeButton("Cancel", (senderAlert, confArgs) => { }); confirm.Show(); }; }; return view; }
private void recordButton_Click(object sender, EventArgs e) { if (!recording) { recordButton.Text = "Stop recording!"; audioManager.StartRecording(recFile); recordButton.SetBackgroundResource(Resource.Drawable.recordButtonRed); } else { recordButton.Text = "Recording complete!"; audioManager.StopRecording(); recordButton.SetBackgroundResource(Resource.Drawable.recordButtonBlue); Android.Support.V7.App.AlertDialog alert = new Android.Support.V7.App.AlertDialog.Builder(this) .SetTitle("Recording complete!") .SetMessage("You completed a new voice entry about " + placeName + ". Would you like to try again or export this recording?") .SetNegativeButton("Restart", (EventHandler<DialogClickEventArgs>) null) .SetPositiveButton("Export", (s, args) => { ExportRecordings(); }) .Create(); alert.Show(); // A second alert dialogue, confirming the decision to restart Button negative = alert.GetButton((int) DialogButtonType.Negative); negative.Click += delegate { Android.Support.V7.App.AlertDialog.Builder confirm = new Android.Support.V7.App.AlertDialog.Builder(this); confirm.SetTitle("Are you sure?"); confirm.SetMessage("Restarting will wipe your current progress. Restart the scenario?"); confirm.SetPositiveButton("Restart", (senderAlert, confArgs) => { recordButton.Text = "Start recording!"; alert.Dismiss(); }); confirm.SetNegativeButton("Cancel", (senderAlert, confArgs) => { }); confirm.Show(); }; } recording = !recording; }
public void OnItemTap(object sender, AdapterView.ItemClickEventArgs args) { if(progressDialog == null) { progressDialog = new ProgressDialog(this); progressDialog.SetMessage("Uploading your content. Please wait."); progressDialog.SetButton("Cancel Upload", (arg1, arg2) => { if (cancelTokenSource != null) cancelTokenSource.Cancel(); }); progressDialog.Indeterminate = true; } Android.Support.V7.App.AlertDialog alert = new Android.Support.V7.App.AlertDialog.Builder(this) .SetTitle("Scenario Complete!") .SetMessage("What would you like to do with the results of this scenario?") .SetCancelable(true) .SetNegativeButton("Delete", (EventHandler<DialogClickEventArgs>)null) .SetPositiveButton("Upload", (s, a) => { IResultItem toUpload = AppData.Session.ResultsToUpload[args.Position - 1]; progressDialog.Show(); cancelTokenSource = new CancellationTokenSource(); ServerData.PushResult(toUpload, RefreshList, OnUploadComplete, cancelTokenSource.Token); }) .SetNeutralButton("Cancel", (s, a) => { }) .Create(); alert.Show(); // A second alert dialogue, confirming the decision to delete Button negative = alert.GetButton((int)DialogButtonType.Negative); negative.Click += delegate(object s, EventArgs e) { Android.Support.V7.App.AlertDialog.Builder confirm = new Android.Support.V7.App.AlertDialog.Builder(this); confirm.SetTitle("Are you sure?"); confirm.SetMessage("The recorded data will be irrecoverably lost."); confirm.SetPositiveButton("Delete", (senderAlert, confArgs) => { AppData.Session.DeleteResult(AppData.Session.ResultsToUpload[args.Position - 1]); RefreshList(); alert.Dismiss(); }); confirm.SetNegativeButton("Cancel", (senderAlert, confArgs) => { }); confirm.Show(); }; }
protected override void UpdateData() { var username = Activity.Intent.GetStringExtra("username"); var password = Activity.Intent.GetStringExtra("password"); var confirm = Activity.Intent.GetStringExtra("confirm"); var name = Activity.Intent.GetStringExtra("name"); var address = Activity.Intent.GetStringExtra("address"); var year = Activity.Intent.GetIntExtra("date year", DateTime.Now.Year); var month = Activity.Intent.GetIntExtra("date month", DateTime.Now.Year); var day = Activity.Intent.GetIntExtra("date day", DateTime.Now.Year); var interests = Activity.Intent.GetIntegerArrayListExtra(InfoType.Interest.ToString()); var foodhabits = Activity.Intent.GetIntegerArrayListExtra(InfoType.FoodHabit.ToString()); var languages = Activity.Intent.GetIntegerArrayListExtra(InfoType.Language.ToString()); //Generates a dialog showing a spinner var pb = new Android.Support.V7.App.AlertDialog.Builder(Activity).Create(); pb.SetView(new ProgressBar(pb.Context)); pb.SetCancelable(false); pb.Show(); ThreadPool.QueueUserWorkItem(o => { //Tries to create the user on the server if (MainActivity.CIF.CreateUser(name, address, new DateTimeOffset(year, month, day, 0, 0, 0, new TimeSpan(0)), username, password, confirm)) { MainActivity.CIF.Login(username, password); foreach (var interest in interests) { MainActivity.CIF.AddInformation(new InfoChange(InfoType.Interest, (int)interest, 1)); } foreach (var foodhabit in foodhabits) { MainActivity.CIF.AddInformation(new InfoChange(InfoType.FoodHabit, (int)foodhabit, 1)); } foreach (var language in languages) { MainActivity.CIF.AddInformation(new InfoChange(InfoType.Language, (int)language, 1)); } //Removes the spinner again Activity.RunOnUiThread(() => pb.Dismiss()); var profileIntent = new Intent(Activity, typeof(ProfileActivity)); Activity.StartActivity(profileIntent); } else { //Removes the spinner again Activity.RunOnUiThread(() => { pb.Dismiss(); //Generates a dialog showing an errormessage var errorDialog = new Android.Support.V7.App.AlertDialog.Builder(Activity); errorDialog.SetMessage(MainActivity.CIF.LatestError); errorDialog.SetNegativeButton(Resource.String.ok, (s, earg) => { }); errorDialog.Show(); }); } }); }