void showAlert(AlertDialog.Builder builder) { alert = builder.Create(); alert.Show(); var acceptButton = alert.GetButton((int)DialogButtonType.Positive); acceptButton.Click += saveNewDrink; var cancelButton = alert.GetButton((int)DialogButtonType.Negative); cancelButton.Click += (sender, e) => { alert.Dismiss(); }; }
public async void Load() { LoadingDialog builder = new LoadingDialog(this).SetMessage("Загрузка..."); Android.App.AlertDialog dialog = builder.Create(); dialog.Show(); string response = await Connector.GetAsync("phrase.set") ?? "{}"; var data = JObject.Parse(response); if (data?["status"] == null) { Toast.MakeText(this, "Произошла ошибка :(", ToastLength.Short).Show(); dialog.Dismiss(); Finish(); return; } Phrases = new List <Phrase>(); foreach (var item in (JArray)data["result"]) { Phrase ph = new Phrase { Id = Convert.ToInt32(item["id"]), Text = Convert.ToString(item["text"]) }; Phrases.Add(ph); } BuildElements(); dialog.Dismiss(); }
private void OnSelectButtonClick(string playlistId) { if (_state.Value != State.Waiting && _state.Value != State.Failed) { return; } AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this, Resource.Style.DialogTheme); LayoutInflater inflater = (LayoutInflater)GetSystemService(LayoutInflaterService); View popupView = inflater.Inflate(Resource.Layout.popup, null); dialogBuilder.SetView(popupView); AlertDialog dialog = dialogBuilder.Create(); dialog.Show(); popupView.FindViewById <Button>(Resource.Id.shuffle_button).Click += (sender, e) => { dialog.Dismiss(); OnShuffleButtonClick(playlistId, ShuffleMode.Shuffle, popupView); }; popupView.FindViewById <Button>(Resource.Id.restrict_button).Click += (sender, e) => { dialog.Dismiss(); OnShuffleButtonClick(playlistId, ShuffleMode.Restrict, popupView); }; popupView.FindViewById <EditText>(Resource.Id.restrict_value).Text = GetSharedPreferences("SPOTIFY", 0).GetString("RESTRICT_VALUE", "10"); }
private void _ButtonOk_Click(object sender, EventArgs e) { Intent intent = new Intent(this, typeof(Settings)); StartActivity(intent); alertDialogAndroid.Dismiss(); }
private void ListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e) { int item = e.Position; if (IsThereAnAppToTakePictures()) { CreateDirectoryForPictures(); } if (item == 0) { Intent intent = new Intent(MediaStore.ActionImageCapture); BitmapHelper._file = new File(BitmapHelper._dir, String.Format("myPhotoTemp_{0}.jpg", Guid.NewGuid())); intent.PutExtra(MediaStore.ExtraOutput, Android.Net.Uri.FromFile(BitmapHelper._file)); StartActivityForResult(intent, CAMERA_REQUEST); } else if (item == 1) { Intent = new Intent(); Intent.SetType("image/*"); Intent.SetAction(Intent.ActionGetContent); StartActivityForResult(Intent.CreateChooser(Intent, "Select Picture"), PickImageId); } dlgAlert.Dismiss(); }
public void ShowConfirmDelete(string alerTitle, string alertMessage, string id) { Android.App.AlertDialog.Builder showDialog = new Android.App.AlertDialog.Builder(this); Android.App.AlertDialog Alert = showDialog.Create(); Alert.SetTitle(alerTitle); Alert.SetMessage(alertMessage); Alert.SetButton("YES", delegate { try { string URL = "https://download-tracker.herokuapp.com/movies/" + id; DeleteMovie(URL); } catch (Exception e) { Console.WriteLine(e.Message); } }); Alert.SetButton2("NO", delegate { Alert.Dismiss(); Alert.Dispose(); return; }); Alert.Show(); }
private void ShowLogoutDialog() { builder = new Android.App.AlertDialog.Builder(mainActivity); alertDialog = builder.Create(); alertDialog.SetMessage("Do you want to log out?"); alertDialog.SetButton("Yes", (s1, e1) => { var auth = sessionManager.GetFirebaseAuth(); editor = preferences.Edit(); LoginManager.Instance.LogOut(); auth.SignOut(); editor.Clear(); editor.Commit(); var intent = new Intent(Application.Context, typeof(OnboardingActivity)); intent.SetFlags(ActivityFlags.ClearTask | ActivityFlags.ClearTop | ActivityFlags.NewTask); StartActivity(intent); mainActivity.Finish(); }); alertDialog.SetButton2("No", (s2, e2) => { alertDialog.Dismiss(); }); alertDialog.Show(); }
// Initiates a dialogue to be shown to the end use if the form has invalid inputs. private void InitiateInvalidInputsAlertDialogue() { invalidInputsAlert = new AlertDialog.Builder(this).Create(); invalidInputsAlert.SetTitle("Invalid Fields"); invalidInputsAlert.SetMessage("Please complete all required fields."); invalidInputsAlert.SetButton("Okay", (sender, args) => { invalidInputsAlert.Dismiss(); }); }
// Initiates an alert dialogue to provide confirmation for a `delete` action by an end user. private void InitiateDeleteAlertDialogue() { deletionAlert = new AlertDialog.Builder(this).Create(); deletionAlert.SetTitle("Confirm deletion"); deletionAlert.SetMessage("Are you sure you wish to delete this question?"); deletionAlert.SetButton("Confirm", DeletionAlertConfirmButtonClick); deletionAlert.SetButton2("Dismiss", (sender, args) => { deletionAlert.Dismiss(); }); }
public async void OnDialogDismiss(object sender, EventArgs args) { if (_dialogue != null) { _dialogue.Dismiss(); //not sure if this is actually needed but if it isnt broke... } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); LinearLayout main = new LinearLayout(this); main.Orientation = Orientation.Vertical; main.SetGravity(GravityFlags.Top); SetContentView(main); EditText editor = new EditText(this); editor.SetHeight(Screen.Height / 4); editor.Gravity = GravityFlags.Left | GravityFlags.Top; main.AddView(editor); Button send = new Button(this); send.Text = "Отправить комментарий"; send.Click += async delegate { if (String.IsNullOrWhiteSpace(editor.Text)) { return; } InputMethodManager inputManager = (InputMethodManager)GetSystemService(Activity.InputMethodService); inputManager.HideSoftInputFromWindow(editor.WindowToken, 0); var data = new NameValueCollection(); data.Add("name", Options.ClientName); data.Add("comment", editor.Text); LoadingDialog builder = new LoadingDialog(this).SetMessage("Отправка..."); Android.App.AlertDialog dialog = builder.Create(); dialog.Show(); string responce = await Connector.PostAsync("comment.add", data) ?? "{}"; bool added = JObject.Parse(responce)?["status"] != null; if (added) { Snackbar bar = Snackbar.Make(send, "Комментарий отправлен :)", Snackbar.LengthShort); bar.Show(); editor.Text = ""; } else { Snackbar.Make(send, "Произошла ошибка :(", Snackbar.LengthIndefinite) .SetAction("Ok", delegate { }) .Show(); } dialog.Dismiss(); }; main.AddView(send); }
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); } }
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(); }
public void ShowUserLoginErrorDialog() { Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this); Android.App.AlertDialog alert = dialog.Create(); alert.SetTitle("Alert!"); alert.SetMessage("User not found!"); alert.SetButton("Retry", (c, ev) => { alert.Dismiss(); }); alert.Show(); }
public void ShowInvalidInputDialog() { Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this); Android.App.AlertDialog alert = dialog.Create(); alert.SetTitle("Alert!"); alert.SetMessage("Please enter your email and password"); alert.SetButton("OK", (c, ev) => { alert.Dismiss(); }); alert.Show(); }
public void ShowEmailFormatErrorDialog() { Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this); Android.App.AlertDialog alert = dialog.Create(); alert.SetTitle("Alert!"); alert.SetMessage("Use a correct email format."); alert.SetButton("Retry", (c, ev) => { alert.Dismiss(); }); alert.Show(); }
public void ShowErrorDialog() { Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this); Android.App.AlertDialog alert = dialog.Create(); alert.SetTitle("Alert!"); alert.SetMessage("Error adding the new user."); alert.SetButton("Retry", (c, ev) => { alert.Dismiss(); }); alert.Show(); }
public void ShowTextLenghtErrorDialog() { Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this); Android.App.AlertDialog alert = dialog.Create(); alert.SetTitle("Alert!"); alert.SetMessage("All data entered must have a minimum of 5 characters."); alert.SetButton("Retry", (c, ev) => { alert.Dismiss(); }); alert.Show(); }
private void AttachSocketEvents(AlertDialog alert) { // Whenever the server emits "login", log the login message socket.On("login", data => { if (alert != null) { alert.Dismiss(); alert.Dispose(); alert = null; } var d = Data.FromData(data); connected = true; // Display the welcome message AddMessage("Welcome to Socket.IO Chat – ", true); AddParticipantsMessage(d.numUsers); }); // Whenever the server emits "new message", update the chat body socket.On("new message", data => { var d = Data.FromData(data); AddMessage(d.message, username: d.username); }); // Whenever the server emits "user joined", log it in the chat body socket.On("user joined", data => { var d = Data.FromData(data); AddMessage(d.username + " joined"); AddParticipantsMessage(d.numUsers); }); // Whenever the server emits "user left", log it in the chat body socket.On("user left", data => { var d = Data.FromData(data); AddMessage(d.username + " left"); AddParticipantsMessage(d.numUsers); UpdateChatTyping(d.username, true); }); // Whenever the server emits "typing", show the typing message socket.On("typing", data => { var d = Data.FromData(data); UpdateChatTyping(d.username, false); }); // Whenever the server emits "stop typing", kill the typing message socket.On("stop typing", data => { var d = Data.FromData(data); UpdateChatTyping(d.username, true); }); }
private void FuncijaZaNoviNit(string s) { PretragaKriterijumDto pretraga = new PretragaKriterijumDto(); pretraga.IdKorisnika = MSettings.CurrentSession.LoggedUser.UserID; pretraga.Kriterijum = s; try { this.listaPretrage = Api.Api.SearchUsers(pretraga); layoutPretrage.Visibility = ViewStates.Visible; RunOnUiThread(() => listView.Adapter = new PretragaListAdapter(this, listaPretrage)); alert.Dismiss(); } catch (Exception ex) { RunOnUiThread(() => alert.Dismiss()); RunOnUiThread(() => alertGreska.Show()); } }
public void OnClick(View v) { Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(context); Android.App.AlertDialog alert = dialog.Create(); alert.SetTitle("UnBlock"); alert.SetMessage("Do you want to UnBlock this user"); alert.SetButton("OK", (c, ev) => { RemoveFromBlackListAsync(Convert.ToInt64(item.id)); }); alert.SetButton2("CANCEL", (c, ev) => { alert.Dismiss(); }); alert.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; }
public void OnClick(View v) { Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this.context); Android.App.AlertDialog alert = dialog.Create(); alert.SetTitle("Add Contact"); alert.SetMessage("Do you want to Add this Contact"); alert.SetButton("OK", (c, ev) => { Contact C = new Contact(); C.contactId = Contact.UserId; // C. SaveContact(C); }); alert.SetButton2("CANCEL", (c, ev) => { alert.Dismiss(); }); alert.Show(); }
private void BlockedContactLayout_Click(object sender, EventArgs e) { Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this); Android.App.AlertDialog alert = dialog.Create(); alert.SetTitle("Block Contact"); alert.SetMessage("Do you want to block this contact"); alert.SetButton("OK", (c, ev) => { if (txtBlockContact.Text == "Block") { BlockContact(ContactObject.ContactId); } else { } }); alert.SetButton2("CANCEL", (c, ev) => { alert.Dismiss(); }); 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.."; } }
/// <summary> /// just a helper method to build and show our alert dialog /// </summary> protected void ShowAlertDialog() { Log.Debug (logTag, "MainActivity.ShowAlertDialog"); alert = new AlertDialog.Builder ( this).Create(); alert.SetMessage ("An AlertDialog! Don't forget to clean me up!"); alert.SetTitle ("Hey Cool!"); alert.SetButton ("Ohkaay!", (s,e) => { this.showingAlert = false; alert.Dismiss(); }); alert.Show(); this.showingAlert = true; }
private async void TakeMapOfflineButton_Click(object sender, EventArgs e) { // Create a path for the output mobile map. string tempPath = $"{Path.GetTempPath()}"; string[] outputFolders = Directory.GetDirectories(tempPath, "NapervilleWaterNetwork*"); // Loop through the folder names and delete them. foreach (string dir in outputFolders) { try { // Delete the folder. Directory.Delete(dir, true); } catch (Exception) { // Ignore exceptions (files might be locked, for example). } } // Create a new folder for the output mobile map. string packagePath = Path.Combine(tempPath, @"NapervilleWaterNetwork"); int num = 1; while (Directory.Exists(packagePath)) { packagePath = Path.Combine(tempPath, @"NapervilleWaterNetwork" + num.ToString()); num++; } // Create the output directory. Directory.CreateDirectory(packagePath); try { // Create an offline map task with the current (online) map. OfflineMapTask takeMapOfflineTask = await OfflineMapTask.CreateAsync(_mapView.Map); // Create the default parameters for the task, pass in the area of interest. GenerateOfflineMapParameters parameters = await takeMapOfflineTask.CreateDefaultGenerateOfflineMapParametersAsync(_areaOfInterest); // Get the overrides. GenerateOfflineMapParameterOverrides overrides = await takeMapOfflineTask.CreateGenerateOfflineMapParameterOverridesAsync(parameters); // Create the overrides UI. ParameterOverrideFragment overlayFragment = new ParameterOverrideFragment(overrides, _mapView.Map); // Resume work when the dialog is closed. overlayFragment.FinishedConfiguring += async(o, args) => { // Show the progress dialog while the job is running. _alertDialog.Show(); // Create the job with the parameters and output location. _generateOfflineMapJob = takeMapOfflineTask.GenerateOfflineMap(parameters, packagePath, overrides); // Handle the progress changed event for the job. _generateOfflineMapJob.ProgressChanged += OfflineMapJob_ProgressChanged; // Await the job to generate geodatabases, export tile packages, and create the mobile map package. GenerateOfflineMapResult results = await _generateOfflineMapJob.GetResultAsync(); // Check for job failure (writing the output was denied, e.g.). if (_generateOfflineMapJob.Status != JobStatus.Succeeded) { // Report failure to the user. ShowStatusMessage("Failed to take the map offline."); } // Check for errors with individual layers. if (results.LayerErrors.Any()) { // Build a string to show all layer errors. System.Text.StringBuilder errorBuilder = new System.Text.StringBuilder(); foreach (KeyValuePair <Layer, Exception> layerError in results.LayerErrors) { errorBuilder.AppendLine($"{layerError.Key.Id} : {layerError.Value.Message}"); } // Show layer errors. ShowStatusMessage(errorBuilder.ToString()); } // Display the offline map. _mapView.Map = results.OfflineMap; // Apply the original viewpoint for the offline map. _mapView.SetViewpoint(new Viewpoint(_areaOfInterest)); // Enable map interaction so the user can explore the offline data. _mapView.InteractionOptions.IsEnabled = true; // Change the title and disable the "Take map offline" button. _takeMapOfflineButton.Text = "Map is offline"; _takeMapOfflineButton.Enabled = false; }; overlayFragment.Show(FragmentManager, ""); } catch (TaskCanceledException) { // Generate offline map task was canceled. ShowStatusMessage("Taking map offline was canceled"); } catch (Exception ex) { // Exception while taking the map offline. ShowStatusMessage(ex.Message); } finally { // Hide the loading overlay when the job is done. _alertDialog.Dismiss(); } }
private void _ButtonOk_Click(object sender, EventArgs e) { alertDialogAndroid.Dismiss(); }
private void OnCloseDialog(object sender, DialogClickEventArgs e) { _alert.Dismiss(); }
public void ShowSelfSignedCertificateDialog(string urlToOpen, AlertDialog urlDialog) { var dialogAlert = (new AlertDialog.Builder (homeActivity)).Create (); dialogAlert.SetIcon (Android.Resource.Drawable.IcDialogAlert); dialogAlert.SetTitle ("Waarschuwing"); dialogAlert.SetMessage ("U heeft een webadres opgegeven met een ssl certificaat welke niet geverifieerd is. Weet u zeker dat u wilt doorgaan?"); dialogAlert.SetButton2 ("Cancel", (s, ev) => { dialogAlert.Dismiss(); }); dialogAlert.SetButton ("Ga verder", (s, ev) => { urlDialog.Dismiss (); dialogAlert.Dismiss(); }); dialogAlert.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 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(); } }; }
public void ShowHttpWarningDialog(string urlToOpen, AlertDialog urlDialog) { var dialogAlert = (new AlertDialog.Builder (homeActivity)).Create (); dialogAlert.SetIcon (Android.Resource.Drawable.IcDialogAlert); dialogAlert.SetTitle ("Waarschuwing"); dialogAlert.SetMessage ("U heeft een http webadres opgegeven. Weet u zeker dat u een onbeveiligde verbinding wilt opzetten?"); dialogAlert.SetButton2 ("Cancel", (s, ev) => { dialogAlert.Dismiss(); }); dialogAlert.SetButton ("Ga verder", (s, ev) => { urlDialog.Dismiss (); dialogAlert.Dismiss(); }); dialogAlert.Show (); }
public override bool OnCreateOptionsMenu(IMenu menu) { MenuInflater.Inflate(Resource.Menu.bottom_menu, menu); var searchItem = menu.FindItem(Resource.Id.search); var searchView = MenuItemCompat.GetActionView(searchItem); var _searchView = searchView.JavaCast <Android.Support.V7.Widget.SearchView>(); _searchView.QueryHint = "Pretrazi prijatelja.."; _searchView.QueryTextChange += (s, e) => { if (e.NewText.Equals(String.Empty)) { tabLayout.Visibility = ViewStates.Visible; viewPager.Visibility = ViewStates.Visible; listView.Adapter = null; layoutPretrage.Visibility = ViewStates.Gone; } else { tabLayout.Visibility = ViewStates.Gone; viewPager.Visibility = ViewStates.Gone; layoutPretrage.Visibility = ViewStates.Visible; } }; _searchView.QueryTextSubmit += (s, e) => { _searchView.ClearFocus(); alert = new Android.App.AlertDialog.Builder(this).Create(); alert.SetTitle("Vrsi se pretraga!"); alert.SetMessage("Molimo sacekajte!"); alert.SetCancelable(false); alert.Show(); alertGreska = new Android.App.AlertDialog.Builder(this).Create(); alertGreska.SetTitle("Pretraga neuspesna!"); alertGreska.SetMessage("Nije pronadjeno nijedno poklapanje sa: " + e.Query); alertGreska.SetButton("U redu", delegate(object sender, DialogClickEventArgs args) { alert.Dismiss(); }); Thread novaNit = new Thread(() => FuncijaZaNoviNit(e.Query)); novaNit.Start(); e.Handled = true; }; return(true); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Location_Activity); xamEssF = new XamEssentialFeatures(this); messages = new Messages(this); inflater = LayoutInflater.From(this); auth = inflater.Inflate(Resource.Layout.Authentication, null); logIn = auth.FindViewById <Button>(Resource.Id.logIn); Messages.ToastMessage(message: $"{logIn.Text}"); allText = new MyTexts(this); email = auth.FindViewById <EditText>(Resource.Id.email); locationPersonalName = FindViewById <EditText>(Resource.Id.locationPersonalName); passeword = auth.FindViewById <EditText>(Resource.Id.passeword); dialog = new AlertDialog.Builder(this).Create(); dialog.SetView(auth); db = new DataAccess("location.db3", this); locationPersonalName.TextChanged += delegate { if (string.IsNullOrEmpty(locationPersonalName.Text)) { locationPersonalName.Background = GetDrawable(Resource.Drawable.EditTextBackground); } else { locationPersonalName.Background = GetDrawable(Resource.Drawable.TextEditing); } }; locationDisplayer = FindViewById <TextView>(Resource.Id.locationDisplayer); formatedTime = FindViewById <TextView>(Resource.Id.formatedTime); btnGetLocation = FindViewById <Button>(Resource.Id.getLocation); todayLocations = FindViewById <Button>(Resource.Id.todayLocations); mapLauncher = FindViewById <Button>(Resource.Id.mapLauncher); saveLocation = FindViewById <Button>(Resource.Id.saveLocation); locationLayout = FindViewById <LinearLayout>(Resource.Id.locationLayout); progessLayout = FindViewById <LinearLayout>(Resource.Id.progessLayout); //Messages.ToastMessage($"{accessData.isConnected}"); if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.AccessCoarseLocation) != 0 || ContextCompat.CheckSelfPermission(this, Manifest.Permission.AccessFineLocation) != 0) { RequestPermissions(new string[] { Manifest.Permission.AccessCoarseLocation, Manifest.Permission.AccessFineLocation }, 2); } saveLocation.Click += (s, e) => { LocationsRepository.UpdateTable(locationPersonalName.Text); }; btnGetLocation.Click += (s, e) => { btnGetLocation.Enabled = false; xamEssF.GetLocation(locationDisplayer, locationLayout, progessLayout, btnGetLocation); }; mapLauncher.Click += delegate { xamEssF.navigateToMap(); }; todayLocations.Click += delegate { if (LocationsRepository.GetLastLocation() != null) { Messages.ToastMessage($"Last location id={LocationsRepository.GetLastLocation()._id}"); } else { Messages.ToastMessage("No location in the location table"); } intent = new Intent(this, typeof(locationActivity)); StartActivity(intent); }; passeword.TextChanged += delegate { passeword.Background = GetDrawable(Resource.Drawable.TextEditing); }; email.TextChanged += delegate { email.Background = GetDrawable(Resource.Drawable.TextEditing); }; logIn.Click += (s, e) => { if (db.isLogedIn(email.Text, passeword.Text)) { dialog.Dismiss(); Messages.ToastMessage("LogIn successfully"); } else { email.Background = GetDrawable(Resource.Drawable.ErrorBackground); passeword.Background = GetDrawable(Resource.Drawable.ErrorBackground); Log.Info("info", "LogIn Error"); Messages.ToastMessage("Email or passeword incorrect"); }; }; }