void Justificativa(string justificativa, CardMenuPDVsModel item) { try { CheckApp(); var gpsLocation = GPS.lastLocation; var batery = GetBatteryLevel(); if (gpsLocation == null) { controller.Justificativa(item.listTypePdv, justificativa, 0, 0, batery); } else { controller.Justificativa(item.listTypePdv, justificativa, gpsLocation.Latitude, gpsLocation.Longitude, batery); } RemoveItem(item); controller.RegistroDePontoEletronico(); if (controller.CheckOutVisita(model.pdvs.Count)) { CheckOutMessage(); } PopulateProgressBar(); MetricsManager.TrackEvent("JustificativaLoja"); Toast.MakeText(this, Resources.GetString(Resource.String.justificativa_sucesso), ToastLength.Long).Show(); } catch (NullReferenceException) { Toast.MakeText(this, Resources.GetString(Resource.String.erro_justificativa), ToastLength.Long).Show(); } }
void ExecMapByGPSCord(CardMenuPDVsModel item) { var gmmIntentUri = Android.Net.Uri.Parse( string.Format("http://maps.google.com/maps?daddr={0}", WebUtility.UrlEncode(item.endereco))); try { MetricsManager.TrackEvent("MapClick"); var mapIntent = new Intent(Intent.ActionView, gmmIntentUri); StartActivity(mapIntent); } catch (ActivityNotFoundException) { Toast.MakeText(this, Resource.String.maps_not_found, ToastLength.Long); } }
public List <CardMenuPDVsModel> PopulateList() { model.pdvs = new List <CardMenuPDVsModel>(); var result = model.pdvs; foreach (TB_VISITA pdv in controller.VisitasPendentes()) { string[] fullGeoPT = pdv.ENDERECO.Split('\n'); string itemLoja = fullGeoPT[0].Split('-')[1].Trim(); string itemEndereco = (fullGeoPT[1] + " " + fullGeoPT[2].Replace(" - CEP:", ", CEP:")); var index = model.pdvs.FindIndex(CardMenuPDVsModel => (CardMenuPDVsModel.name.Equals(itemLoja) && CardMenuPDVsModel.endereco.Equals(itemEndereco))); var infoPdv = new ListTypePDV(pdv.ID); if (index >= 0 && result.Count > 0) { if (result[index].listTypePdv.FindIndex(ListTypePDV => (ListTypePDV.IdVisita.Equals(infoPdv.IdVisita))) < 0) { result[index].listTypePdv.Add(infoPdv); } } else { var justificativaTextView = new TextView(this) { Text = Resources.GetString(Resource.String.justificativa_card) }; justificativaTextView.Click += delegate { }; var checkIn = new TextView(this) { Text = Resources.GetString(Resource.String.check_in_card) }; checkIn.Click += delegate { }; var itemCard = new CardMenuPDVsModel(itemLoja, pdv.LAT_PDV, pdv.LONG_PDV, itemEndereco, Resources.GetString(Resource.String.justificar_card), HandleClickJustificativa, Resources.GetString(Resource.String.check_in_card), HandleClickCheckIN, Resources.GetString(Resource.String.map_card), HandleClickMap, infoPdv); result.Add(itemCard); } } return(result); }
void RemoveItem(CardMenuPDVsModel item) { var index = model.pdvs.FindIndex(CardMenuPDVsModel => (CardMenuPDVsModel.name.Equals(item.name) && CardMenuPDVsModel.endereco.Equals(item.endereco))); if (index > -1) { model.pdvs.RemoveAt(index); if (model.adapter != null) { model.adapter.NotifyDataSetChanged(); } } if (string.IsNullOrEmpty(filterPDV) && model.adapter != null) { model.adapter.Filter.InvokeFilter(""); } else if (model.adapter != null) { model.adapter.Filter.InvokeFilter(filterPDV); } }
void CheckIn(CardMenuPDVsModel item) { try { var isToOpenTarefas = false; CheckApp(); var batery = GetBatteryLevel(); var gpsLocation = GPS.lastLocation; var cordenadaEsperada = controller.GetCoordinates(item.listTypePdv); var gpsEsperado = new Android.Locations.Location("GpsEsperado") { Latitude = cordenadaEsperada[0], Longitude = cordenadaEsperada[1] }; if (gpsEsperado == null) { isToOpenTarefas = true; controller.CheckIn(item.listTypePdv, 0, 0, batery); } else { var distance = gpsEsperado.DistanceTo(gpsLocation); if (distance > 500 && (int)cordenadaEsperada[0] > 0 && (int)cordenadaEsperada[1] > 0) { AlertDialog.Builder dialogBuilder; dialogBuilder = new AlertDialog.Builder(this, Resource.Style.DialogTheme); dialogBuilder.SetTitle(Resources.GetString(Resource.String.PDV_Distante)); dialogBuilder.SetMessage(Resources.GetString(Resource.String.PDV_Distante_descricao)); dialogBuilder.SetPositiveButton(Resources.GetString(Resource.String.sim), delegate { try { controller.CheckIn(item.listTypePdv, gpsLocation.Latitude, gpsLocation.Longitude, batery); controller.RegistroDePontoEletronico(); MetricsManager.TrackEvent("CheckInLoja"); isToRunning = false; var i = new Intent(this, typeof(MenuTarefas)); i.PutExtra("lojaSelecionada", item.name); i.PutStringArrayListExtra("idUser", controller.PrepareIdsUserToIntent()); i.PutExtra("visitas", new ListTypePDV().ToIntentVar(item.listTypePdv)); var options = ActivityOptions.MakeSceneTransitionAnimation(this, Pair.Create(FindViewById(Resource.Id.profile_image_pdv), "profileImage"), Pair.Create(FindViewById(Resource.Id.profileBarLayout), "profileBar"), Pair.Create(FindViewById(Resource.Id.toolbar), "toolbar")); StartActivity(i, options.ToBundle()); } catch (NullReferenceException) { Toast.MakeText(this, Resources.GetString(Resource.String.erro_checkin), ToastLength.Long).Show(); } catch (Java.Lang.NullPointerException) { Toast.MakeText(this, Resources.GetString(Resource.String.erro_checkin), ToastLength.Long).Show(); } }); dialogBuilder.SetNegativeButton(Resources.GetString(Resource.String.nao), delegate { MetricsManager.TrackEvent("CancelCheckIn"); }); model.modelGeneric.dialog = dialogBuilder.Create(); RunOnUiThread(() => model.modelGeneric.dialog.Show()); } else { try { isToOpenTarefas = true; controller.CheckIn(item.listTypePdv, gpsLocation.Latitude, gpsLocation.Longitude, batery); } catch (NullReferenceException ex) { MetricsManager.TrackEvent("CheckInFail"); MetricsManager.TrackEvent(ex.Message); Toast.MakeText(this, Resources.GetString(Resource.String.erro_checkin), ToastLength.Long).Show(); } catch (Java.Lang.NullPointerException exPointer) { MetricsManager.TrackEvent("CheckInFail"); MetricsManager.TrackEvent(exPointer.Message); Toast.MakeText(this, Resources.GetString(Resource.String.erro_checkin), ToastLength.Long).Show(); } } } if (isToOpenTarefas) { controller.RegistroDePontoEletronico(); MetricsManager.TrackEvent("CheckInLoja"); var i = new Intent(this, typeof(MenuTarefas)); i.PutExtra("lojaSelecionada", item.name); i.PutStringArrayListExtra("idUser", controller.PrepareIdsUserToIntent()); i.PutExtra("visitas", new ListTypePDV().ToIntentVar(item.listTypePdv)); var options = ActivityOptions.MakeSceneTransitionAnimation(this, Pair.Create(FindViewById(Resource.Id.profile_image_pdv), "profileImage"), Pair.Create(FindViewById(Resource.Id.profileBarLayout), "profileBar"), Pair.Create(FindViewById(Resource.Id.toolbar), "toolbar")); StartActivity(i, options.ToBundle()); } } catch (NullReferenceException) { Toast.MakeText(this, Resources.GetString(Resource.String.erro_checkin), ToastLength.Long).Show(); } catch (Java.Lang.NullPointerException) { Toast.MakeText(this, Resources.GetString(Resource.String.erro_checkin), ToastLength.Long).Show(); } }