// PickMap_Click button clicked private void PickMap_Click(object sender, EventArgs e) { //#if (FULL) // Create intent to launch configuration activity var intent = new Intent(this, typeof(PickActivity)); // Create coordinates to pass List <string> parameters = new List <string>(); String coord = txtCoord.Text; String sLat = ""; String sLon = ""; if (GCStuffs.TryToConvertCoordinates(coord, ref sLat, ref sLon)) { parameters.Add(sLat); parameters.Add(sLon); } else { parameters.Add(""); parameters.Add(""); } String radius = FindViewById <EditText>(Resource.Id.editRadius).Text; if (!String.IsNullOrEmpty(radius)) { parameters.Add(radius); } intent.PutStringArrayListExtra("coordinates", parameters); // Start the activity waiting for a result StartActivityForResult(intent, 10); // 10 for map return; //#endif /* #if (LITE) * Toast.MakeText(this, this.Resources.GetString(Resource.String.OnlyFullMap), ToastLength.Long).Show(); * return; #endif */ }
private void CreateNotifications() { // Check if internet access is available if (!GCStuffs.CheckNetworkAccess(this)) { Toast.MakeText(this, this.Resources.GetString(Resource.String.NoInternet), ToastLength.Short).Show(); return; } try { // Get all the nested values // Get coordinates String coord = txtCoord.Text; String sLat = ""; String sLon = ""; if (!GCStuffs.TryToConvertCoordinates(coord, ref sLat, ref sLon)) { // Cancel creation wrong coordinates Toast.MakeText(this, this.Resources.GetString(Resource.String.BadCoordinates), ToastLength.Short).Show(); return; } // convert to double double dlat = GCStuffs.ConvertToDouble(sLat); double dlon = GCStuffs.ConvertToDouble(sLon); // Get radius String radius = FindViewById <EditText>(Resource.Id.editRadius).Text; int distance = 0; if (!Int32.TryParse(radius, out distance) || (distance == 0)) { // Cancel creation wrong radius Toast.MakeText(this, this.Resources.GetString(Resource.String.BadDistance), ToastLength.Short).Show(); return; } // Get Name String name = FindViewById <EditText>(Resource.Id.editName).Text; if (name == "") { // Cancel creation since empty name Toast.MakeText(this, this.Resources.GetString(Resource.String.BadName), ToastLength.Short).Show(); return; } // Email Spinner mySpinner = FindViewById <Spinner>(Resource.Id.spinnerEmail); String email = ""; if (mySpinner.Visibility != ViewStates.Invisible) { if (mySpinner.SelectedItem != null) { email = mySpinner.SelectedItem.ToString(); } /* * if (email == "") * { * // Cancel creation since empty name * Toast.MakeText(this, this.Resources.GetString(Resource.String.BadEmail), ToastLength.Short).Show(); * return; * }*/ } // Types : check that at least one type is checked List <Tuple <int, string, List <string>, int> > selectedTypes = new List <Tuple <int, string, List <string>, int> >(); foreach (var tc in _typecaches) { // Is it checked ? if (tc.Checked) { // Yes, so we find the correspoding tuple foreach (var tpl in _allowedtypes) { if (tpl.Item2 == tc.Type) { // Found it ! selectedTypes.Add(tpl); } } } } // At least one type selected ? int nbsel = selectedTypes.Count; if (nbsel == 0) { // Cancel creation since no type Toast.MakeText(this, this.Resources.GetString(Resource.String.NoType), ToastLength.Short).Show(); return; } else { // Check if we go higher that 40 notifications if ((nbNotifs + nbsel) > 40) { int maxnb = 40 - nbNotifs; String msg = String.Format(this.Resources.GetString(Resource.String.MaxNotifWillReached), nbNotifs, maxnb); Toast.MakeText(this, msg, ToastLength.Long).Show(); return; } } // Ask if we are ready var builder = new AlertDialog.Builder(this); builder.SetMessage(this.Resources.GetString(Resource.String.ConfirmCreate)); builder.SetPositiveButton(this.Resources.GetString(Resource.String.BtnYes), (s, ev) => { // Launch application inside a progress bar ProgressDialog progressDialog = new ProgressDialog(this); progressDialog.SetProgressStyle(ProgressDialogStyle.Horizontal); progressDialog.SetMessage(this.Resources.GetString(Resource.String.LblCreateInProgress)); progressDialog.SetTitle(this.Resources.GetString(Resource.String.OperationInProgress)); progressDialog.Progress = 0; progressDialog.Max = selectedTypes.Count; progressDialog.SetCancelable(false); _Canceled = false; progressDialog.SetButton((int)(DialogButtonType.Negative), this.Resources.GetString(Resource.String.Cancel), (st, evt) => { // Tell the system about cancellation _Canceled = true; }); progressDialog.Show(); ThreadPool.QueueUserWorkItem(o => CreateNotificationsImpl(progressDialog, dlat, dlon, distance, name, selectedTypes, email)); }); builder.SetNegativeButton(this.Resources.GetString(Resource.String.BtnNo), (s, ev) => { // do something on Cancel click }); builder.Create().Show(); } catch (Exception) { Toast.MakeText(this, this.Resources.GetString(Resource.String.Error), ToastLength.Short).Show(); } }
// Save button clicked private void Save_Click(object sender, EventArgs e) { // Check if internet access is available if (!GCStuffs.CheckNetworkAccess(this)) { Toast.MakeText(this, this.Resources.GetString(Resource.String.NoInternet), ToastLength.Short).Show(); return; } try { // Get all the nested values // Get coordinates String coord = txtCoord.Text; String sLat = ""; String sLon = ""; if (!GCStuffs.TryToConvertCoordinates(coord, ref sLat, ref sLon)) { // Cancel creation wrong coordinates Toast.MakeText(this, this.Resources.GetString(Resource.String.BadCoordinates), ToastLength.Short).Show(); return; } // convert to double double dlat = GCStuffs.ConvertToDouble(sLat); double dlon = GCStuffs.ConvertToDouble(sLon); // Ask if we are ready var builder = new AlertDialog.Builder(this); builder.SetMessage(this.Resources.GetString(Resource.String.ConfirmUpdateCoord)); builder.SetPositiveButton(this.Resources.GetString(Resource.String.BtnYes), (s, ev) => { // Launch application inside a progress bar ProgressDialog progressDialog = new ProgressDialog(this); progressDialog.SetProgressStyle(ProgressDialogStyle.Horizontal); progressDialog.SetMessage(this.Resources.GetString(Resource.String.LblUpdateInProgress)); progressDialog.SetTitle(this.Resources.GetString(Resource.String.OperationInProgress)); progressDialog.Progress = 0; progressDialog.Max = _ids.Count; progressDialog.SetCancelable(false); _Canceled = false; progressDialog.SetButton((int)(DialogButtonType.Negative), this.Resources.GetString(Resource.String.Cancel), (st, evt) => { // Tell the system about cancellation _Canceled = true; }); progressDialog.Show(); ThreadPool.QueueUserWorkItem(o => UpdateCoord(progressDialog, dlat, dlon)); }); builder.SetNegativeButton(this.Resources.GetString(Resource.String.BtnNo), (s, ev) => { // do something on Cancel click }); builder.Create().Show(); } catch (Exception) { Toast.MakeText(this, this.Resources.GetString(Resource.String.Error), ToastLength.Short).Show(); } }