protected async override void OnCreate (Bundle savedInstanceState){ base.OnCreate (savedInstanceState); var prefs = this.GetSharedPreferences ("RunningAssistant.preferences", FileCreationMode.Private); SetContentView (Resource.Layout.agregar_negocio); mToolbar = FindViewById<SupportToolBar> (Resource.Id.toolbar); mScrollView = FindViewById<ScrollView> (Resource.Id.scrollView); SetSupportActionBar (mToolbar); //ESTA ES LA FLECHA PARA ATRÁS SupportActionBar.SetHomeAsUpIndicator (Resource.Drawable.ic_arrow_back); SupportActionBar.SetDisplayHomeAsUpEnabled (true); //SupportActionBar.SetHomeButtonEnabled (true); SupportActionBar.Title = "Añadir Negocio"; mItems = new List<Categoria> (); fossbytes = new List<byte[]>(); deleteimgnegocio = FindViewById<Button> (Resource.Id.deleteimgnegocio); esperadatos = FindViewById<ProgressBar> (Resource.Id.esperadatos); FragmentMap = FindViewById<LinearLayout> (Resource.Id.fragmentmap); mapFrag = (MapFragment)FragmentManager.FindFragmentById(Resource.Id.map); map = mapFrag.Map; Point size = new Point (); Display display = WindowManager.DefaultDisplay; display.GetSize (size); mScreenHeight = size.Y; mToolbar.SetBackgroundColor (Color.Argb (255, 51, 150, 209)); string tag="ASIGNACION"; //Asignacion de variables try{ Log.Debug(tag, "asigna"); nombre = FindViewById<EditText> (Resource.Id.nombre); Log.Debug(tag, "asigna"); descripcion = FindViewById<EditText> (Resource.Id.descripcion); Log.Debug(tag, "asigna"); sitioweb = FindViewById<EditText> (Resource.Id.sitioweb); Log.Debug(tag, "asigna"); email = FindViewById<EditText> (Resource.Id.email); Log.Debug(tag, "asigna"); telefono = FindViewById<EditText> (Resource.Id.telefonoedit); Log.Debug(tag, "asigna"); pais = FindViewById<EditText> (Resource.Id.pais); Log.Debug(tag, "asigna"); ciudad = FindViewById<EditText> (Resource.Id.ciudad); Log.Debug(tag, "asigna"); colonia = FindViewById<EditText> (Resource.Id.colonia); Log.Debug(tag, "asigna"); calle = FindViewById<EditText> (Resource.Id.calle); Log.Debug(tag, "asigna"); numero = FindViewById<EditText> (Resource.Id.numero); Log.Debug(tag, "asigna"); codigopostal = FindViewById<EditText> (Resource.Id.codigopostal); Log.Debug(tag, "asigna"); referencias = FindViewById<EditText> (Resource.Id.referencias); Log.Debug(tag, "asigna"); facebook = FindViewById<EditText> (Resource.Id.facebook); Log.Debug(tag, "asignaeste"); twitter = FindViewById<EditText> (Resource.Id.twitter); Log.Debug(tag, "asignaultimo"); whatsapp = FindViewById<EditText> (Resource.Id.whatsapp); Log.Debug(tag, "asignaultimoultimo"); tagsnegocio = FindViewById<EditText> (Resource.Id.tagsnegocio); Log.Debug(tag, "pasó"); //<!-- Dias de la semana --> Log.Debug(tag, "asigna"); lunes_a = FindViewById<TextView> (Resource.Id.lunes_a); Log.Debug(tag, "asigna"); lunes_c = FindViewById<TextView> (Resource.Id.lunes_c); Log.Debug(tag, "asigna"); martes_a = FindViewById<TextView> (Resource.Id.martes_a); Log.Debug(tag, "asigna"); martes_c = FindViewById<TextView> (Resource.Id.martes_c); Log.Debug(tag, "asigna"); miercoles_a = FindViewById<TextView> (Resource.Id.miercoles_a); Log.Debug(tag, "asigna"); miercoles_c = FindViewById<TextView> (Resource.Id.miercoles_c); Log.Debug(tag, "asigna"); jueves_a = FindViewById<TextView> (Resource.Id.jueves_a); Log.Debug(tag, "asigna"); jueves_c = FindViewById<TextView> (Resource.Id.jueves_c); Log.Debug(tag, "asigna"); viernes_a = FindViewById<TextView> (Resource.Id.viernes_a); Log.Debug(tag, "asigna"); viernes_c = FindViewById<TextView> (Resource.Id.viernes_c); Log.Debug(tag, "asigna"); sabado_a = FindViewById<TextView> (Resource.Id.sabado_a); Log.Debug(tag, "asigna"); sabado_c = FindViewById<TextView> (Resource.Id.sabado_c); Log.Debug(tag, "asigna"); domingo_a = FindViewById<TextView> (Resource.Id.domingo_a); Log.Debug(tag, "asigna"); domingo_c = FindViewById<TextView> (Resource.Id.domingo_c); Log.Debug(tag, "asigna"); //<!-- Radio Groups --> Log.Debug(tag, "asigna"); region = FindViewById<RadioGroup> (Resource.Id.region); Log.Debug(tag, "asigna"); reservaciones = FindViewById<RadioGroup> (Resource.Id.reservaciones); Log.Debug(tag, "asigna"); entregaadomicilio = FindViewById<RadioGroup> (Resource.Id.entregaadomicilio); Log.Debug(tag, "asigna"); parallevar = FindViewById<RadioGroup> (Resource.Id.parallevar); Log.Debug(tag, "asigna"); aceptatarjeta = FindViewById<RadioGroup> (Resource.Id.aceptatarjeta); Log.Debug(tag, "asigna"); ambientefamiliar = FindViewById<RadioGroup> (Resource.Id.ambientefamiliar); Log.Debug(tag, "asigna"); estacionamiento = FindViewById<RadioGroup> (Resource.Id.estacionamiento); Log.Debug(tag, "asigna"); nivelruido = FindViewById<RadioGroup> (Resource.Id.nivelruido); Log.Debug(tag, "asigna"); alcohol = FindViewById<RadioGroup> (Resource.Id.alcohol); Log.Debug(tag, "asigna"); tienetv = FindViewById<RadioGroup> (Resource.Id.tienetv); Log.Debug(tag, "asigna"); tienemeseros = FindViewById<RadioGroup> (Resource.Id.tienemeserios); Log.Debug(tag, "asigna"); enviarnegocio = FindViewById<Button> (Resource.Id.enviarnegociop); imhere=FindViewById<Button> (Resource.Id.imhere); }catch(Exception ex){ Log.Debug (tag, "f**k: "+ex); } //Se llena el Spinner de las categorías try{ categorias_array = await plifserver.FetchWeatherAsync("http://plif.mx/mobile/get_cats_neg"); objeto = categorias_array["respuesta"]; Log.Debug("AgregarNegocio", "Antes del Foreach"); foreach(JsonObject data in objeto){ Log.Debug("AgregarNegocio", "Entra Foreach: "+data["categorias"]["id"]+" "+data["categorias"]["nombre"]); mItems.Add(new Categoria(){ Id = data["categorias"]["id"], Nombre = data["categorias"]["nombre"] }); Log.Debug("AgregarNegocio", "Sale de Foreach"); } }catch(Exception ex){ Toast.MakeText (Application.Context, "Ocurrió un error al recuperar las categorías", ToastLength.Long).Show (); Log.Debug ("Foreach","ERRORRRR!!! "+ex.ToString()); } //Se asignan las categorias al spinnes Spinner categ = FindViewById<Spinner> (Resource.Id.categorias); MyNegociosAdapter adapter_c = new MyNegociosAdapter (Application.Context, mItems); categ.Adapter = adapter_c; //Se crea el event handler para las categorías try{ categ.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs> (c_spinner_ItemSelected); }catch(Exception ex){ Log.Debug ("Handler","Lel, error: "+ex.ToString()); } //ya aqui hacemos todo el desmadre enviarnegocio = FindViewById<Button> (Resource.Id.enviarnegociop); if (enviarnegocio == null) { Log.Debug (tag, "es nulo D:"); } hour = DateTime.Now.Hour; minute = DateTime.Now.Minute; //AQUI PARA PONER LAS HORAS!!!!! //INICIA LUNES lunes_a.InputType = Android.Text.InputTypes.Null; lunes_c.InputType = Android.Text.InputTypes.Null; Android.Support.V7.Widget.SwitchCompat lunes_ac = FindViewById<Android.Support.V7.Widget.SwitchCompat> (Resource.Id.lunes_ac); lunes_ac.Click += (object sender, EventArgs e) => { if(lunes_ac.Checked==true){ lunes_a.Text=""; lunes_a.Enabled=true; lunes_c.Text=""; lunes_c.Enabled=true; }else{ lunes_a.Text="Cerrado"; lunes_a.Enabled=false; lunes_c.Text="Cerrado"; lunes_c.Enabled=false; } }; lunes_ac.PerformClick (); lunes_a.Click += (object sender, EventArgs e) => { Log.Debug(tag,"Clickeó lunes a"); currenthour=lunes_a; ShowDialog(TIME_DIALOG_ID); }; lunes_c.Click += (object sender, EventArgs e) => { Log.Debug(tag,"Clickeó lunes c"); currenthour=lunes_c; ShowDialog(TIME_DIALOG_ID); }; //TERMINA LUNES //INICIA martes martes_a.InputType = Android.Text.InputTypes.Null; martes_c.InputType = Android.Text.InputTypes.Null; Android.Support.V7.Widget.SwitchCompat martes_ac = FindViewById<Android.Support.V7.Widget.SwitchCompat> (Resource.Id.martes_ac); martes_ac.Click += (object sender, EventArgs e) => { if(martes_ac.Checked==true){ martes_a.Text=""; martes_a.Enabled=true; martes_c.Text=""; martes_c.Enabled=true; }else{ martes_a.Text="Cerrado"; martes_a.Enabled=false; martes_c.Text="Cerrado"; martes_c.Enabled=false; } }; martes_ac.PerformClick (); martes_a.Click += (object sender, EventArgs e) => { Log.Debug(tag,"Clickeó martes a"); currenthour=martes_a; ShowDialog(TIME_DIALOG_ID); }; martes_c.Click += (object sender, EventArgs e) => { Log.Debug(tag,"Clickeó martes c"); currenthour=martes_c; ShowDialog(TIME_DIALOG_ID); }; //TERMINA martes //INICIA miercoles miercoles_a.InputType = Android.Text.InputTypes.Null; miercoles_c.InputType = Android.Text.InputTypes.Null; Android.Support.V7.Widget.SwitchCompat miercoles_ac = FindViewById<Android.Support.V7.Widget.SwitchCompat> (Resource.Id.miercoles_ac); miercoles_ac.Click += (object sender, EventArgs e) => { if(miercoles_ac.Checked==true){ miercoles_a.Text=""; miercoles_a.Enabled=true; miercoles_c.Text=""; miercoles_c.Enabled=true; }else{ miercoles_a.Text="Cerrado"; miercoles_a.Enabled=false; miercoles_c.Text="Cerrado"; miercoles_c.Enabled=false; } }; miercoles_ac.PerformClick (); miercoles_a.Click += (object sender, EventArgs e) => { Log.Debug(tag,"Clickeó miercoles a"); currenthour=miercoles_a; ShowDialog(TIME_DIALOG_ID); }; miercoles_c.Click += (object sender, EventArgs e) => { Log.Debug(tag,"Clickeó miercoles c"); currenthour=miercoles_c; ShowDialog(TIME_DIALOG_ID); }; //TERMINA miercoles //INICIA jueves jueves_a.InputType = Android.Text.InputTypes.Null; jueves_c.InputType = Android.Text.InputTypes.Null; Android.Support.V7.Widget.SwitchCompat jueves_ac = FindViewById<Android.Support.V7.Widget.SwitchCompat> (Resource.Id.jueves_ac); jueves_ac.Click += (object sender, EventArgs e) => { if(jueves_ac.Checked==true){ jueves_a.Text=""; jueves_a.Enabled=true; jueves_c.Text=""; jueves_c.Enabled=true; }else{ jueves_a.Text="Cerrado"; jueves_a.Enabled=false; jueves_c.Text="Cerrado"; jueves_c.Enabled=false; } }; jueves_ac.PerformClick (); jueves_a.Click += (object sender, EventArgs e) => { Log.Debug(tag,"Clickeó jueves a"); currenthour=jueves_a; ShowDialog(TIME_DIALOG_ID); }; jueves_c.Click += (object sender, EventArgs e) => { Log.Debug(tag,"Clickeó jueves c"); currenthour=jueves_c; ShowDialog(TIME_DIALOG_ID); }; //TERMINA jueves //INICIA viernes viernes_a.InputType = Android.Text.InputTypes.Null; viernes_c.InputType = Android.Text.InputTypes.Null; Android.Support.V7.Widget.SwitchCompat viernes_ac = FindViewById<Android.Support.V7.Widget.SwitchCompat> (Resource.Id.viernes_ac); viernes_ac.Click += (object sender, EventArgs e) => { if(viernes_ac.Checked==true){ viernes_a.Text=""; viernes_a.Enabled=true; viernes_c.Text=""; viernes_c.Enabled=true; }else{ viernes_a.Text="Cerrado"; viernes_a.Enabled=false; viernes_c.Text="Cerrado"; viernes_c.Enabled=false; } }; viernes_ac.PerformClick (); viernes_a.Click += (object sender, EventArgs e) => { Log.Debug(tag,"Clickeó viernes a"); currenthour=viernes_a; ShowDialog(TIME_DIALOG_ID); }; viernes_c.Click += (object sender, EventArgs e) => { Log.Debug(tag,"Clickeó viernes c"); currenthour=viernes_c; ShowDialog(TIME_DIALOG_ID); }; //TERMINA viernes //INICIA sabado sabado_a.InputType = Android.Text.InputTypes.Null; sabado_c.InputType = Android.Text.InputTypes.Null; Android.Support.V7.Widget.SwitchCompat sabado_ac = FindViewById<Android.Support.V7.Widget.SwitchCompat> (Resource.Id.sabado_ac); sabado_ac.Click += (object sender, EventArgs e) => { if(sabado_ac.Checked==true){ sabado_a.Text=""; sabado_a.Enabled=true; sabado_c.Text=""; sabado_c.Enabled=true; }else{ sabado_a.Text="Cerrado"; sabado_a.Enabled=false; sabado_c.Text="Cerrado"; sabado_c.Enabled=false; } }; sabado_ac.PerformClick (); sabado_a.Click += (object sender, EventArgs e) => { Log.Debug(tag,"Clickeó sabado a"); currenthour=sabado_a; ShowDialog(TIME_DIALOG_ID); }; sabado_c.Click += (object sender, EventArgs e) => { Log.Debug(tag,"Clickeó sabado c"); currenthour=sabado_c; ShowDialog(TIME_DIALOG_ID); }; //TERMINA sabado //INICIA domingo domingo_a.InputType = Android.Text.InputTypes.Null; domingo_c.InputType = Android.Text.InputTypes.Null; Android.Support.V7.Widget.SwitchCompat domingo_ac = FindViewById<Android.Support.V7.Widget.SwitchCompat> (Resource.Id.domingo_ac); domingo_ac.Click += (object sender, EventArgs e) => { if(domingo_ac.Checked==true){ domingo_a.Text=""; domingo_a.Enabled=true; domingo_c.Text=""; domingo_c.Enabled=true; }else{ domingo_a.Text="Cerrado"; domingo_a.Enabled=false; domingo_c.Text="Cerrado"; domingo_c.Enabled=false; } }; domingo_ac.PerformClick (); domingo_a.Click += (object sender, EventArgs e) => { Log.Debug(tag,"Clickeó domingo a"); currenthour=domingo_a; ShowDialog(TIME_DIALOG_ID); }; domingo_c.Click += (object sender, EventArgs e) => { Log.Debug(tag,"Clickeó domingo c"); currenthour=domingo_c; ShowDialog(TIME_DIALOG_ID); }; //TERMINA domingo //TERMINA LO DE PARA PONER LAS HORAS imhere.Click += async (object sender, EventArgs e) => { Log.Debug(tag, "I am here!!"); if(lat =="" && lng ==""){ //aun no hay geo Log.Debug(tag,"Aun no hay geo"); Toast.MakeText (Application.Context, "Aún estamos localizando tu ubicación. Inténtalo en un momento!", ToastLength.Long).Show (); }else{ geo_lat=lat; geo_long=lng; Geocoder geocoder = new Geocoder(Application.Context, Java.Util.Locale.Default); IList<Address> lista; lista = await geocoder.GetFromLocationAsync(Convert.ToDouble(lat), Convert.ToDouble(lng), 10); Address address = lista.FirstOrDefault(); if(address!=null){ StringBuilder deviceAddress = new StringBuilder(); //Obtener calle y número string[] lines = Regex.Split(address.GetAddressLine(0), " "); string calle=""; string colonia=address.GetAddressLine(1); for(int j=0; j<=lines.Length-2; j++ ){ calle=calle+lines[j]+" "; } string numero=lines[lines.Length-1]; string codigopostal=""; string[] cpciudad=Regex.Split(address.GetAddressLine(2), " "); codigopostal=cpciudad[0]; string preciudad=""; for(int k=1; k<=cpciudad.Length-1; k++){ preciudad=preciudad+cpciudad[k]; } string[] getciudad=Regex.Split(preciudad, ","); string ciudad=getciudad[0]; string paiss="Mexico"; // Toast.MakeText (Application.Context, "La calle es: "+calle, ToastLength.Long).Show (); FindViewById<EditText> (Resource.Id.calle).Text=calle; // Toast.MakeText (Application.Context, "El número es: "+numero, ToastLength.Long).Show (); FindViewById<EditText> (Resource.Id.numero).Text=numero; // Toast.MakeText (Application.Context, "La Colonia es: "+colonia, ToastLength.Long).Show (); FindViewById<EditText> (Resource.Id.colonia).Text=colonia; // Toast.MakeText (Application.Context, "El Codigo Postal es: "+codigopostal, ToastLength.Long).Show (); FindViewById<EditText> (Resource.Id.codigopostal).Text=codigopostal; // Toast.MakeText (Application.Context, "La ciudad es: "+ciudad, ToastLength.Long).Show (); FindViewById<EditText> (Resource.Id.codigopostal).Text=codigopostal; // Toast.MakeText (Application.Context, "El País es: "+paiss, ToastLength.Long).Show (); FindViewById<EditText> (Resource.Id.pais).Text=paiss; } } }; Button replicar = FindViewById<Button> (Resource.Id.replicar); LinearLayout horarioscontainer = FindViewById<LinearLayout> (Resource.Id.horarioscontainer); TextView horariostext = FindViewById<TextView> (Resource.Id.horariostext); horariostext.Click += delegate { if(showinghorarios){ horarioscontainer.Visibility=ViewStates.Gone; showinghorarios=false; }else{ horarioscontainer.Visibility=ViewStates.Visible; showinghorarios=true; } }; replicar.Click += delegate { string lunesa = lunes_a.Text; string lunesc = lunes_c.Text; martes_a.Text=lunesa; martes_c.Text=lunesc; miercoles_a.Text=lunesa; miercoles_c.Text=lunesc; jueves_a.Text=lunesa; jueves_c.Text=lunesc; viernes_a.Text=lunesa; viernes_c.Text=lunesc; sabado_a.Text=lunesa; sabado_c.Text=lunesc; domingo_a.Text=lunesa; domingo_c.Text=lunesc; }; Log.Debug (tag,"Aquí iniciamos a poner los botones de las imagenes"); GridLayout imgnegocioprev = FindViewById<GridLayout> (Resource.Id.imgnegocioprev); TextView masimagenesnegocio = FindViewById<TextView> (Resource.Id.masimagenesnegocio); //INICIAN BOTONES DE IMAGENES imagennegocio=FindViewById<Button> (Resource.Id.imagennegocio); imagennegocio.Click += async (object sender, EventArgs e) => { source=1; ProcesarImagenes(imgnegocioprev, 3, masimagenesnegocio); }; Log.Debug (tag,"pasamos el de imagen negocio"); imagencamaranegocio = FindViewById<Button> (Resource.Id.imagencamaranegocio); imagencamaranegocio.Click += async (object sender, EventArgs e) => { source=2; ProcesarImagenes(imgnegocioprev, 3, masimagenesnegocio); }; //TERMINAN BOTONES DE IMAGENES Log.Debug (tag,"pasamos el de imagen camara negocio"); deleteimgnegocio.Click += async (sender, e) => { //LinearLayout imgcomprev = FindViewById<LinearLayout> (Resource.Id.imgcomprev); //LinearLayout imgcontainercomprev = FindViewById<LinearLayout> (Resource.Id.imgcontainercomprev); Log.Debug("DELETEBUTTON","Inician las layouts"); if(imgnegocioprev.ChildCount>0){ imgnegocioprev.RemoveAllViews(); } Log.Debug("DELETEBUTTON","vistas removidas"); if(imagencomentario!=null){ imagencomentario.Recycle(); imagencomentario=null; } Log.Debug("DELETEBUTTON","reciclado"); //deleteimgrev.Visibility=ViewStates.Gone; Log.Debug("DELETEBUTTON","se oculta boton borrar (deprecated)"); //layoutdejaimagenes.Visibility=ViewStates.Gone; Log.Debug("DELETEBUTTON","se oculta el contenedor de subir imagenes"); fossbytes.Clear(); Log.Debug("DELETEBUTTON","El Arraylist de bytes se resetea"); imgcount=0; Log.Debug("DELETEBUTTON","se resetea el contador de cuantas imagenes se subieron"); masimagenesnegocio.Text="Carga 3 imágenes más!"; Log.Debug("DELETEBUTTON","Reseteamos el texto de las imagenes"); }; enviarnegocio.Click += async (object sender, EventArgs e) => { Log.Debug("boton","hizoclick"); if(nombre.Text == "" || descripcion.Text == "" || sitioweb.Text == "" || email.Text == "" || telefono.Text == "" || pais.Text == "" || ciudad.Text == "" || colonia.Text == "" || calle.Text == "" || numero.Text == "" || codigopostal.Text == "" || referencias.Text == "" || facebook.Text == "" || twitter.Text == "" || whatsapp.Text=="" || tagsnegocio.Text==""){ Toast.MakeText (Application.Context, "Te faltan algunos campos de llenar, por favor revísalos!", ToastLength.Long).Show (); }else{ //Información completa. //http://plif.mx/AgregarNegociop?droid //Aqui nos quedamos. Hay que añadir también enviando=true; enviarnegocio.Visibility=ViewStates.Gone; ProgressBar enviandonegocio= FindViewById<ProgressBar> (Resource.Id.enviandonegocio); enviandonegocio.Visibility=ViewStates.Visible; Dictionary<string, string> diccionario = new Dictionary<string, string>(); diccionario.Add("nombre_completo", prefs.GetString("nombre", null)); diccionario.Add("email_user", prefs.GetString("email", null)); diccionario.Add("id_user", prefs.GetString("id",null)); diccionario.Add("nombre",nombre.Text); diccionario.Add("desc",descripcion.Text); int selectedregion = region.CheckedRadioButtonId; RadioButton nameregion = FindViewById<RadioButton> (selectedregion); string nameregiontext=nameregion.Text; switch(nameregiontext){ case "Durango": //Toast.MakeText (Application.Context, "Region Durango", ToastLength.Long).Show (); diccionario.Add("estado","9"); break; case "Torreón": //Toast.MakeText (Application.Context, "Region Torreon", ToastLength.Long).Show (); diccionario.Add("estado","3"); break; case "Mazatlán": //Toast.MakeText (Application.Context, "Region Mazatlan", ToastLength.Long).Show (); diccionario.Add("estado","2"); break; case "Zacatecas": //Toast.MakeText (Application.Context, "Region Zacatecas", ToastLength.Long).Show (); diccionario.Add("estado","4"); break; default: //Toast.MakeText (Application.Context, "None of the above", ToastLength.Long).Show (); diccionario.Add("estado","0"); break; }//switch región diccionario.Add("categoria",cat_id); diccionario.Add("ubicacion",ciudad.Text); diccionario.Add("email",email.Text); diccionario.Add("sitioweb",sitioweb.Text); diccionario.Add("telefono",telefono.Text); diccionario.Add("facebook",facebook.Text); diccionario.Add("twitter",twitter.Text); diccionario.Add("google",""); //No hay campo para google+ diccionario.Add("pais",pais.Text); //diccionario.Add("ciudad","Durango"); //Todos van a ser Durango ahorita diccionario.Add("ciudad",ciudad.Text); diccionario.Add("geo_long",geo_long); diccionario.Add("geo_lat",geo_lat); diccionario.Add("cp",codigopostal.Text); diccionario.Add("colonia",codigopostal.Text); diccionario.Add("calle",calle.Text); diccionario.Add("numero",numero.Text); diccionario.Add("tags",tagsnegocio.Text); diccionario.Add("sub_categoria","0"); //aun no hay campo de subcategoría diccionario.Add("referencias",referencias.Text); //AÑADIMOS AL DICCIONARIO LOS HORARIOS: diccionario.Add("lunes_de",lunes_a.Text); diccionario.Add("lunes_a",lunes_c.Text); diccionario.Add("martes_de",martes_a.Text); diccionario.Add("martes_a",martes_c.Text); diccionario.Add("miercoles_de",miercoles_a.Text); diccionario.Add("miercoles_a",miercoles_c.Text); diccionario.Add("jueves_de",jueves_a.Text); diccionario.Add("jueves_a",jueves_c.Text); diccionario.Add("viernes_de",viernes_a.Text); diccionario.Add("viernes_a",viernes_c.Text); diccionario.Add("sabado_de",sabado_a.Text); diccionario.Add("sabado_a",sabado_c.Text); diccionario.Add("domingo_de",domingo_a.Text); diccionario.Add("domingo_a",domingo_c.Text); //AÑADIMOS AL DICCIONARIO LA INFORMACION ADICIONAL //acepta reservaciones diccionario.Add("reservation",FindViewById<RadioButton> (reservaciones.CheckedRadioButtonId).Text); //entrega a domicilio diccionario.Add("delivery",FindViewById<RadioButton> (entregaadomicilio.CheckedRadioButtonId).Text); //para llevar diccionario.Add("take-out",FindViewById<RadioButton> (parallevar.CheckedRadioButtonId).Text); //acepta tarjeta diccionario.Add("credit",FindViewById<RadioButton> (aceptatarjeta.CheckedRadioButtonId).Text); //familiar diccionario.Add("kids",FindViewById<RadioButton> (ambientefamiliar.CheckedRadioButtonId).Text); //estacionamiento diccionario.Add("parking",FindViewById<RadioButton> (estacionamiento.CheckedRadioButtonId).Text); //ruido diccionario.Add("noise",FindViewById<RadioButton> (nivelruido.CheckedRadioButtonId).Text); //alcohol diccionario.Add("alcohol",FindViewById<RadioButton> (alcohol.CheckedRadioButtonId).Text); //tiene tv diccionario.Add("tv",FindViewById<RadioButton> (tienetv.CheckedRadioButtonId).Text); //tiene meseros diccionario.Add("meseros",FindViewById<RadioButton> (tienemeseros.CheckedRadioButtonId).Text); //tiene wifi diccionario.Add("wi-fi","No"); //aun no hay campo de wifi //LIIISTO!!! LOS MANDAMOS POR POST CON EL MULTIPART string resp = await plifserver.PostMultiPartForm ("http://plif.mx/AgregarNegociop?droid", fossbytes, "nada", "file[]", "image/jpeg", diccionario, false); Log.Debug(tag,"Termina RESP!!!"); //Log.Debug(tag,"La respuesta es: "+resp); Toast.MakeText (Application.Context, "Tu negocio ha sido enviado con éxito y en breve será revisado. ¡Gracias por formar parte de Plif!", ToastLength.Long).Show (); Finish(); } }; }
public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { base.OnCreateView (inflater, container, savedInstanceState); if (savedInstanceState != null) { //restore fragment here } View view = inflater.Inflate (Resource.Layout.Fragment2, container, false); //Toast.MakeText (Application.Context, "Estas en el fragmento 2", ToastLength.Long).Show (); //ANTES QUE NADA, CREAMOS LOS BOTONES, LOS INPUTS, LAS LAYOUTS Y LOS PROGRESSBAR, Y PORSUPUESTO EL LISTVIEW Button busqueda = view.FindViewById<Button> (Resource.Id.busqueda); //pestaña busqueda Button resultados = view.FindViewById<Button> (Resource.Id.resultados);//pestaña resultados LinearLayout botones = view.FindViewById<LinearLayout> (Resource.Id.linearLayout0); //capa de botones busqueda-resultados LinearLayout cuadbusqueda = view.FindViewById<LinearLayout> (Resource.Id.linearLayout1); //capa de cuadro de busqueda LinearLayout cuadresultados = view.FindViewById<LinearLayout> (Resource.Id.linearLayout3); //capa de cuadro de busqueda LinearLayout prevnext = view.FindViewById<LinearLayout> (Resource.Id.linearLayout4); //capa de botones siguiente y anterior EditText cad = view.FindViewById<EditText> (Resource.Id.cadena); //cuadro de texto que contiene las palabras a buscar //cad.Text="pulpo"; Button buscar = view.FindViewById<Button> (Resource.Id.buscar); //botón de buscar en mi ciudad Button geo = view.FindViewById<Button> (Resource.Id.geo); //botón de buscar cerca de mi Button prev = view.FindViewById<Button> (Resource.Id.prev); //botón de anterior en los resultados Button next = view.FindViewById<Button> (Resource.Id.next); //boton de siguiente en los resultados ProgressBar wait = view.FindViewById<ProgressBar> (Resource.Id.progressBar1); //progress bar para la búsqueda ProgressBar waitpagina = view.FindViewById<ProgressBar> (Resource.Id.progressBar2); //progress bar para las paginas ListView reslista = view.FindViewById<ListView> (Resource.Id.listView1); //la lista donde se mmuestran los resultados de la busqueda TextView noresults = view.FindViewById<TextView> (Resource.Id.textView2); //texto que dice que no se encontraron resultados gps = this.Arguments; //CREAMOS LAS VARIABLES QUE VA A RECIBIR LA API string cadena=""; string lat_long = ""; string lat = ""; string longt = ""; string region_heredada = null; Typeface font = Typeface.CreateFromAsset(Activity.Assets, "Fonts/fa.ttf"); buscar.SetTypeface(font, TypefaceStyle.Normal); geo.SetTypeface(font, TypefaceStyle.Normal); //TERMINAMOS DE CREAR LOS ELEMENTOS, AHORA SI A PROGRAMAR TODO LO DEMÁS busqueda.Click += (sender, e) => { busqueda.SetBackgroundResource(Resource.Drawable.busquedaactive); resultados.SetBackgroundResource(Resource.Drawable.busqueda); //cambiar colores busqueda.SetTextColor(Android.Graphics.Color.ParseColor("#FFFFFF")); resultados.SetTextColor(Android.Graphics.Color.ParseColor("#000000")); //hacer visible el cuadro de busqueda y hacer invisible el cuadro de resultados cuadbusqueda.Visibility=ViewStates.Visible; cuadresultados.Visibility = ViewStates.Gone; }; resultados.Click += (sender, e) => { busqueda.SetBackgroundResource(Resource.Drawable.busqueda); resultados.SetBackgroundResource(Resource.Drawable.busquedaactive); //cambiar colores busqueda.SetTextColor(Android.Graphics.Color.ParseColor("#000000")); resultados.SetTextColor(Android.Graphics.Color.ParseColor("#FFFFFF")); //hacer invisible el cuadro de busqueda y visible el cuadro de resultados cuadbusqueda.Visibility=ViewStates.Gone; cuadresultados.Visibility = ViewStates.Visible; }; //CATEGORIAS Spinner categ = view.FindViewById<Spinner> (Resource.Id.categorias); mItems = new List<Categoria> (); mItems.Add(new Categoria(){ //NegocioName = WebUtility.HtmlDecode(data["Data"]["titulo"]), Id = "", Nombre = "Selecciona una categoría" }); //inicia lo de para traer las categorias Button getcats = view.FindViewById<Button> (Resource.Id.getcats); getcats.Click += async (sender, e) => { JsonValue objeto; try{ categorias_array = await FetchWeatherAsync("http://plif.mx/mobile/get_cats_neg"); objeto = categorias_array["respuesta"]; foreach(JsonObject data in objeto){ mItems.Add(new Categoria(){ Id = data["categorias"]["id"], Nombre = data["categorias"]["nombre"] }); } }catch(Exception ex){ Toast.MakeText (Application.Context, "Ocurrió un error al recuperar las categorías", ToastLength.Long).Show (); } }; getcats.PerformClick (); //termina lo de para traer las categorias MyNegociosAdapter adapter_c = new MyNegociosAdapter (Application.Context, mItems); categ.Adapter = adapter_c; //REGIONES Spinner regio = view.FindViewById<Spinner> (Resource.Id.regiones); ArrayAdapter<String> regadapter; //Android.Resource.Layout.SimpleSpinnerDropDownItem regadapter = new ArrayAdapter<string>(Application.Context, Resource.Layout.spinnerfuck, Resource.Id.company); rItems = new List<Region> (); //AGREGAMOS LAS REGIONES rItems.Add(new Region(){ //NegocioName = WebUtility.HtmlDecode(data["Data"]["titulo"]), Id = "9", Nombre = "Durango" }); rItems.Add(new Region(){ //NegocioName = WebUtility.HtmlDecode(data["Data"]["titulo"]), Id = "2", Nombre = "Mazatlán" }); rItems.Add(new Region(){ //NegocioName = WebUtility.HtmlDecode(data["Data"]["titulo"]), Id = "3", Nombre = "Torreón" }); rItems.Add(new Region(){ //NegocioName = WebUtility.HtmlDecode(data["Data"]["titulo"]), Id = "4", Nombre = "Zacatecas" }); MyRegionesAdapter adapter_r = new MyRegionesAdapter (Application.Context, rItems); regio.Adapter = adapter_r; categ.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs> (c_spinner_ItemSelected); regio.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs> (r_spinner_ItemSelected); buscar.Click += async (sender, e) => { counter=0; reslista.Adapter=null; //ESTE VA A TENER QUE SER ASÍNCRONO! cadena=cad.Text; noresults.Visibility=ViewStates.Gone; //ocultamos el teclado InputMethodManager imm = (InputMethodManager)Application.Context.GetSystemService(Context.InputMethodService); imm.HideSoftInputFromWindow(cad.WindowToken, 0); //primero deberíamos validar que el usuario haya introducido algún texto if((cadena=="" || cadena==null) && (cat_id=="" || cat_id == null) && (region_heredada == null || region_heredada=="")){ Toast.MakeText (Application.Context, "¡Espera! Primero dinos que estás buscando.", ToastLength.Long).Show (); }else{ //antes que nada, comenzamos a armar la url desde la base string uri="http://plif.mx/filtrar.json?"; //comenzaremos desde la pagina 1 pagina=1; //añadimos la cadenas uri=uri+"cadena="+cadena; //añadimos la categoría uri=uri+"&categoria="+cat_id; //añadimos el lat_long, que en este caso será nulo uri=uri+"&lat_long="+lat_long; //añadimos la latitud que pues tambien será nula uri=uri+"&lat="+lat; //y la longitud igual uri=uri+"&long="+longt; //añadimos la región uri=uri+"®ion="+reg_id; //guardamos la url hasta ahí para los botones prev next urlnextprev=uri; //y por último añadimos la página uri=uri+"&pagina="+pagina; // Toast.MakeText (Application.Context, uri, ToastLength.Long).Show (); //mostrar los botones y los resultados, y ocultar el cuadro de busqueda botones.Visibility = ViewStates.Visible; cuadresultados.Visibility = ViewStates.Visible; cuadbusqueda.Visibility=ViewStates.Gone; prev.Visibility=ViewStates.Gone; next.Visibility=ViewStates.Gone; //mostramos el progressbar wait.Visibility=ViewStates.Visible; //cambiar el estilo de los botones busqueda y resultados busqueda.SetBackgroundResource(Resource.Drawable.busqueda); resultados.SetBackgroundResource(Resource.Drawable.busquedaactive); //cambiar colores busqueda.SetTextColor(Android.Graphics.Color.ParseColor("#000000")); resultados.SetTextColor(Android.Graphics.Color.ParseColor("#FFFFFF")); //cambiar el margen de la busqueda RelativeLayout.LayoutParams pms = new RelativeLayout.LayoutParams (ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); pms.AddRule(LayoutRules.Below, Resource.Id.linearLayout0); pms.TopMargin = -90; cuadbusqueda.LayoutParameters=pms; Log.Debug("BUSQUEDA","LA URI ES: "+uri); //Y aqui vamos a pedirle al servidor que busque try{ negocios = await FetchWeatherAsync(uri); objeto = negocios["respuesta"]; negItems = new List<Negocio> (); foreach(JsonObject data in objeto){ Log.Debug("GEO","Waaaaat!!!"); //AQUI LOS AGREGAMOS negItems.Add(new Negocio(){ NegocioId = WebUtility.HtmlDecode(data["Data"]["id"]), NegocioName = WebUtility.HtmlDecode(data["Data"]["titulo"]), NegocioDir = WebUtility.HtmlDecode(data["Data"]["geo_calle"]+" "+data["Data"]["geo_numero"]+" "+data["Data"]["geo_colonia"]), NegocioCat = WebUtility.HtmlDecode(data["Data"]["categoria"]), NegocioFoto = WebUtility.HtmlDecode(data["Data"]["ruta"]), NegocioCal = WebUtility.HtmlDecode(data["Data"]["calificacion"]), NegocioPrem = data["Data"]["premium"], NegocioNum = counter }); //Toast.MakeText (Application.Context, "YUSS!!", ToastLength.Long).Show (); counter++; } wait.Visibility=ViewStates.Gone; if(counter==0){ noresults.Visibility=ViewStates.Visible; }else{ MyListAdapter res_adapter = new MyListAdapter (Application.Context, negItems); if(pagina<=1){ prev.Enabled=false; }else{ prev.Enabled=true; } if(counter<10){ next.Enabled=false; }else{ next.Enabled=true; } prev.Visibility=ViewStates.Visible; next.Visibility=ViewStates.Visible; reslista.Adapter = res_adapter; }//else si no se encontraron resultados }catch(Exception ex){ Log.Debug("BUSQUEDA","Error"+ex); busqueda.PerformClick(); Toast.MakeText (Application.Context, "Ooops! Parece que algo salió mal. ¿Por qué no lo intentas de nuevo?", ToastLength.Long).Show (); } }//ELSE SI LA CADENA NO ESTÁ VACIA }; //AQUI CHECAMOS SI RECIBE UN ID DE REGION PARA LA PANTALLA PRINCIPAL region_heredada=gps.GetString("region"); //Toast.MakeText (Application.Context, "la region es: "+region_heredada, ToastLength.Long).Show (); if(region_heredada != "nada"){ reg_id = region_heredada; //Toast.MakeText (Application.Context, "la region es: "+reg_id+" SI HAY", ToastLength.Long).Show (); buscar.PerformClick (); } prev.Click += async (sender, e) => { if(pagina==1){ //No hagas nada }else{ pagina--; counter=0; prev.Visibility=ViewStates.Gone; next.Visibility=ViewStates.Gone; waitpagina.Visibility=ViewStates.Visible; string newuri = urlnextprev + "&pagina="+pagina; try{ negocios = await FetchWeatherAsync(newuri); objeto = negocios["respuesta"]; negItems = new List<Negocio> (); //esto es para la distancia en la geolocalizacion float dist=0; string dist_final=""; double dist2=0; foreach(JsonObject data in objeto){ //AQUI LOS AGREGAMOS try{ //HAY QUE VALIDAR ESTO, SI NO VA A TRONAR dist=float.Parse(WebUtility.HtmlDecode(data["Data"]["distance"])); //Log.Debug (tag, "La Distancia de la BD es: "+dist); if(dist<1){ dist=dist*1000; dist2=Math.Round(dist, 1); dist_final=dist2.ToString(); dist_final=dist_final+" mts."; }else{ dist2=Math.Round(dist, 1); dist_final=dist2.ToString(); dist_final=dist_final+" kms."; } }catch(Exception ex){ Log.Debug (tag, "Error detectado: NO HAY DISTANCIA"); } negItems.Add(new Negocio(){ NegocioId = WebUtility.HtmlDecode(data["Data"]["id"]), NegocioName = WebUtility.HtmlDecode(data["Data"]["titulo"]), NegocioDir = WebUtility.HtmlDecode(data["Data"]["geo_calle"]+" "+data["Data"]["geo_numero"]+" "+data["Data"]["geo_colonia"]), NegocioCat = WebUtility.HtmlDecode(data["Data"]["categoria"]), NegocioFoto = WebUtility.HtmlDecode(data["Data"]["ruta"]), NegocioCal = WebUtility.HtmlDecode(data["Data"]["calificacion"]), NegocioPrem = data["Data"]["premium"], NegocioNum = counter, NegocioDist = dist_final }); //Toast.MakeText (Application.Context, "YUSS!!", ToastLength.Long).Show (); counter++; } MyListAdapter res_adapter = new MyListAdapter (Application.Context, negItems); if(pagina<=1){ prev.Enabled=false; }else{ prev.Enabled=true; } if(counter<10){ next.Enabled=false; }else{ next.Enabled=true; } prev.Visibility=ViewStates.Visible; next.Visibility=ViewStates.Visible; waitpagina.Visibility=ViewStates.Gone; reslista.Adapter = res_adapter; }catch(Exception ex){ if(pagina<=1){ prev.Enabled=false; }else{ prev.Enabled=true; } prev.Visibility=ViewStates.Visible; next.Visibility=ViewStates.Visible; waitpagina.Visibility=ViewStates.Gone; Toast.MakeText (Application.Context, "Oops! Parece que algo salió mal. ¿Por qué no oprimes \"Anterior\" para intentarlo de nuevo?", ToastLength.Long).Show (); } }//else si la pagina no es la primera }; next.Click += async (sender, e) => { pagina++; counter=0; prev.Visibility=ViewStates.Gone; next.Visibility=ViewStates.Gone; waitpagina.Visibility=ViewStates.Visible; string newuri = urlnextprev + "&pagina="+pagina; try{ negocios = await FetchWeatherAsync(newuri); objeto = negocios["respuesta"]; negItems = new List<Negocio> (); //esto es para la distancia en la geolocalizacion float dist=0; string dist_final=""; double dist2=0; foreach(JsonObject data in objeto){ //AQUI LOS AGREGAMOS try{ //HAY QUE VALIDAR ESTO, SI NO VA A TRONAR dist=float.Parse(WebUtility.HtmlDecode(data["Data"]["distance"])); if(dist<1){ dist=dist*1000; dist2=Math.Round(dist, 1); dist_final=dist2.ToString(); dist_final=dist_final+" mts."; }else{ dist2=Math.Round(dist, 1); dist_final=dist2.ToString(); dist_final=dist_final+" kms."; } }catch(Exception ex){ Log.Debug (tag, "Error detectado: NO HAY DISTANCIA"); } negItems.Add(new Negocio(){ NegocioId = WebUtility.HtmlDecode(data["Data"]["id"]), NegocioName = WebUtility.HtmlDecode(data["Data"]["titulo"]), NegocioDir = WebUtility.HtmlDecode(data["Data"]["geo_calle"]+" "+data["Data"]["geo_numero"]+" "+data["Data"]["geo_colonia"]), NegocioCat = WebUtility.HtmlDecode(data["Data"]["categoria"]), NegocioFoto = WebUtility.HtmlDecode(data["Data"]["ruta"]), NegocioCal = WebUtility.HtmlDecode(data["Data"]["calificacion"]), NegocioPrem = data["Data"]["premium"], NegocioNum = counter, NegocioDist = dist_final }); //Toast.MakeText (Application.Context, "YUSS!!", ToastLength.Long).Show (); counter++; } MyListAdapter res_adapter = new MyListAdapter (Application.Context, negItems); if(pagina<=1){ prev.Enabled=false; }else{ prev.Enabled=true; } if(counter<10){ next.Enabled=false; }else{ next.Enabled=true; } prev.Visibility=ViewStates.Visible; next.Visibility=ViewStates.Visible; waitpagina.Visibility=ViewStates.Gone; reslista.Adapter = res_adapter; }catch(Exception ex){ if(pagina<=1){ prev.Enabled=false; }else{ prev.Enabled=true; } prev.Visibility=ViewStates.Visible; next.Visibility=ViewStates.Visible; waitpagina.Visibility=ViewStates.Gone; Toast.MakeText (Application.Context, "Oops! Parece que algo salió mal. ¿Por qué no oprimes \"Siguiente\" para intentarlo de nuevo?", ToastLength.Long).Show (); } }; //BOTON DE GEOLOCALIZACION geo.Click += async (sender, e) => { Log.Debug(tag, "Si clickeó"); string longitud=gps.GetString("longitud"); string latitud=gps.GetString("latitud"); //cad.Text=gps.GetString("longitud")+","+gps.GetString("latitud"); //HAY QUE CONVERTIR LAS COMAS DE LAS COORDENADAS EN PUNTOS PARA QUE NO MARQUE ERROR EL SERVIDOR //input.Replace("_::_", "Areo"); longitud=longitud.Replace(",","."); latitud=latitud.Replace(",","."); cadena=cad.Text; noresults.Visibility=ViewStates.Gone; //ocultamos el teclado InputMethodManager imm = (InputMethodManager)Application.Context.GetSystemService(Context.InputMethodService); imm.HideSoftInputFromWindow(cad.WindowToken, 0); if(longitud=="nada" || latitud == "nada"){ Toast.MakeText (Application.Context, "Parece que aún no hemos podido determinar tu ubicación. Toca para intentarlo de nuevo!", ToastLength.Long).Show (); }else{ if(longitud=="nogps" || latitud == "nogps"){ Toast.MakeText (Application.Context, "Tienes el GPS y la ubicación desactivados, por favor actívalos!", ToastLength.Long).Show (); }else{ //Toast.MakeText (Application.Context, "Latitud: "+latitud+" Longitud: "+longitud, ToastLength.Long).Show (); //AQUI VAMOS A ARMAR TODO! //INICIA BUSQUEDA //antes que nada, comenzamos a armar la url desde la base string uri="http://plif.mx/filtrar.json?"; //comenzaremos desde la pagina 1 pagina=1; reslista.Adapter=null; //añadimos la cadena uri=uri+"cadena="+cadena; //añadimos la categoría uri=uri+"&categoria="+cat_id; //añadimos el lat_long //uri=uri+"&lat_long="+"(6371*acos(cos(radians("+latitud+")*cos(radians(geo_lat))*cos(radians(geo_long)-radians("+longitud+"))+sin(radians("+latitud+"))*sin(radians(geo_lat))))"; //uri=uri+"&lat_long="+"(6371*acos(cos(radians("+latitud+"))*cos(radians(geo_lat))*cos(radians(geo_long)-radians("+longitud+"))+sin(radians("+latitud+"))*sin(radians(geo_lat))))"; uri=uri+"&lat_long="+"&lat_long=%28+6371+*+acos%28+cos%28+radians%28"+latitud+"+%29+%29+*+cos%28+radians%28+geo_lat+%29+%29+*+cos%28+radians%28+geo_long+%29+-+radians%28"+longitud+"%29+%29+%2B+sin%28+radians%28"+latitud+"%29+%29+*+sin%28+radians%28+geo_lat+%29+%29+%29+%29+"; //añadimos la latitud uri=uri+"&lat="+latitud; //y la longitud igual uri=uri+"&long="+longitud; //añadimos la región uri=uri+"®ion="+reg_id; //guardamos la url hasta ahí para los botones prev next urlnextprev=uri; //y por último añadimos la página uri=uri+"&pagina="+pagina; //cad.Text=uri; //Toast.MakeText (Application.Context, uri, ToastLength.Long).Show (); //mostrar los botones y los resultados, y ocultar el cuadro de busqueda botones.Visibility = ViewStates.Visible; cuadresultados.Visibility = ViewStates.Visible; cuadbusqueda.Visibility=ViewStates.Gone; prev.Visibility=ViewStates.Gone; next.Visibility=ViewStates.Gone; //mostramos el progressbar wait.Visibility=ViewStates.Visible; //cambiar el estilo de los botones busqueda y resultados busqueda.SetBackgroundResource(Resource.Drawable.busqueda); resultados.SetBackgroundResource(Resource.Drawable.busquedaactive); //cambiar colores busqueda.SetTextColor(Android.Graphics.Color.ParseColor("#000000")); resultados.SetTextColor(Android.Graphics.Color.ParseColor("#FFFFFF")); //cambiar el margen de la busqueda RelativeLayout.LayoutParams pms = new RelativeLayout.LayoutParams (ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); pms.AddRule(LayoutRules.Below, Resource.Id.linearLayout0); pms.TopMargin = -90; cuadbusqueda.LayoutParameters=pms; Log.Debug("GEO","LA URI ES: "+uri); //Y aqui vamos a pedirle al servidor que busque try{ Log.Debug("GEO","ENTRAMOS"); negocios = await FetchWeatherAsync(uri); objeto = negocios["respuesta"]; Log.Debug("GEO","PASAMOS LA ASIGNACION"); negItems = new List<Negocio> (); float dist=0; string dist_final; double dist2=0; foreach(JsonObject data in objeto){ Log.Debug("GEO","Entramos a FOREACH"); //AQUI LOS AGREGAMOS //INICIA VERIFICACION DE LA IMAGEN //TERMINA VERIFICACION DE LA IMAGEN dist=float.Parse(WebUtility.HtmlDecode(data["Data"]["distance"])); if(dist<1){ dist=dist*1000; dist2=Math.Round(dist, 1); dist_final=dist2.ToString(); dist_final=dist_final+" mts."; }else{ dist2=Math.Round(dist, 1); dist_final=dist2.ToString(); dist_final=dist_final+" kms."; } negItems.Add(new Negocio(){ NegocioId = WebUtility.HtmlDecode(data["Data"]["id"]), NegocioName = WebUtility.HtmlDecode(data["Data"]["titulo"]), NegocioDir = WebUtility.HtmlDecode(data["Data"]["geo_calle"]+" "+data["Data"]["geo_numero"]+" "+data["Data"]["geo_colonia"]), NegocioCat = WebUtility.HtmlDecode(data["Data"]["categoria"]), NegocioFoto = WebUtility.HtmlDecode(data["Data"]["ruta"]), NegocioCal = WebUtility.HtmlDecode(data["Data"]["calificacion"]), NegocioPrem = data["Data"]["premium"], NegocioDist = dist_final, NegocioNum = counter }); //Toast.MakeText (Application.Context, "YUSS!!", ToastLength.Long).Show (); counter++; } wait.Visibility=ViewStates.Gone; if(counter==0){ noresults.Visibility=ViewStates.Visible; }else{ MyListAdapter res_adapter = new MyListAdapter (Application.Context, negItems); if(pagina<=1){ prev.Enabled=false; }else{ prev.Enabled=true; } if(counter<10){ next.Enabled=false; }else{ next.Enabled=true; } prev.Visibility=ViewStates.Visible; next.Visibility=ViewStates.Visible; reslista.Adapter = res_adapter; }//else si no se encontraron resultados }catch(Exception ex){ Log.Debug("GEO","El error: "+ex); busqueda.PerformClick(); Toast.MakeText (Application.Context, "Ooops! Parece que algo salió mal. ¿Por qué no lo intentas de nuevo? "+ex, ToastLength.Long).Show (); } //TERMINA BUSQUEDA }//ELSE GPS DESACTIVADO }//ELSE NO SE HA ENCONTRADO LA UBICACION }; reslista.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => { //Toast.MakeText (Application.Context, "El ID del negocio es: "+negItems [e.Position].NegocioId, ToastLength.Long).Show (); if(negItems[e.Position].NegocioPrem!="0"){ //Toast.MakeText (Application.Context, negItems [e.Position].NegocioName+" Es premium!!"+" NegocioPrem es: "+negItems[e.Position].NegocioPrem, ToastLength.Long).Show (); var negocio = new Intent (this.Activity, typeof(PerfilPremium)); negocio.PutExtra("id",negItems [e.Position].NegocioId); negocio.PutExtra("nombre",negItems [e.Position].NegocioName); negocio.PutExtra("direccion",negItems [e.Position].NegocioDir); negocio.PutExtra("categoria",negItems [e.Position].NegocioCat); negocio.PutExtra("calificacion",negItems [e.Position].NegocioCal); StartActivity (negocio); }else{ var negocio = new Intent (this.Activity, typeof(PerfilNegocio)); negocio.PutExtra("id",negItems [e.Position].NegocioId); negocio.PutExtra("nombre",negItems [e.Position].NegocioName); negocio.PutExtra("direccion",negItems [e.Position].NegocioDir); negocio.PutExtra("categoria",negItems [e.Position].NegocioCat); negocio.PutExtra("calificacion",negItems [e.Position].NegocioCal); StartActivity (negocio); } //StartActivity(typeof(PerfilNegocio)); //AQUI INCICIAMOS LA ACTIVIDAD DE PERFIL Y LE PASAMOS DATOS /* var myActivity = (MainActivity) this.Activity; myActivity.VerNegocio(negItems [e.Position].NegocioId); */ }; return view; }