Home

Aplicación móvil de localización de ocio para Android.

image

Contents

1. private String getRespuestaPost try BufferedReader reader new BufferedReader new InputStreamReader is iso 8859 1 8 StringBuilder sb new StringBuilder string babky while line reader readLine null sb append line An sucios ene respuesta sb toString SR oso rech Moses Soja Y at respuesta catch Exception e 4 OOS Wo BE ee MoO BEOS SE ACRO OEC return respuesta 06 07 08 09 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 B 1 C DIGO JAVA 81 KK HR XXX I K AK A AX K KARA RARA K AK AX Ak KA X KA AK I RK I Obtiene un JSon con la informacion pedida por el cliente x param ArrayList parametros Parametros que se quieren enviar return String Json con la informacion de la respuesta public String getServerDataString ArrayList lt String gt parametros conectaPost parametros server E aS AIME getRespuestaPost if respuesta null 66 respuesta trim respuesta respuesta substring respuesta indexOf resp
2. EntornoADir double new Restaurantes createStatement query SELECT FROM Restaurante WHERE coor ou OB EDEN AAN DO A ANDECO FAVO IN EEN EA NIDADES yA resultSetRest statement executeQuery query 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 369 370 371 372 373 374 375 376 371 379 380 102 AP NDICE B C DIGO FUENTE while resultSetRest next Restaurante rest new Restaurante Integer parselnt resultSetRest getString id resultSetRest getString nombre BSS CERSS ee er direccion Double parseDouble resultSetRest getString coord_X Double parseDouble resultSetRest getString coord_ Y Float parseFloat resuleoeeRest Ge SE i puntuacion restaurantes add rest catch ClassNotFoundException CNFE catch SQLException SOLE catch InstantiationException IE System out println CNFE getMessage RAIN TES System out println SQLE getMessage E SVS SMe OU ers oral E catch IllegalAccessException IAE System out println IAE getMessage return restaurantes AZ E getMessage 3 A TKK KKK KK I RK I RI I RI II K KARA KARA KA AX Z K AKA I IK I i EA
3. Ene Ne ee ArrayList java util concurrent ExecutionException serviOcios Restaurantes com aplicacion conexion Post google android maps GeoPoint google android maps MapActivity google android maps MapController google android maps MapView google android maps Overlay com com com com com com google gson Gson android location Address android location Geocoder android location android location android location android os Bundle Location LocationListener LocationManager android app ProgressDialog android content Context PUNO OLON UL O android view Menu class Mapa extends MapActivity 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 Ja 76 77 78 79 80 81 B 1 C DIGO JAVA 65 private private private private private a Ll vo Overri PUTA DERIMSOSOM CAV SEC lies MapView mapa null MapController controlador null ProgressDialog pd KAKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK amado cuando es creado eI RI I K AK AX A K KA Z ROI RK I OKI XXE Y de void onCreate Bundle savedInstanceState super onCreate savedInstanceState setContentView
4. B 1 C DIGO JAVA 53 addEvents KK KKK I EE HR EE HR AKA AX AZ AK AK AX AX KAZ IORI I I I IK I RK I Anade los eventos a los botones de la pantalla KR HRK HRK AK AK Z K AK AX A K KAZ Z AZ K AK Z K AK AX Z K AKA Xe Xe Ak k private void addEvents final OnClickListener eventoAcept new OnClickListener SuppressWarnings unchecked SuppressLint ShowToast public void onClick View v CAC if getRestaurante length lt 1 getDireccion length lt 1 Toast makeText getContext Debes completar tanto el nombre del restaurante como su direccin Toast LENGTH LONG show else ArrayList lt String gt parametros new ArrayList lt String gt parametros add option parametros add 1 parametros add nombre parametros add getRestaurante toLowerCase parametros add dir parametros add getDireccion toLowerCase parametros add web parametros add getWeb 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 54 AP NDICE B C DIGO FUENTE Geocoder geocoder new Geocoder geteContexe On List lt Address gt addresses addresses geocoder getFromLocationName getDireccion CD AE if addr
5. 20 Diagrama de clases core 44 454754 bow Ge obese ee 6 20 Diagrama de clases serviOcios lt lt lt lt lt lt 21 Modelo relacional de la base de datos 23 Panalaimeal 2 wi 30 SUDMENU id e KES 2 8 Kes do NE 31 Formulario usando gps 32 Formulario sin el uso de gps 32 Resultado de una consulta 33 Detalle de un restaurante e e oleo 56 64 a eu dues 33 Mensaje de alta correcta de un restaurante 34 Formulario para puntuar un plato 35 IX NDICE DE FIGURAS Cap tulo 1 Introducci n 2 CAP TULO 1 INTRODUCCI N 1 1 Motivaci n Actualmente la sociedad est acostumbrada al uso diario de dispositivos m viles y las capacidades que estos nos brindan por ello no es una cuesti n balad el intentar explotar todo su potencial para obtener comodidades De un tiempo a esta parte el n mero de aplicaciones disponibles para estos dispositivos ha ido en aumento haciendo que haya aplicaciones de todo tipo Si realizamos un estudio de sus funcionalidades y usos r pidamente comprobamos que la mayor parte de estas est n orientadas al ocio As pues en base a esto nos disponemos a realizar el estudio de un proyecto de ingenier a de software en el que desarrollaremos una aplicaci n de localizaci n de restaurantes para dispositivos m viles con sistema operativo Android 1 2 Funcionalidades La aplic
6. Es llamado cuando es creado para mostrar las opciones del menu Override public boolean onCreateOptionsMenu Menu menu 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 B 1 C DIGO JAVA 67 getMenulnflater inflate R menu activity main menu return true Override protected boolean isRouteDisplayed TODO Auto generated method stub return false KK KKK I IKI K AK A AX I I AKA AX I RI IRI I IK I I I RK I kh Obtiene los datos del GPS del dispositivo KKK k KK A K K AK AK Z K AK AX A K KA Z AZ K AK ZX K RARA K AK AX KAR KR RARAS private void configGPS LocationManager mLocationManager LocationListener mLocationListener mLocationManager LocationManager getSystemService Context LOCATION SERVICE mLocationListener new MyLocationListener mLocationManager requestLocationUpdates LocationManager GPS_PROVIDER 5000 10 mLocationListener KK KKK I KI I De HR EE AXA AK AKA I KAZ AZ I AK AX AK KA X I AK Z KAR RR kk Actualiza el mapa acorde a la posicion que se le pas
7. param Si param Si un restaurante en la bbdd tring nombre nombre del restaurante tring dir direccion del restaurante param double x coordenada x latitud 381 382 383 384 385 386 387 388 389 390 391 392 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 B 1 C DIGO JAVA 103 x param double coordenada y longitud param String web web del restaurante ZAM REBO SS On ONO RESP ESA KKK KK A I K AK AK Z K AK AX A K KAZ Z AK K AK Z K AK AX Z AKA AX I RI XXE public static String insertRestaurante String nombre String dir double x double y String web String query Mu SeringsresJsons date NA no Statement statement EEM conectar statemen query nombr ESO ResultSe execu if resul else BBDD E S Cm Createstatement SELECT id FROM Restaurante WHERE eS Eno more ANDIM direccion Hole Rue Wg t resultSet statement teQuery query LoetenextEi th resJson update nok query INSERT INTO Restaurante nombre POS CCSOT C OTO COSTA PUE seo nS EU TO MORE e UNE Noe WR SAM A E int resultado statement executeUpdate query 1f resultado 1 sucio gt MPa Te oe ES if web length 0 int idRest 1 414 420 421 422
8. 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 B 1 C DIGO JAVA 87 KK KKK I KI IK I I RK IKI KAR KA AX KR KARA I RIK RK I Modifica la puntuacion de un restaurante param float p nueva puntuacion KKK RH HRK AK AK Z K AK AX A K KAZ Z AZ AK AK X RARA K Xe KARA kk Y public void setPuntuacion float p this puntuacion p KK HR KI I KARA KARA KARA KARA KARA I AK Z XX Obtiene la lista de paginas web de un restaurante return ArrayList lt String gt KKK KA AA K K AK AK Z K AK AX A K KA Z AZ K AK ZX K AK AX Z K AKA KR KARA ARRAY public ArrayList lt String gt getWeb I tn el WEDII JR Re HR KI I Ge HR EE KI I EE I KR ORI I Xe KI Modifica la lista de paginas web de un restaurante param ArrayList lt String gt w nueva lista de paginas web KKK I K AK AK Z K AK AX A K KA Z AZ K AK ZX K AK AX ZX K Xe KR I I public void setWeb ArrayList lt String gt w this web w KK KK I I I KI K AK A ZX K AK AX AX I KA Ke AK AX Ak kA Z kA RE I Anade una web a la lista de paginas web de un restaurante param String w nueva paginas web KKK KK A K K AK AK Z K AK AX A K KA Z AZ K AK X K AKA Z K AKA A KAZ KAR kk public void addWeb String w 251 252 253 254 255 256 257 258 259 260 261 262 263 264 26
9. 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 56 catch final OnClicki AP NDICE B C DIGO FUENTE Toast makeText getContext FAR SEOS momentos no se HALO TOME guardar este restaurante intentelo de nuevo m s tarde BOSS LENGTH LONG show IOException e System out println e getMessage InterruptedException e System out println e getMessage ExecutionException e System out println e getMessage istener eventoClear new ONC SRS tener public void onClick View v HR Staurantensete x us e FDESCSON te 0 EWED SETTE E Ma 93 94 95 96 97 98 99 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 21 a 217 218 219 220 221 222 223 224 225 226 22 3 228 229 230 231 B 1 C DIGO JAVA 57 acept setOnClickListener eventoAcept clear setOnClickListener eventoClear KK KKK I HR De HR EE HE I HR RI I KR RRA RRA Obtiene el valor del string escrito en la etiqueta de restaurante return String nombre del restaurante Sas KKK KK A K K A AK Z K AK AX A K KAZ AX KARA K AK AX ZX K AKA KARA KARA KARA AS public String getRestaurante return ERestaurante getText
10. Eduardo Campos de Diago KKK KAZ KK AK Z K AK A Z K AK AZ Z K AK AX AX K AK AX AX KAZ KARA KARA KARA Y package core import java io BufferedReader import n import import import import import import import import NaS AT PCI KA Ca Cale od ds import SVO COS ava io IOException ava io InputStreamReader ava net MalformedURLException ava net URL ava net URLConnection AMAS E ava util ArrayList ava util Iterator ava util Scanner import com google gson Gson public class Gestor Private Statue String dominio el Ebano Quai CANES el OSS CTB Ae private static String user camposdediago private s SUECO As Ea Bat VOSA GUNDA ow nNECEHON chy EOST NOU E OMA ABC AVE OracleDriver 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 s7 58 59 60 61 62 63 64 65 66 67 68 69 70 71 12 73 B 1 C DIGO JAVA 93 ina or String URL On dbes le gos pw2 1 camposdediagoleiffel itba edu ar 1521 ITBA private static Gson gson static Scanner teclado PUPITENS tar ei vord AMA Tits OPERON String aux teclado opcion menu while opcion switch opcion case 0 case 1 new Gson String args Sering resultado MAUS new Scanner Syst
11. O InterfazServicio Figura 2 19 Diagrama de clases com aplicacion conexion 2 3 3 Diagrama de clases core Gestor T user string a oo pass string conexion unDriver string URLConn string cn gson conectarBBDD obtenerRestaurantes entrada x double entrada y double entrada comida string string Een restaurantesComidaWeb entrada restaurantes Restaurantes entrada comida string entrada rest Restaurantes restaurantesComidaBBDD entrada restaurantes Restaurantes entrada comida string entrada res Restaurantes restaurantesEntomoADir entrada x double entrada y double Restaurantes insertarRestaurante entrada nombre string entrada dir string entrada x double entrada y double entrada web string string insertarPlato entrada nombre string entrada plato string entrada puntuacion float string Figura 2 20 Diagrama de clases core CAP TULO 2 DOCUMENTACI N 2 3 DIAGRAMA DE CLASES 21 2 3 4 Diagrama de clases serviOcios Restaurantes restaurantes com aplicacion com aplicacion ui conexion Figura 2 21 Diagrama de clases serviOcios 22 CAP TULO 2 DOCUMENTACI N 2 4 Documentaci n de interfaces 2 4 1 Interfaz del servidor Como ya comentamos previamente la comunicaci n entre la aplicaci n web y el servidor es mediante en env o de mensajes POST del protocolo HTTP Como hemos visto a lo largo de la documentaci n expuest
12. conexion serviOcios Figura 2 17 Diagrama de clases Paquetes del proyecto En este gr fico podemos ver como se distribuyen y relacionan los paquetes que forman parte del proyecto En l podemos observar com aplicacion ui Este paquete es el encargado de toda la presentaci n de menus y mapas en el dispositivo m vil com aplicacion conexion Este paquete es el encargado de realizar la cone xi n entre el dispositivo m vil y el servidor mediante mensajes post Core Es el core del servidor se encarga de realizar las funciones del mismo a serviOcios Este paquete es el encargado de modelar todos los servicios que se vayan a implementar en nuestro caso restaurantes Es un paquete que est presente tanto en el servidor como en el cliente Ahora procederemos a ver un diagrama de clases m s detallado de cada uno de estos paquetes 2 3 DIAGRAMA DE CLASES 2 3 1 Diagrama de clases com aplicacion ui com aplicacion conexion refreshMap entrada location obtenerRestaurantes entrada location Restaurantes getDistance entrada lat a double entrada lon a double entrada lat b double entrada lon b double double Figura 2 18 Diagrama de clases com aplicacion ui 20 2 3 2 Diagrama de clases com aplicacion conexion com aplicacion ui gerServerDataString entrada parametros string serviOcios conectaPost entrada parameteros entrada URL string getRespuestaPost string
13. executeQuery query while resultSetWeb next Sn O CONE SATA KE Wilks CEY UREA url new URL resultSetWeb TEES le a 211 212 213 214 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 98 ILE AP NDICE B C DIGO FUENTE URLConnection uc url openConnection We Connect fr InputStreamReader is new InputStreamReader uc getInputStream ISO TE IE System out println is getEncoding BufferedReader in new BufferedReader is SEEING Boole DNS A while inputLine in readLine null contenido inputLine An We NNC OS EINE contenido contenido toLowerCase Cat ehi MalformedURLException e Syete P TE getMessage Cauch lOEXcepe ron re SV SEEM OUP getMessage if contenido contains comida toLowerCase esta true esta 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 B 1 C DIGO JAVA 99 rest setWeb plas rests add rest else aux add rest catch SQLException e System out println e getMessage resTurn add aux resTurn add res
14. o x param Location location Localizacion que se quiere mostrar KKK KA AA K K AK AS private void refreshMap Location location ik loecatkvon k nulls 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 68 AP NDICE B C DIGO FUENTE pd dismiss final List lt Overlay gt overlays mapa getOverlays overlays clear Restaurantes restaurantes null GeoPoint point new GeoPoint int location getLatitude 1000000 int location getLongitude x 1000000 controlador setZoom 18 controlador animateTo point MapOverlay myMapOverlay new MapOverlay getResources getDrawable R drawable Maite ado US ceca POE overlays add myMapOverlay restaurantes obtenerRestaurantes location myMapOverlay new MapOverlay getResources getDrawable R drawable icono rest restaurantes overlays add myMapOverlay JR KK KK KKK EH HE EH I HR Ge HR EH I RK I RK I RI I XX Obtiene Restaurantes que hay en torno a una posicion param Location location Localizacion en torno a la que buscar los retunr Restaurantes Objeto de la clase Restaurantes con resultados obtenidos KR KR KA AA K AK AK Z K AK AK X K AK AZ Z K AKA AX K AK AX ZX
15. toString KK KKK I KI I I I RII AK AX AX RARA KARA kA AK KAR RR Kk Obtiene el valor del string escrito en la etigueta de direccion return String direccion del restaurante KKK k RH HRK AK AK Z K AK AX A K KAZ Z AX K AK X K AKA Z AK AKA KARA KAR KARA AS public String getDireccion return EDireccion getText toString KK KK IK KI I KI I RK I I AKA AX I RI I ORI I I I Ge RE XX Obtiene el valor del string escrito en la etiqueta de web return String web del restaurante KKK KK A K K AK AK Z K AK A A K KAZ Z AZ KARA K AK AX Z K AKA AX RAR KARA RARAS public String getWeb return EWeb getText toString 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 58 Clase ControlPuntuar java AP NDICE B C DIGO FUENTE KKK KK KK KK KARA KARA RAR ARA KR OK RK ARA KK x Fichero ControlPuntuar java Clase que modela la pantalla de la funcion puntuar de la aplicacion x author Eduardo Campos de Diago version 1 2 package com aplicacion ui import import import import import import import import import import import import public pri
16. 200 201 202 203 204 205 206 207 208 86 AP NDICE B C DIGO FUENTE TKK KK RER RK I IK I I HR KA X K KARA KARA KA AX Z KARA I Modifica la coordenada x de un restaurante param double x nueva coordenada x public void setCoordX double x this coord X x TKK KKK KK I AZ K AK AK A I K AK AX AX K AK X K KAZ K Xe ke Z OKI I RRA Obtiene la coordenada y de un restaurante x return double AA public double getCooraY RO SU REAL OO e E TKK KK RE KI I I I AK AX A AX KARA K KAZ Z KKK AX A K AK AX Z ORI kk Modifica la coordenada y de un restaurante param double y nueva coordenada y KKK KK AAA KK AK Z K K A X K AKA Z K AKA X KARA He HRK HR KARA KARA Y public void setCoordY double y this coord_Y y JR RER KR KK KR I AA I RARA KR ARK K AKA X KKK Xe ke Z K AKA k k Obtiene la puntuacion de un restaurante x return float XAAKKKKRAKKKARKKKARKKKARKAK RARA K AK AX X KARA K KAZ KARA ARAS public float getPuntuacion return this puntuacion 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
17. 53 54 55 56 57 58 59 60 61 62 63 64 65 B 1 C DIGO JAVA 85 JR RO KK I Xka XK KARA RIK I AX KARA I AK Z XX Modifica el nombre de un restaurante x param String n nuevo nombre KKK I K A AK Z K K AK AX A K KAR KAZ X K AK AX X K AKA A KAZ AZ KARA KARA public void setNombre String n this nombre n KK RE KK I KR I IK I I HR RI I RII I ORI I HR RK IK I RK I x Obtiene la direccion de un restaurante return String KKK KK A Z K AK AK Z K AK AX A K KAZ Z AZ KAZ X RARA AK AK AX KR KAR KARA public String getDireccion mortales OZE S EKO T e KK KK I I I KI K AKA ZX HR KARA RARA ORI I KARA kA AK Z RK I Modifica la direccion de un restaurante param String d nueva direccin A KK AA K K AK AK Z K AK A AX K KA Z AZ K AK ZX K AK AX Z K AKA A KAZ AK AK AXA ARRAY public void setDireccion String d ells OS SCO C KK KKK I XXX K AK A AX AZ AK AK AX I RI I RI I RI I RIK I RK I I Obtiene la coordenada x de un restaurante return double KKK KK AA K K AK AK Z K AK AX A K KAZ Z OI Z K AKA KARA KARA KARA public double getCooraX TMO ESC OO RCA 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
18. 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 B 1 C DIGO JAVA return true 77 builder setPositiveButton Aceptar new OnClickListener PUDIESE VOLARON NECKE DialogInterface dialog int which dialog cancel builder create builder show KK KKK I HR Z K AK AK AX K AK RE X KAR KARA I RIK KK I Obtiene la distancia entre dos puntos O OC A param lat param lon a doubl param lat b doubl param lon b doubl _a doubl latitud del punto a longitud del punto a Farsi ud deds PU DES DER DAD longitud del punto b return double con la distacina entre los dos puntos KKK KK A K K AK AK Z K AK AX A K KA Z A K AK Z K RARA K AKA KK KARA KARA AS private double getDistance double lat a double lon a douto O doubl doubl e Lon doubl doubl ES ES doubl ke return OO DIO TOS d d Lat eon I Mo lat a Won D ona LatxdLat LonxdLon Math sqrt a b 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 78 AP NDICE B C DIGO FUENTE B 1 2 Paquete com aplicacion conexion Clase Post java TKK KKK KK RI I A A I K RARA KARA K AKA X K AKA A I KI K ORI k k RCAC EON Clase Post jav
19. 97 98 99 100 101 102 103 104 105 106 107 108 109 48 AP NDICE B C DIGO FUENTE KK KK HR KI I HR HR K AK X K KARA I RIK I RK KE XX Anade los eventos a los botones de la pantalla KR KR K AAA KK AK Z K AK AK Z K AKA Z K AK AX Z K AK AX ZX KARA KARA KK RRA ARAS private void addEvents final OnClickListener eventoAcept new OnClickListener public void onClick View v Intent intent new Intent getContext Mapa class Bundle bundle new Bundle bundle putString comida getComida D MOHS OU ATC AS PD AE intent putExtras bundle getContext startActivity intent final OnClickListener eventoClear new OnClickListener public void onClick View v HE omukcearsciteke ster UM e EDRR SE EESE UE check setChecked false final OnCheckedChangeListener eventoCheck new OnCheckedChangeListener public void onCheckedChanged CompoundButton buttonView boolean isChecked if isChecked 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 B 1 C DIGO JAVA 49 MDP SSV SOA VS PE Es ED Soe Vers 1 D UEY VES EBELE else DAS e CIRE sale ANAS LD
20. MANUAL DE USUARIO Ap ndice B C digo fuente 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 38 AP NDICE B C DIGO FUENTE B 1 C digo java B 1 1 Paquete com aplicacion ui Clase MainA ctivity java KK KK RK KR KI I RI I EH HE OK IK I X K RI ROK RRA RR Fichero MainActivity java Clase que modela la pantalla inicial de la aplicacion x author Eduardo Campos de Diago version 1 2 ee HRK Z K AK AK ZX K AK AZ Z K Xe HR Ke HR ee ee package com aplicacion ui import android os Bundle import android app Activity import android app AlertDialog import android content Context import android content DialogInterface import android content Intent import android content DialogInterface OnClickListener import android view View import android widget Button public class MainActivity extends Activity TKK KK KKK EE RE A HRK AK AX AX KARA K KAZ Z K AKA AX I KA AX Z KARA IK I oe Es llamado cuando es creado el primer activity Override public void onCreate Bundle savedInstanceState super onCreate savedInstanceState setContentView R layout
21. intentelo de nuevo m s ARCO MORSE LENGTH LONG show else Toast makeText getContext Gracias por puntuar este plato Toast LENGTH LONG show InterruptedException e System out println e getMessage ExecutionException e System out println e getMessage 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 62 AP NDICE B C DIGO FUENTE final OnClickListener eventoClear new ORGA TEAS ET ee IAN public void onClick View v ERestaurante setText PPA Orcs Cee xt grupo clearCheck acept setOnClickListener eventoAcept clear setOnClickListener eventoClear TKK KK KK KI KI I HRK AK A AX K I K KAZ He Xe Xe KR IK I Obtiene el valor del string escrito en la etiqueta de restaurante return String nombre del restaurante KKK K AAA KK AK ZX K AK AK X K KAZ Z K AK AX AX RARA KARA KARA KARA ARRAY public String getRestaurante return ERestaurante getText toString KK KK KKK I RK I IK I I K AK AX I I I KAZ I RK I RIKI RIK I IK IE Obtiene el valor del string escrito en la etiqueta de plato return String plato que se quiere puntuar Ce KK AAA KK AK Z K AK A X K AK AZ Z K AK AX X KA AX K
22. package com aplicacion ui IMP Oss import import import import import import import import import import import import PUDITE priva priva priva priva priva priva an an an an an an an an an an an an an droid droid droid droid OnCheckedChangeListener droid droad aro las ROC drola droid droiad droid droid widget Button widget CheckBox widget CompoundButton widget CompoundButton widget Linearlayout widget TextView CcONESTATACON ESE SOMESNE MESTE os Bundle util AttributeSet view LayoutiInflater view View widget EditText class ControlBuscar extends LinearLayout xeo ES TS Ce ES BUBEO e Butto EditText EComida TextView LDir PCE Dir CheckBox check n acept n clear TKK KK RE I IK I I HR K I K KAZ Z K Xe Xe I IK I oe Constructor de la clase ControlBuscar 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 s7 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 B 1 C DIGO JAVA 47 param Context contesto de la aplicacion KKK I K AK A Z K AK AX A K KA Z AK K AK X K AKA Z KA A KR AZ AK I I public ControlBuscar Context context super context ASS E KK KK
23. 2 5 Puntuar plato Aplicaci n m vil 2 2 2 6 Puntuar plato Servidor 2 2 3 Diagramas de secuencia 254 lt BOS obi pe ses 2 2 3 1 Buscar restaurantes 2 2 3 2 A adir restaurantes 2 2 3 3 Puntuar un plato VII III IX Vill INDICE GENERAL 2 3 Diagrama de clases occur a dune 18 2 3 1 Diagrama de clases com aplicacion ui 19 2 3 2 Diagrama de clases com aplicacion conexion 20 2 3 3 Diagrama de clases core 3 a td 4 we a bad 4 20 2 3 4 Diagrama de clases serviOcios 21 2 4 Documentaci n de interfaces 22 2 4 1 Interfaz del servidor 22 2 4 1 1 Buscar restaurantes 22 2 4 1 2 Afiadirrestaurante 22 2 4 1 3 Puntuar plato ya a de the 23 2 5 Documentaci n de la base de datos 24 Disks LablaS ore y ete cate dose abies Sew ET sla 2A 2 5 2 Modelo relacional ooa 25 3 Versiones y mejoras 27 A Manual de usuario 29 A 1 Iniciando nuestro uso en serviOcios 30 A 2 Buscando restaurantes 31 A 3 A adir restaurantes b l la n e 34 A 4 Puntuar un plato das e a 35 B C digo fuente 37 Bel C digo java CC 38 B 1 1 Paquete com aplicacion ui lt 38 B 1 2 Paquete com aplicacion conexion 78 B 1 3 Paquete serviOci
24. 248 249 250 251 252 253 254 255 256 257 258 70 A hr CCC AP NDICE B C DIGO FUENTE Fichero MyLocationListener java Clase que escucha los eventos del mapa author Eduardo Campos de Diago version 1 2 KR KR K AKA A KK AK Z K AK AK Z K AK AZ Z K RARA KA A KE AK HRK HR RE Y pub lic class MyLocationListener implements LocationListener double longitud double latitud public void onLocationChanged Location location longitud location getLongitude latitud location getLatitude MOSCA CV MAPD nee ee Value0f longitud MOJO Moa A O Sie sas value0f latitud refreshMap location public void onProviderDisabled String location TODO Auto generated method stub public void onProviderEnabled String provider TODO Auto generated method stub publticsyoratonstatusehengediSteringr providencias status Bundle extras TODO Auto generated method stub 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 B 1 C DIGO JAVA 71 Clase MapOverlay java KKK KK KR RK KARA KARA KK KARA KARA RK KK KE KK KK Fichero MapOverlay java Clase gue gestiona el overlay de un mapa de google Gauthor Eduardo Campos de Diago version 1 2 KKK KK AZ KK AK Z K AK A AX K K AK A X K AK AX
25. AX K KAZ KARA KARA KARA ARRAY package com aplicacion ui MPD OBE OVA USE EHO import serviOcios Restaurante import serviOcios Restaurantes import android app AlertDialog import android content DialogInterface import android content DialogInterface OnClickListener import android graphics Canvas Importe androudugraphies Patent TS OS EH ON Ames PO import android graphics drawable Drawable import com google android maps GeoPoint import com google android maps MapView import com google android maps Overlay import com google android maps Projection public class MapOverlay extends Overlay private Drawable imagen private nio Ese privareminemy oreset private String text private Restaurantes restaurantes new Restaurantes private GeoPoint punto JR OR Re HR kk HR AKA AXA XK AK AX X KR K AK AX AK KA I RR KAR RR kk Constructor de la clase MapOverlay 50 51 2 53 s4 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 72 AP NDICE B C DIGO FUENTE param Drawable draw param String text Texto que se desea excribir param GeoPoint point Punto que se desea representar XAKKKKKAKKKARKKKARKKKARKK RARA K AK AX AZ KARA KARA KARA ARRAY public MapOverlay Drawable draw String text GeoPoint point t
26. Clase que caracteriza el menu para la eleccion de accion author Eduardo Campos de Diago version 1 2 ee HRK HR EE HR A Z K AK AX AX KA AX ZX KAZ ee ee oe ee ee ee ee package com aplicacion ui im im im im im im im im port port port port port port port port public an an an an an an an an dromdk EGG ARO AOA ARO droid droid droid app Activi CY content In os Bundle view View tent widget AdapterView widget ArrayAdapter widget ListView widget AdapterView OnItemClickListener class Submenu extends Activity KKK KK KK RK HRK EH I K AK X K I I RK I RK I IRI I IK I oe Es llamado cuando es creado public void onCreate Bundle savedInstanceState super onCreate savedInstanceState setContentView R layout submenu String datoList un restaurante Puntuar un plato new String Buscar A adir Bundle bundle getIntent getExtras short option bundle getShort option 7 EM ee td m CeL Dar We 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 B 1 C DIGO JAVA 43 ArrayAdapter
27. K AK AX A K KAZ Z IOI K AK HR Xe KR KARA ARRAY public Restaurante int i double loa sp Siemans jel SEST NS TN Ch COLS ArrayList lt String gt w ArrayList lt 80 81 82 83 84 85 86 87 88 89 91 92 93 94 95 97 98 99 100 101 102 103 104 105 106 107 108 109 120 121 122 84 AP NDICE B C DIGO FUENTE Cole akel hp this nombre n ciales cole eeelon this coord X x this coord_Y y this puntuacion p this web w this platos pl x Se Q Se KK KKK KK I KR KI RI I I II K KAZ X KAR K AKA Z KAZ I IK IE Obtiene el id de un restaurante return int KR RH KA AA KK AK Z K AK A X K AKA Z K AK AX AX K KARA K Ke KARA ARRAY D M ne ee PETUA SO JR RER HR RK I RI I HR I KARA K I I RK I I OKI k k Modifica el id de un restaurante param int i nuevo id KR KR ee Z K AK AZ A Uo VOC SEE AN this id i JR KK KK KKK EE HE KI I AK AX AX AX Ge X K KE He Xe ke Xe I I I oe x Obtiene el nombre de un restaurante return String KKK KK AAA KK AK Z K AK A X K AK AK Z K AKA X KA AX ZX AZ K AK HRK HR ARRAY public String getNombre return this nombre 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
28. KARA KARA KARA ARRAY SuppressWarnings unchecked private Restaurantes obtenerRestaurantes Location location 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 B 1 C DIGO JAVA 69 Restaurantes restaurantes null ArrayList lt String gt parametros new Arraylist lt String gt 0 parametros ada option parametros add 0 parametros add X parametros add String valueOf location getLongitude 0 parametros add Y parametros add String value0f location getLatitude parametros add comida parametros add comida parametros add OK parametros add ok Post post new Post post execute parametros Pus String datos post get Og SAO gta as Gson gson new Gson restaurantes gson fromJson datos Restaurantes class catch InterruptedException e Log e log_tag e getMessage catch ExecutionException e Log e log_tag e getMessage return restaurantes KK KKK KI KI I HR RK IKI EE AX RARA KK AK AX AK RII AX IK I RK I 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
29. O rest Restaurante ite next query SELECT FROM plato WHERE id restaurant rest getId ANDA AS O MO ar COMETA gt resultSetPlat statement executeQuery query while resultSetPlat next plas add resultSetPlat get or PNA OZ esta true if esta rest setPlatos plas rests add rest aux add rest catch SQLException e 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 B 1 C DIGO JAVA 101 System out println e getMessage resTurn add aux resTurn add rests return resTurn JR OR KKK I I I I XK KARA AK AK AK I X KARA KARA I IK I kk Obtiene restaurantes gue estan en torno a una direccion dada as param double x coordenada x latitud x param double coordenada y longitud return Restaurantes KR I I HRK AK AK Z K AK AX A K KA Z I K AK AX Z K AKA AX KAZ KARA KARA private static Restaurantes restaurantesl x double y double margen 0 003 double xA xB yA yB SOB SIS ALL ResultSet resultSetRest null Restaurantes restaurantes ELY conectarBBDD xA x margen Zde Sr ao em yA y margen VB y margen Statement statement cn
30. R layout layout mapa Obtenemos una referencia al control MapView mapa MapView findViewById R id mapa Mostramos los controles de zoom sobre el mapa mapa setBuiltInZoomControls true controlador mapa getController Bundle bundle getIntent getExtras comida bundle getString comida dir bundle getString dir la eng E MOLEO GEY Geocoder geocoder new Geocoder abs p List lt Address gt addresses addresses geocoder getFromLocationName dir 1 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 66 AP NDICE B C DIGO FUENTE pd ProgressDialog show this Localizacin Esperando Cbreneradaros a 87 if addresses size gt 0 double latitude addresses get 0 getLatitude double longitude addresses get 0 getLongitude Location location new Location LocationManager GPS PROVIDER location setlatitude latitude location setLongitude longitude refreshMap location catch IOException e System out println e getMessage else COMELGER Sse pd ProgressDialog show this MOSCA 7 C1 Me MHS PE ran dOn COC AA cas nl SEST iy TKK KK KKK RK HRK RI I KA X K AKA Z K AKA I RK I RI I IK I ok
31. aplicacion Gauthor version 1 2 Eduardo Campos de Diago ee AK AX A K KA Z A K AK X K AK AX Z K AKA AX KAZ AK ee eee aE package com aplicacion ui im im im im im im im im im im im im im im im im public port port port port DOTE port port port port port port port port port port port ct pe aa AE FRJ t t GE al DV O 0 0 0 0 0 006 java io IOException java util java util java util Arraylist St concurrent ExecutionException com aplicacion conexion Post ndroid 1 MNOHO autres Sites ndroid view LayoutInflater ndroid widget Button ndroid widget LinearLayout ndroid widget Toast ndroid annot tation SuppressLint LOCa LOC ndroid view View ndroid widget EditText ndroid content Context ndroid tion Address tion Geocoder class ControlAnadir extends LinearLayout private private privat ES Edi Edi Edi tText ERestaurante prosa DANO en tText EWeb priva ES private But Eon dCeple But ton clear KK KK KK I KI I KI IR KI K AK AX AXA RARA KARA KARA I AK Z RK KAR 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 52 AP NDICE B C DIGO FUE
32. comprobar si tienen la comida deseada param String comida comida que se desea buscar param Restaurantes rests lisya der estaurantes que ya se sabe que tienen la comida buscada x return ArrayList lt Restaurantes gt 178 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 200 201 202 203 204 205 206 207 208 209 210 B 1 C DIGO JAVA 97 private static ArrayList lt Restaurantes gt restaurantesComidaWeb Restaurantes restaurantes String comida Restaurantes rests ResultSet resultSetWeb null SLIM query Statement statement ArrayList lt Restaurantes gt resTurn new ArrayList lt Restaurantes boolean esta false Restaurantes aux new Restaurantes CHEN statement cn createStatement Iterator lt Restaurante gt ite getRestaurantes iter while ite hasNext restaurantes ator ArrayList lt String gt plas new ArrayList lt String gt esta false Restaurante rest new Restaurante O rest Restaurante ite next query SELECT x FROM web WHERE id restaurante rest getId resultSetWeb statement
33. lt String gt adapterList new ArrayAdapter SOE CNAG Mas cuelan o O UE simple list item 1 datolist ListView list ListView findViewByld R id list list setAdapter adapterlist Adaptador del ListView y del GridView OnItemClickListener eventoList new OnItemClickListener public void onItemClick AdapterView lt gt parent View v int position 7 Lome abel Intent intent new Intent Submenu this SelectionAccion class Bundle bundle new Bundle OCH nono PO SOE parent getItemIdAtPosition position intent putExtras bundle startActivity intent asociacin de adaptadores y eventos list setOnItemClickListener eventoList 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 44 AP NDICE B C DIGO FUENTE Clase SelectionA ction java TKK KK KKK EE I IK I I EH AX KARA K KE Z K RE AKA Z ORI k k Fichero SelectionAction java Clase gue caracteriza el menu para la eleccion de accion author Eduardo Campos de Diago version 1 2 KKK KA AA KK AK Z K AK A X K AK AZ Z K AK AX A KA AX Z K AK Z K KAZ kk AK ARAS package com aplicacion ui import android app Activity import android os Bundle public class SelectionAccion extends Activity JR RER EE KK RK I IK I I I I K AK X K KAZ Z K Xe Xe I IK I Es llama
34. main 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 s7 58 59 60 61 62 63 64 65 66 67 68 B 1 C DIGO JAVA 39 Button bRestaurantes Button findViewById R id bot restaurantes Button bCines Button findViewById R id bot cines Button bTeatros Button findViewById R id bot teatros kerea caim de Tos ln final View OnClickListener eventoRestaurantes new View OnClickListener public void onClick View v Intent intent new Intent MainActivity this Submenu class Bundle bundle new Bundle pundilier puto Norti ao OM SO iO intent putExtras bundle startActivity intent final View OnClickListener eventoCines new View OnClickListener public void onClick View v xIntent intent new Intent MainActivity this Submenu class Bundle bundle new Bundle Bundle puto EGP O SI 2 intent putExtras bundle startActivity intent x AlertDialog Builder builder new AlertDialog Builder context builder setTitle Informacion Servicios builder setMessage Esta opci n no est disponible a n 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 4
35. 0 AP NDICE B C DIGO FUENTE builder setPositiveButton Aceptar We new O ACS Se A m OE PUBIC vou ONCEk DialogInterface dialog ae le bn ae dialog cancel i bunld r create tr builder show final View OnClickListener eventoTeatros new View OnClickListener public void onClick View v xIntent intent new Intent MainActivity this Submenu class Bundle bundle new Bundle DUNA purs NOA po SMo c intent putExtras bundle startActivity intent x AlertDialog Builder builder new AlertDialog Builder context bualider set little Tn SEU CROSS builder setMessage Esta opci n no est disponible a n builder setPositiveButton Aceptar Mew KONGRES Pene P OV OTO CAE DialogInterface dialog El A dialog cancel LA 97 98 99 00 01 02 03 04 05 06 07 08 09 B 1 C DIGO JAVA 41 builder create builder show asociacin de adaptadores y eventos bRestaurantes setonClickListener eventoRestaurantes bCines setOnClickListener eventoCines bTeatros setOnClickListener eventoTeatros 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 42 Clase Submenu java AP NDICE B C DIGO FUENTE KKK IK KK KK RK RK RK KR RK RK RK RK KK Fichero Submenu java
36. 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 104 AP NDICE B C DIGO FUENTE query SELECT id FROM Restaurante WHERE nombre nombret AND Y ap Melee gt rollito resultSet statement executeQuery query while resultSet next idRest resultSet getInt que query INSERT INTO web uri OLE status A UE SA A web idRest resultado statement executeUpdate guery if resultado 1 resJson update ok NE web US WE ClassNotFoundException CNFE System out println CNFE getMessage 1 SOLException SOLE System out println SOLE getMessage 2 InstantiationException IF E System out println IE getMessage 3 T IllegalAccessException IAE System out println IAE getMessage 4 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 B 1 C DIGO JAVA 105 recur tres JSEM KK KKK I KK I I KAZ K AK A AZ K AK A A I KA Z K K A ZX K AKA KARA K AK Z K AKA Z I RK RAR Puntua un plato en la bbdd En caso de no existir el plato lo crea param String nombre nombre del rest
37. 5 266 267 268 269 270 271 272 273 274 275 276 88 AP NDICE B C DIGO FUENTE this web add w JR RER HR RK I I KI I HR I K I I RI I RK I I I I XX Obtiene la lista de platos de un restaurante return ArrayList lt String gt KR KR KA AA KK AK Z K AK A X K AKA X K RE Xe HR KARA K public ArrayList lt String gt getPlatos return this platos TKK KK RE I KI I HR KARA K KAZ X K AKA A I KA AX Z KARA KR RR I Modifica la lista de platos de un restaurante param ArrayList lt String gt p nueva lista de platos KKK KK AKA AK AK AK Z K AK A X K AKA ZX K AK AX AX K AK AX KARA KARA ARRAY public void setPlatos ArrayList lt String gt p this platos p 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 B 1 C DIGO JAVA 89 Clase Restaurantes java Fichero Restaurantes java Clase que caracteriza una lista de restaurante Gauthor Eduardo Campos de Diago version 1 2 KKK KK AA K K AK AK Z K AK A A K KAZ Z AZ K AK X K AKA ZX K AKA KARA KARA KARA package serviOcios import java util Arraylist public class Restau
38. 50 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 96 AP NDICE B C DIGO FUENTE JR RE HR RK I AKA RE AX A AX K AK AX K KAZ X I RK I RK I RIK k k Obtiene restaurantes dadas unas coordenadas y una comida param double x coordenada x latitud param double y coordenada y longitud param String comida comida que se desea buscar return String json con la respuesta obtenida KKK KK AAA RH AK ZX K AK A X K AK AK Z K AKA X K AK AX Z KAZ KARA KARA KARA Y public static String obtenerRestaurantes double x double AONE COMA Gla Ser Agi SUS NA ML ArrayList lt Restaurantes gt resultados new Arraylist lt Restaurantes gt Restaurantes restaurantes new Restaurantes Restaurantes rests new Restaurantes restaurantes restaurantesEntornoADir x y resultados restaurantesComidaBBDD restaurantes comida rests resultados restaurantesComidaWeb resultados get 0 comida resultados get 1 resJson gson toJson resultados get 1 return resJson JR RE KK KR KI I KI I EH I RRA KARA KARA K AKA Z KARA XX Obtiene restaurantes que tienen una comida deseada tras buscar en la pagina web de dichos restaurantes x param Restaurantes restaurantes lista de restaurantes que se quiere
39. ARA KARA KARA ARAS public String getPlato return EPlato getText toString 82 83 84 85 86 87 88 89 90 91 92 93 94 B 1 C DIGO JAVA 63 KK KK I XXX I AK A AX I K AK AX AX RARA RI I KARA kA XX x Obtiene el valor del valor de la puntuacion return Int puntuacion dada KKK K I K AK AK Z K AK AX A K KAZ Z AZ K AK Z K AK AX Z ORI KAZ KR kk public int getPuntuacion qe 99 i grupo indexOfChild findViewById grupo getCheckedRadioButtonld 1 TN Ie iiy 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 64 Clase Mapa java AP NDICE B C DIGO FUENTE Fichero Mapa java Clase gue modela un mapa author Eduardo Campos de Diago version 1 2 KKK KAZ KK AK Z K AK A X K AK A Z K AK AX AX KA AX ZX KAZ AX K Ke KK KARA Y package com aplicacion ui im im im im im im im im im im im im im im im im im im port port port port port port port port port port port port pont port port port port port port port port pont public java io IOException java util
40. ARKK RARA KA AX KARA KARA KARA ARAS public void setRestaurantes ArrayList lt Restaurante gt r this restaurantes r JR RER KR KK IK RK I AKA A I K AK AX AX K AK X K KAZ X K AKA Xe AX Z KARA k ch A ade un restaurante a la lista de restaurantes return Restaurante r restaurante que se quiere anadir a Sea RH KR K AAA KK AK Z K AK A X K AK AK Z K AK AX X KA AX AZ K AK AX KARA KK RRA ARRAY public void add Restaurante r this restaurantes add r JR OR RE KK IR KI I KI I I IK I I IK I RI I ke Xe IK I IK I x Borra un restaurante a la lista de restaurantes param Restaurante r restaurante que se quiere borrar a la lista KR KR KA AA KK AK Z K AK A Z K AKA Z K ARR AX K AK HRK A kk A Z K public void remove Restaurante r if restaurantes contains r FOND ASPA Se tre apar B 1 C DIGO JAVA SEIE 91 restaurantes get i equals r this restaurantes remove 1 r 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 92 AP NDICE B C DIGO FUENTE B 1 4 Paquete core Clase Gestor java JR RH KK HR RIK I I AK AX AX AX RR K KAZ Z KARA KA AX Z KAR kk Fichero Gestor java Clase encargada de realizar la conexion a la BBDD y de responder las perico ne sia cmo sic lense san ta pitt acom author version 1 2
41. AlertDialog Builder mapView der context builder setTitle Informacion de restaurante int i int restaurante getPuntuacion 1 SW CINE e case 1 mensaje Nombre restaurante 141 142 143 144 145 146 147 B 1 C DIGO JAVA 75 getNombre WA nDireccin restaurante getDireccion NN nPuntuacin Este restaurante no ha sido puntuado We r break case 0 mensaje Nombre restaurante getNombre NDA SIE UE restaurante getDireccion t vm ne Caine Malo restaurante getPuntuacion 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 76 AP NDICE B C DIGO FUENTE E break case 1 mensaje Nombre restaurante getNombre SDE ee i W restaurante getDireccion nPuntuacin Regular restaurante getPuntuacion AIS break case 2 mensaje Nombre restaurante getNombre DARE a restaurante getDireccion Poe babe ab jal Bueno restaurante getPuntuacion SERA Me break case 3 case 4 mensaje Nombre restaurante getNombre IPS ee ave Wap RSSAC getDireccion nPuntuacin Muy Bueno restaurante getPuntuacion st Hie break builder setMessage mensaje 166 167 168 69 70 71 72 73 74 75 76 TT 78
42. Ban 8 Sarmiento P g E Mesta Senora Palace Hote e Macacha Guemes ficio Bank Fe ale ERC 9 a Am ric s Mercado E lo 5 A des Plata Repsol PF A y i M se ae Juan Domingu Pere 4 y Google 2 ta 2 i g E R nanen Eran Figura A 5 Resultado de una consulta En este mapa podr pulsar en los iconos de los restaurantes para obtener m s informaci n sobre ellos como su nombre direcci n y puntuaci n dada por los usuarios de la aplicaci n Informacion de restaurante hia eau de justo 430 Figura A 6 Detalle de un restaurante 34 AP NDICE A MANUAL DE USUARIO De este modo podremos saber que restaurantes disponen de esa comida que deseamos A 3 A adir restaurantes Como se coment previamente esta aplicaci n tambi n es capaz de apren der nuevos restaurantes mediante la colaboraci n de los usuarios as pues ahora procederemos a ver c mo se pueden a adir nuevos restaurantes Para ello en la pantalla del submenu deber seleccionar la opci n A adir un restaurante esto le conducir a un nuevo formulario en el cual podr insertar los datos de un restaurante Los campos Nombre y Direcci n son obligatorios as pues en caso de que no los cumplimente aparecer un aviso por pantalla indic ndo que deben ser relle nados Cabe destacar que cuanto m s exacto sea a la hora de poner la direcci n mayor facilidad y enriquecimiento habr entre los us
43. C digo HTML JSP index jsp lt page language java contentType text html charset NSCOS 38609231 pageEncoding IS0 8859 1 lt page import core Gest o o gt EOE A S lt DOCTYPE html PUBLIC W3C DTD HTML 4 01 Transitional EN http www w3 org TR html4 loose dtd gt lt html gt lt head gt lt meta http eguiv Content Type content text html charset IS0 8859 1 gt lt title gt resto JSP lt title gt lt head gt lt body gt PeoOyecuo ema CE Gan ea Fecha Actual lt new Java util Date gt lt FORM NAME forml ACTION index jsp METHOD get gt opcion lt input type text name DE aera x lt input type text name X gt y lt input type text name Y gt comida lt input type text name comida gt lt input type hidden name 0K gt lt input type submit value show gt lt FORM gt if request getParameter OK null COMIDO E double y String comida String nombre SEST O CIN 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 B 2 C DIGO HTML JSP 109 String web float puntuacion char opcion request getParameter option charAt 0 switch opcion SAS x Double valueo0f request getParameter X y Double valueo0f reques
44. K I EH RE Z K AK A ZX I K AK AK AX I I IRI I KARA KAR RR Kk Constructor de la clase ControlBuscar as param Context contesto de la aplicacion param AttributeSet Atributos public ControlBuscar Context context AttributeSet attrs super context attrs occiso JR RER KK I HR EE Z K AK A AX K AKA AX RARA K AK AX KARA KARA KARA RR KA Inicializa la interfaz para ser mostrada KKK KK AZ K K A AK Z K AK A A K KAZ Z AZ K AK X K AK AX Z K AKA AX KARA KAR kk private void initialize String interfaz Context LAYOUT INFLATER SERVICE LayoutInflater inflater LayoutInflater getContext getSystemService interfaz inflater inflate R layout buscar this true EComida EditText findViewById R id edit comida LDir TextView findViewById R id label direccion 7 EDir EditText findViewByld R id edit_direccion check CheckBox findViewById R id checkBox gps acept Button findViewById R id button Buscar clear Button findViewById R id button Clear addEvents 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
45. MOO USA O uote double y OEM 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 s7 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 B 1 C DIGO JAVA LES OS ab this nombre n ES OS Con hats CO T S PRES Coordi yY this puntuacion this web new ArrayLis e x y d e e D 83 ESSE A this platos new ArrayList lt String gt KKK KR KK RK I I RI I RIK IK IK K KA X K RI RIKI RIK I EX Constructor vacio de la clase restaurante KKK KK AZ K K A AK Z K AK AX A K KARA K AK Z K AK AX Z K AKA AX KAZ K AK AXA kk public Restaurante late gael lt gt ibs this nombre this direccion hats Co TC this coord Y this puntuacion this web new Arraylis e LR ESSE this platos new ArrayList lt String gt KK KKK I XXX K AK A AX K RK I KR AK AX Ak KAR kA A Z K k Z kk ACON SEAC CO jan ar Aro Sey yl AD C param param ArrayLis lt String gt pl param int i indice de la bbdd param String n nombre Gene ks ngc ose cem param double x coordenada x param double y coordenada y peee Jo AO UNIEUHAIC aL io param ArrayList lt String gt w 1 List TES tor de la clase restaurante ta de webs ta de platos KKK I AZ I K A AK Z
46. NTE Constructor de la clase ControlAnadir param Context contesto de la aplicacion A public ControlAnadir Context context super context natale ei Ds TKK KKK KK KR I IK I I AK AX AX Ge X K AKA X K Xe AX Z KAZ RE I Constructor de la clase ControlAnadir param Context contesto de la aplicacion param AttributeSet Atributos A public ControlAnadir Context context AttributeSet attrs SUPET CONGSXE AES ie Se JR RER RE KI IK I I HR AK X K KAZ X AKA Xe Z K AKA RR Inicializa la interfaz para ser mostrada KR KR KA AA KK AK Z K AK A X K AK A Z K AK AX Z K AK AX ZX AZ KAZ Z K KAZ KARA KARA Y private void initialize String interfaz Context LAYOUT_INFLATER_SERVICE LayoutInflater inflater LayoutInflater getContext getSystemService interfaz inflater inflate R layout anadir this true ERestaurante EditText findViewById R id edit restaurante EDireccion EditText findViewById R id comida seccion EWeb EditText findViewById R id edit web acept Button findViewById R id button Anadir clear Button findViewById R id button Clear 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 01 02 03 04 05 06 07 08 09
47. S TBA INSTITUTO TECNOLOGICO DE BUENOS AIRES UNIVER SIDAD PRIVADA Escuela Universitaria de Ingenier a T cnica de Telecomunicaci n Universidad Polit cnica de Madrid Proyecto Final de Carrera Aplicaci n m vil de localizaci n de ocio para Android Autor Eduardo Campos de Diago Legajo 54483 DNI 51423674 K Tutor Dra Silvia G mez 2013 Dedicado a mis padres y hermana por apoyarme en todo momento II Agradecimientos A mis amigos Tono Mardo Beto y Rober porque sus risas son mis alegr as A mis colegas de la universidad Tiko Kike Paula David desArmando Por que nuestras cabezas se han llenado juntas de nuevas paranolas A mi tutora Silvia G mez y a Leticia G mez que desde las sombras me ha echado un cable MUCHAS GRACIAS Il IV AGRADECIMIENTOS Resumen No sabes d nde comer un plato t pico cuando est s de vacaciones Quieres ir con amigos a comer a un sitio distinto Quieres disfrutar de esa comida que tanto te gusta y no sabes d nde hacerlo Con af n de responder a estas preguntas y gracias a las capacidades que nos brindan las nuevas tecnolog as de dispositivos m viles surge la aplicaci n que se presenta en este proyecto fin de carrera Se tra ta de una aplicaci n para dispositivos m viles con sistema operativo Android que nos brindar la opci n de encontrar restaurantes en nuestro entorno que nos ofrez can esa comida que queremos Adem s a modo de red so
48. SON OP OBZ y meste ato ant super draw canvas mapView shadow i drawAt canvas imagen point2 x xOffset shadow Done 7 We an O SEE Iterator lt Restaurante gt ite restaurantes getRestaurantes iterator while ite hasNext Restaurante rest ite next punto new GeoPoint int rest getCoordy x 1000000 int rest getCoordX x 1000000 Point point2 new Point Projection p mapView getProjection PAGOS ISO OP ONE 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 74 AP NDICE B C DIGO FUENTE canvas drawText rest getNombre PON EDS EMA DOZ ytintrinsicHeight paint super draw canvas mapView shadow 7 drawAt canvas imagen point2 x XORESCE POUNnEZ ay a VO LESC shadow Override public boolean onTap GeoPoint point MapView mapView double margen 0 0001 double Tat Lon lat point getlatitudeE6 1E6 lon point getLongitudeE6 1E6 Iterator lt Restaurante gt ite restaurantes getRestaurantes iterator while ite hasNext Restaurante restaurante ite next if getDistance lat lon restaurante getCoordY restaurante getCoordX lt margen AlertDialog Builder builder new
49. Z AX K KAZ KARA ARAS private void addEvents final OnClickListener eventoAcept new OTNCHBRSkS SSME public void onClick View v try if getRestaurante length lt 1 getPlato length lt 1 Toast makeText getContext Debes completar el nombre del restauranter ok ede eae else que deseas puntuar y su puntuacin Toast LENGTH_LONG show ArrayList lt String gt parametros new ArrayList lt String gt parametros add option parametros add 2 parametros add nombre parametros add getRestaurante toLowerCase parametros add plato parametros add getPlato toLowerCase parametros add puntuacion parametros add String valueo0f getPuntuacion parametros add OK parametros add ok Post post new Post post execute parametros 121 122 123 124 125 126 127 128 129 30 31 32 33 34 35 36 37 38 39 40 41 B 1 C DIGO JAVA catch catch 61 String datos post get if datos contains nok ise datos Conta nS nok OM Toast makeText getContext No tenemos ese restaurante guardado EO O POHANSKO para poder puntuar el uo EO ASE LENGTH LONG show else Toast makeText getContext En estos momentos no SEMA O ACC Y an Y guardara el Oe ES al 19d
50. a el servidor eu clmenisemy author Eduardo Campos de Diago version 1 2 Encargada de realizar la conexion HTTP mediante mensajes POST entre EA package com aplicacion conexion import Java io BufferedReader import java io InputStream import Java io InputStreamReader import java util Arraylist import org apache http HttpEntity import org apache http HttpResponse import org apache tl een Epee import org apache http client entity UrlEncodedFormEntity impone LG apache heep sc lkuent mechods Teepe sit nn On oa oo ne shit pmp relate mice Der au Ise Hitt CE import org apache http message BasicNameValuePair import android os AsyncTask MOORE Anou public class Post extends AsyncTask lt ArrayList lt String gt SE Ag private final String server http eiffel itba edu ar TENS Oy Aue private InputStream is null private String respuesta 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 B 1 C DIGO JAVA 79 KK HR HR Z K AKA AXA K RI AX AZ K AK AX I II A Z I IK I dHreCClOon indicada GParam ArrayLis enviar param String Ul Envia un mensaje post con los parametros deseados a la t parametros Parametros que se quiere
51. a nuestro servicio web pos e tres funciones A continuaci n procederemos a enumerar los par metros que de bemos enviar en nuestro mensaje post para el correcto funcionamiento de nuestro servidor 2 4 1 1 Buscar restaurantes Para hacer uso de esta funcionalidad nuestro mensaje post debe contener los siguientes par metros Option Identifica el tipo de operaci n a realizar Para realizar una b squeda de restaurantes debe ser 0 X Coordenada x latitud Y Coordenada y longitud comida Comida que se desea buscar OK Indica la validez de la petici n Debe existir este par metro en el men saje post y ser distinto de null 2 4 1 2 A adir restaurante Para hacer uso de esta funcionalidad nuestro mensaje post debe contener los siguientes par metros Option Identifica el tipo de operaci n a realizar Para realizar una b squeda de restaurantes debe ser 1 nombre Nombre del restaurante que se desea a adir dir Direcci n del restaurante que se desea a adir X Coordenada x latitud del restaurante que se desea a adir Y Coordenada y longitud del restaurante que se desea a adir web P gina web del restaurante que se desea a adir 2 4 DOCUMENTACI N DE INTERFACES 23 OK Indica la validez de la petici n Debe existir este par metro en el men saje post y ser distinto de null 2 4 1 3 Puntuar plato Para hacer uso de esta funcionalidad nuestro mensaje post debe c
52. aci n que vamos a desarrollar tiene una funcionalidad clara que es la de localizar restaurantes en nuestro entorno que tengan una determinada comida Pero adem s de esto posee varias funcionalidades m s derivadas de esta Ahora procederemos a enumerar las funcionalidades de la aplicaci n Localizaci n de restaurantes e Mediante gps usando la posici n actual del dispositivo e Insertando una direcci n en torno a la que buscar Red social e Insertar nuevos restaurantes a la aplicaci n e Puntuar platos de los restaurantes recomendados Mediante estas funcionalidades agregadas se busca que la aplicaci n sea m s completa agreg ndole valores a adidos a la misma El hecho de que se pueda bus car mediante gps o insertando una direcci n facilita el uso de la aplicaci n tanto para usos tur sticos como para dispositivos que no posean gps El hecho de que tambi n posea las funcionalidades que hemos denominado como red social tendr dos principales ventajas La primera de ellas ser el hecho de que el sistema podr ir enriqueci ndose aumentando el n mero de restaurantes que se tendr n como referencia en las b squedas La segunda de estas ventajas ser la capacidad de ofertar al usuario una informaci n m s completa y contrastada por otros usuarios a la hora de realizar consultas Cap tulo 2 Documentaci n 4 CAP TULO 2 DOCUMENTACI N 2 1 Modelo del sistema El sistema que vamos a utilizar para el desarro
53. aurante param String plat plato que se quiere puntuar param float punt puntuacion del plato return String json con la respuesta A Alia SE AE CSE OM SEPA OSS AA on er Se PUN AKO CEHO String query SERU gines Us ONO CEE NO ME Statement statement abiates bobo float puntuacion int resultado ELY conectarBBDD statement cn createStatement query SELECT id FROM Restaurante WHERE nombre MO MOS HMS ResultSet resultSet statement executeQuery query if resultSet next resJson update nokO else 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 106 AP NDICE B C DIGO FUENTE int id restaurante resultSet getInt id LA query SELECT 4 FROM Plato WHERE plato plat AND id restaurante id restaurante BESURESESE statement executeQuery query ACE SES Slee ne puntuacion resultSet getFloat collie EO NIE id resultSet getInt id one eve A puntuacion puntuacion PUNEN else puntuacion punt query update plato sel Calk CAE One AE DO UNE where id id uacion resultado statement exX query else cuteUpdate query INSERT INTO plato plato calificacion id_resta
54. cial incluye la opci n de poder puntuar los platos degustados en los restaurantes e insertar restaurantes nuevos lo que hace que la aplicaci n tenga una mayor versatilidad En este documento se podr n encontrar los diagramas UML que modelan el proyecto tanto la parte de la aplicaci n como la parte del servidor En l tambi n podremos encontrar otra documentaci n como un manual de usuario de la aplica ci n el c digo fuente de la misma y proposiciones de futuras versiones y mejoras de la aplicaci n actual VI RESUMEN Abstract Don t you know where you can eat a typical dish when you are on holidays Do you want to go to eat to a different place Do you want to enjoy that meal you love and you don t know where you can do it To answer those questions and thanks to the possibilities of modern smartphones technology we present this application in my degrees final project This application which runs with an Android operative system gives us the option to find restaurants in our environment that offer the meal we really want In addition as a social network 1t includes the option to rate the tasted dishes or to add new restaurants giving the application versatility Nowadays our society is used to the use of smartphones and their possibilities That is why we must to explore its potential to obtain better amenities In the last few years the amount of available applications for these devices has increased too much offering a
55. ciones sobre bases de datos desde el lenguaje de programaci n Java que ser el lenguaje escogido para el desarollo de todo el proyecto Cabe destacar el hecho de que la base de datos es totalmente independiente de la aplicaci n m vil lo que hace que sea transparente para esta Aplicaci n m vil lt lt htip gt gt Figura 2 2 Diagrama de despliegue 2 1 3 Arquitectura del sistema Si observamos la arquitectura de la aplicaci n de un modo m s profundo pode mos contemplar los componentes que tiene cada uno de los nodos Cabe resaltar el componente serviOcio presente tanto en la aplicaci n m vil como en el servicio Este componente es el encargado de modelar los restaurantes y sus caracteristicas CAP TULO 2 DOCUMENTACI N Aplicaci n m vil I Servicio Lo serviOcios Lo Figura 2 3 Diagrama de la arquitectura 2 2 FUNCIONALIDAD 7 2 2 Funcionalidad En este apartado vamos a realizar un estudio de estas funciones que tiene la aplicaci n estudiando tanto su flujo como los componentes que intervienen en ellas Como ya hemos comentado previamente la aplicaci n dispone de tres fun cionalidades b sicas Buscar restaurantes a A adir un restaurante Puntuar un plato 2 2 1 Casos de uso Los casos de uso de la aplicaci n se corresponden con cada una de las fun cionalidades que tiene la misma as pues el diagrama de casos de uso ser el siguiente Aplicaci n Buscar r
56. das de la direcci n in sertada por el usuario el resto de las comprobaciones en cuanto a si ya existe ese restaurante en la base de datos son realizadas por el servicio web 2 2 FUNCIONALIDAD 17 2 2 3 3 Puntuar un plato Puntuar plato restaurante plato puntuaci n I 1 1 1 1 1 1 1 Buscar restaurante nombre Buscar plato plato id_restaurante return Buscar plato plato id_restaurante retum Buscar restaurante nombre 1 1 1 I 1 Puntuar plato id_plato puntuacion return Puntuar plato id_plato puntuaci n return Puntuar plato restaurante plato puntuaci n Figura 2 16 Diagrama de secuencia Puntuar plato En este caso la aplicaci n m vil debe env ar los par metros nombre plato y puntuaci n al servicio web Como en los casos anteriores todas las comprobacio nes de si existe ya ese plato registrado en la base de datos o si se debe crear son llevadas a cabo por el servicio web 18 CAP TULO 2 DOCUMENTACI N 2 3 Diagrama de clases En estos diagramas podremos ver m s detenidamente como se ha implementa do el proyecto Como hemos estado realizando en otros puntos de este documento a la hora de ver los diagramas de clases tambi n separaremos la parte de la apli caci n m vil y la parte del servidor Pero previamente vamos a echar un vistazo r pido a todos los paquetes del proyecto y su relaci n com aplicacion ui com aplicacion
57. de datos para comprobar si existe ese restaurante En caso de que no exista lo a ade y confirma la operaci n a la aplicaci n En caso de existir se lo comunica a la aplicaci n 2 2 FUNCIONALIDAD 13 2 2 2 5 Puntuar plato Aplicaci n m vil Seleccionar Restaurantes Seleccionar Puntuar Insertar datos No existe el restaurante Notificaci n de que no existe el restaurante Existe el restaurante Notificaci n de puntuaci n correcta Figura 2 12 Diagrama de estados Puntuar plato aplicaci n Si lo que deseamos es puntuar un plato la aplicaci n nos pedira que comple temos los datos necesarios Una vez completados correctamente se realizar una petici n al servidor Seg n los datos que nos devuelva el servidor se mostrar un mensaje de error o de operaci n realizada 14 CAP TULO 2 DOCUMENTACI N 2 2 2 6 Puntuar plato Servidor Recibir una petici n de puntuar Buscar restautante en la BBDD Hay resultados Buscar el plato en la BBDD con el id del restaurante Existe el plato Calcular la media de la puntuaci n del plato Cambiar la puntuaci n del plato en la BBDD Calcular la media de la puntuaci n del restaurante Cambiar la media del restaurante en la BBDD Enviar respuesta No hay resultados No existe el plato Insertar el plato con la puntuaci n en la BBDD Figura 2 13 Diagrama de estados Puntuar plato servidor Cuando el servidor recibe u
58. do cuando es creado public void onCreate Bundle savedInstanceState super onCreate savedInstanceState Bundle bundle getIntent getExtras short option bundle getShort option switch option case 0 setContentView R layout layout_buscar break Case 1 40 41 42 43 44 45 46 47 48 49 50 B 1 C DIGO JAVA case 2 45 setContentView R layout layout anadir break setContentView R layout layout puntuar break 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 46 AP NDICE B C DIGO FUENTE Clase ControlBuscar java Fichero ControlBuscar java Clase que modela la pantalla de la funcion buscar de la aplicacion x author Eduardo Campos de Diago
59. e desea buscar y la comida que se desea Es funci n del propio servicio web encargase de las sucesivas consultas a la base de datos e internet para obtener los resultados que se presentar n por la pantalla del dispositivo m vil Cabe destacar que tanto si se utiliza gps como si no la llamada efectuada al servicio web es la misma as pues debe ser funci n del dispositivo m vil el obtener las coordenadas de la direcci n que inserte el usuario 16 CAP TULO 2 DOCUMENTACI N 2 2 3 2 A adir restaurantes Aplicaci n m vil BBDD 1 I l 1 1 A adir restaurante nombre direcci n coord X coord Y web 1 l 1 l l l 1 1 Buscar restaurante nombre direcci n return Buscar restaurante nombre direcci n A adir restaurante nombre direcci n coord_x coord_Y retum A adir restaurante nombre direcci n coord_x coord_Y A adir web web id restaurante I 1 return A adir web web id_restaurante il Taname o a n M T 1 return A adir restaurante nombre direcci n coord_X coord_Y web Figura 2 15 Diagrama de secuencia A adir restaurante Al igual que suced a anteriormente la aplicaci n m vil solo efect a una lla mada al servicio web env andole el nombre la direcci n las coordenadas y la direcci n web como par metros Al igual que en el caso previo tambi n es fun ci n de la propia aplicaci n m vil el obtener las coordena
60. em in 9 Consulta insertando coordenadas double x double y System out println nInserte coordenada X aux teclado next Double parseDouble aux System out println nInserte coordenada Y aux teclado next y Double parseDouble aux System out println inInserte SOMA aux teclado next SV Sie Mp OU PEN 6 ncomida aux x sr Em EURE resultado obtenerRestaurantes x y aux System out println resultado break Sian y Ads E cion 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 94 case 2 AP NDICE B C DIGO FUENTE String nombre System out prin MOM nombre teclad System out prin dinae e An direccion tec System out prin coordenada X aux teclado n x Double pars System out prin coordenada Y aux teclado n String web Wi r A M NIS OMS tin nInserte 3 lado next tln AnInserte War r ext eDouble aux tln AnInserte e r ext y Double parseDouble aux System out printin nInserte web 2 web teclado next resultado insertRestaurante nombre direccion X y web System out println resultado break puntuar un plato LO SEO System out println XnInserte rest 2 nombre teclado nex
61. esses size gt 0 parametros add X double longitude addresses get 0 getLongitude parametros add String valueOf longitude parametros add Y double latitude addresses get 0 getLatitude parametros add String valueOf latitude parametros add 0K parametros add ok Post post new Post post execute parametros String datos post get if datos contains nok Toast makeText getContext Gracias por tu ayuda aunque este Restaurante ya est registrado Toast LENGTH LONG show O else if getWeb length gt 0 145 146 147 148 149 150 151 152 53 54 55 56 57 58 59 160 161 B 1 CODIGO JAVA IAE GONE da else lse He D else tos contains ok tos contains wok Toast makeText getContext Gracias por ensearnos u restaurante nuevo Toast LENGTH LONG show Toast makeText Gee C omeencts ON En estos momentos no s has dido guardar este restaurante intentelo de 55 amp amp n E nuevo m s tarde TO Sida LENGTH LONG how n CAROS SCO ETSAC OITO Toast makeText JSPEONESACI Gracias por Ste A E151 restaurante nuevo Toast LENGTH LONG show 162 163 164 165 166 167 168 169 170 171 172 173 174 175
62. estaurantes A adir un restaurante Usuario Puntuar un plato Figura 2 4 Diagrama de casos de uso 2 2 1 1 Buscar restaurantes Aplicaci n Figura 2 5 Diagrama de caso de uso Buscar restaurantes Usuario 8 CAP TULO 2 DOCUMENTACI N Esta funcionalidad nos permitir realizar una b squeda de restaurantes que dispongan entre sus platos la comida que indiquemos 2 2 1 2 A adir restaurantes Aplicaci n A adir un restaurante Usuario Figura 2 6 Diagrama de caso de uso A adir un restaurante Como ya hemos visto la aplicaci n se apoya en una base de datos Esta fun cionalidad nos permite a adir los datos de restaurantes a dicha base de datos 2 2 1 3 Puntuar plato Aplicaci n Puntuar un plato Usuario Figura 2 7 Diagrama de caso de uso Puntuar un plato Como acabamos de comentar disponemos de una base de datos remota Con esta funcionalidad podremos puntuar platos que hayamos pobado en un restauran te 2 2 2 Diagramas de estados Con estos diagramas representaremos el flujo de nuestra aplicaci n estudiando el diagrama de cada uno de los casos de uso y mostrando los estados por los que pasar Para esto es conveniente que estudiemos lo que suceder tanto en nuestra aplicaci n m vil como en el servidor por separado 2 2 FUNCIONALIDAD 9 2 2 2 1 Buscar restaurantes Aplicaci n m vil Seleccionar Restaurantes Seleccionar Buscar Insertar datos Ha seleccionado
63. estaurantes buscar en la base de datos si tienen la comida deseada de no ser as y en caso de que los restaurantes tengan p gina web buscar en la p gina web 2 2 FUNCIONALIDAD la comida Por ltimo los resultados obtenidos los mandar a la aplicaci n 2 2 2 3 A adir restaurantes Aplicaci n m vil Seleccionar Restaurantes Seleccionar A adir Insertar datos No existe el restaurante Notificaci n de que se ha creado correctamente Existe el restaurante Notificaci n de que ya est registrado Figura 2 10 Diagrama de estados A adir restaurante aplicaci n 11 En el caso de que lo que deseemos sea a adir un restaurante la aplicaci n nos pedir los datos necesarios Una vez cumplimentados correctamente se har una llamada al servidor y con los datos devueltos se mostrar un mensaje de operaci n realizada correctamente o operaci n incorrecta 12 CAP TULO 2 DOCUMENTACI N 2 2 2 4 A adir restaurantes Servidor Recibir una petici n de a adir Buscar restautante en la BBDD No hay resultados Agregar restaurante a la BBDD No se recibe par metro web Hay resultados Se recibe par metro web Agregar web a la BBDD Enviar respuesta Figura 2 11 Diagrama de estados A adir restaurante servidor Cuando el servidor recibe una petici n para a adir un restaurantes lo primero que hace es obtener los datos de la petici n Con estos datos consulta la base
64. his imagen draw nas rex exter this punto point KK KKK KK KR KI EE I I EH I KI I AKA X K RI I AK AX XX XX Constructor de la clase MapOverlay param Drawable draw param Restaurantes r Restaurantes que se quieren mostrar XHAKKKKRKKKARKKKARKAKKARKAK AKA X K AK AX ZX KARA KARA XXE Y public MapOverlay Drawable draw Restaurantes r this imagen draw this restaurantes r KK KK KR KK kk RK I A A I I IKI K KAZ X K RK I RI I ORI k k Dibuja el overlay param Canvas canvas param MapView mapView param boolean shadow A public void draw Canvas canvas MapView mapView boolean shadow if shadow final int intrinsicWidth imagen getIntrinsicWidth 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00 01 02 03 04 05 06 107 108 109 110 B 1 C DIGO JAVA 73 final int intrinsicHeight imagen getinte sae HE VOTAN E imagen setBounds 0 0 intrinsicWidth intrinsicHeight xOEFESeEE intrinsicWidth 2 yOffset intrinsicHeight 2 Paint paint new Paint paint setARGB 250 0 0 0 paint setAntiAlias true paint setFakeBoldText true ise reas SS 4 Point point2 new Point On Projection p mapView getProjection Pe oP Xe S DUNE O Ot canvas drawText text point2 x He en
65. huge variety of them If we realize a research about their functionalities and uses we will discover that most of them are oriented to leisure That is why we are going to start the inquiry of a software engineering project developing a restaurant localization restaurant for Android smartphones In this document you can find the UMI diagrams which model the project both the application part and the server part Besides you can find other documents as an application user manual the source and proposals for future versions and improvements ndice seneral Agradecimientos Resumen Lista de figuras 1 2 Introducci n ll Motivacion cuna rr a a tne me 1 2 Funcionalidades Documentaci n 2 1 Modelo del SISTEMA i e sno By Ve A Sea ne o pain 2 1 1 Diagrama de bloques 2 1 2 Diagrama de despliegue 2 1 3 Arquitectura del sistema 24 24 a al a eas 22 Funcionalidad a a sed Ge OR n b o RG Oe 22 14 Casos de USO AS id a PEN LS Z Body 2 2 1 1 Buscar restaurantes 2 2 1 2 A adir restaurantes 4 55 6 44 du di 2213 Binar plates es the e de ao de id ind 2 2 2 Diagramas de estados fe pst ose ASE Sas Rs 2 2 2 1 Buscar restaurantes Aplicaci n m vil 2 2 2 2 Buscar restaurantes Servidor 2 2 2 3 A adir restaurantes Aplicaci n m vil 2 2 2 4 A adir restaurantes Servidor 2 2
66. ir setVisibility INVISIBLE EDir setVisibility INVISIBLE acept setOnClickListener eventoAcept clear setOnClickListener eventoClear check setOnCheckedChangeListener eventoCheck KKK KKK I KI IK I I AK A AX I I RK I RI AX K RI I I I RIK RK I KR Obtiene el valor del string escrito en la etiqueta de comida return String comida que se busca KKK I A AK Z K AK AX A K KA Z Z KARA K AK AX Z K AKA AX KARA KARA KARA public String getComida return EComida getText toString JR OR Re HR XXX Z K AKA AX IK K RI I RIK I I I RIK I RK I Obtiene el valor del string escrito en la etiqueta de direccion return String direccion donde buscar HORREUR HE HRK A AK Z K AK AX A K KAZ Z AZ KAR K AK AX Z AK Xe KARA KARA PUIS ONA oc De 155 156 157 50 AP NDICE B C DIGO FUENTE return EDir getText toString 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 B 1 C DIGO JAVA 51 Clase ControlAnadir java Te En ControlAnadir java Clase gue modela la pantalla de la funcion anadir de la
67. la opci n deseada es la de localizar restaurantes mediante nuestra aplica ci n usted podr buscar restaurantes que contengan en su carta un plato que des e tomar Esta funcionalidad tiene dos m dos de uso Mediante gps Indicando una direcci n Para poder acceder a cualquiera de los dos m dos de b squeda deber pulsar la opci n Buscar restaurantes del submenu Una vez haya puldado dicha opci n aparecer un formulario en el que tendr que indicar qu desea comer y si usar gps o no En caso de que seleccione que no desea usar gps le aparecer un nuevo campo para insertar la direcci n en torno a la que desea buscar 32 AP NDICE A MANUAL DE USUARIO Desea escribir una direcci n para la b squeda Buscar Borrar Figura A 3 Formulario usando gps Comida que deseas ntruduzca la comida que Direcci n Intruduzca la direcci n que desea Y Desea escribir una direcci n para la b squeda Buscar Borrar Figura A 4 Formulario sin el uso de gps Despu s de rellenar el formulario y pulsar el bot n de buscar en ambos casos y tras un tiempo de espera le aparecer n los resultados dibujados en un mapa A 2 BUSCANDO RESTAURANTES 33 Viamonte ki E E A 3 g i E 4 5 5 Tucum n tucum n ho 8 A 2 5 3 2 E 5 E E i 5 Lavale gt Lavabe Lavell Miss a sers rinidad Guevara 3 e F i ure R 3 A re
68. llo de la aplicaci n se basa en una estructura cliente servidor En este apartado vamos a estudiar la estructura que tendr el sistema y como se interconectar n los distintos elementos del mismo 2 1 1 Diagrama de bloques A Usuario UA Aplicaci n m vil Interfaz de usuario Buscar un A adir un Puntuar un plato restaurante restaurante Conexion Servicio web Servicio BBDD Figura 2 1 Diagrama de bloques 2 1 MODELO DEL SISTEMA 5 En esta primera aproximaci n al proyecto podemos observar dos bloques bien diferenciados la aplicaci n m vil y el servidor La parte del servidor posee el servicio propiamente dicho y la base de datos de la que hace uso Por su parte la aplicaci n tiene dos bloques separados claramente la interfaz gr fica y el conector con el servicio Si nos detenemos a observar la parte de la interfaz gr fica de la aplicaci n m vil podemos comprobar que tiene tres bloques Estos se corresponden con cada una de las funcionalidades b sicas que tiene la aplicaci n 2 1 2 Diagrama de despliegue Mediante este diagrama podemos observar que la comunicaci n entre el clien te aplicaci n m vil y el servidor servicio se realizar mediante el protocolo HTTP Tambi n podemos comprobar que el acceso a la base de datos se realiza r mediante Java Database Connectivity jdbc un API que permite la ejecuci n de opera
69. n RL URL del servicio KKK KK AA K K AK AK Z K AK A A K KAZ Z K AK Z K KARA K AKA KARA KARA KARA private void conectaPost ArrayList parametros String URL ArrayList nameValuePairs CHEN Ht Ht tpClient httpclient new DefaultHttpClient tpPost httppost new HttpPost URL nameValuePairs new Arraylist IAZ Ht Ht is parametros null for int i 0 i lt parametros size o ste A nameValuePairs add new BasicNameValuePair String parametros get 1 String parametros get SE apo EO httppost setEntity new UrlEncodedFormEntity nameValuePairs tpResponse response httpclient execute REPOS tpEntity entity response getEntity entity getContent catch Exception e 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 80 AP NDICE B C DIGO FUENTE FORMS AMP NI ee EPA ONCE LOR U a S COSCE LRC A finally TKK KK KKK kk RK I I AKA A I K AK A I AK AK X K KA X K AKA I RIKI I RI I XX Obtiene una respuesta del servidor correspondiente a la peticion realizada x return String codigo completo de la respuesta HTTP
70. na petici n para puntuar un plato obtiene los datos de la petici n Con estos consulta la base de datos para comprobar si existe el 2 2 FUNCIONALIDAD 15 restaurante al que pertenece el plato si existe comprueba si se tiene ya puntuado el plato De ser as cambia la puntuaci n de este plato recalcula la puntuaci n media del restaurante y manda una respuesta afirmativa Si no existe el plato crea el plato lo punt a recalcula la media del restaurante y env a una respuesta afirmativa Si el restaurante no existe se manda un mensaje de error 2 2 3 Diagramas de secuencia Con estos diagramas podremos comprender como se ejecuta el proyecto cro nol gicamente De nuevo tendremos un diagrama distinto para cada funcionalidad del sistema 2 2 3 1 Buscar restaurantes Aplicaci n m vil Servicio web BBDD Internet Buscar restaurantes coord X coord Y comida Buscar restaurantes por posici n Coord X Coord Y return Buscar restaurantes por posici n Coord X Coord_Y Buscar restaurantes por comida restaurantes comida 1 1 I return Buscar restaurantes por comida restaurantes comida retum Buscar restaurantes coord_X coord_Y comida Figura 2 14 Diagrama de secuencia Buscar restaurantes Como podemos comprobar nuestra aplicaci n m vil efect a una nica llama da al servicio web pas ndole como par metros las coordenadas de dond
71. ontener los siguientes par metros option Identifica el tipo de operaci n a realizar Para realizar una b squeda de restaurantes debe ser 2 nombre Nombre del restaurante en el que se desea puntuar el plato plato Nombre del plato que se desea puntuar puntuacion Puntuaci n que se le da al plato OK Indica la validez de la petici n Debe existir este par metro en el men saje post y ser distinto de null 24 CAP TULO 2 DOCUMENTACI N 2 5 Documentaci n de la base de datos Como hemos estado viendo a lo largo de toda la documentaci n el servicio web hace uso de una base de datos En este apartado nos disponemos a ver un poco m s en profuncidad el dise o de la misma 2 5 1 Tablas restaurante id nombre direccion coor X coor Y puntuacion id Se trata del identificador de los restaurantes de tipo entero Es de tipo integer nico autoincremental y no puede ser nulo a nombre Es una cadena de sesenta caracteres como m ximo Es el nombre del restaurante No puede ser nulo direccion Es una cadena de cien caracteres como maximo Es la direcci n del restaurante No puede ser nulo m coor X Se trata de la coordenada x del restaurante latitud Es del tipo float coor_Y Se trata de la coordenada y del restaurante longitud Es del tipo float puntuacion Es la puntuaci n media de todos los platos que se tiene regis trados y puntuados del restauran
72. os 5 Sa ghee ha a tds 82 B Paquete Core seere grani dorna der de e de ek roue Vee ke 92 B 2 C digo HTML JSP td ae She a ala 108 ndice de figuras 2 1 22 2 3 2 4 2 5 2 6 2 2 8 2 2 10 2 11 2412 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 222 A l A 2 A3 AA AS A 6 A 7 A 8 Diagrama de bloques 4 Diagrama de despliegue 4 46 cou a we we A 5 Diagrama de la arquitectura veia at 6 Diagrama de casos deuso 7 Diagrama de caso de uso Buscar restaurantes 7 Diagrama de caso de uso A adir un restaurante 8 Diagrama de caso de uso Puntuarunplato 8 Diagrama de estados Buscar restaurante aplicaci n 9 Diagrama de estados Buscar restaurante servidor 10 Diagrama de estados A adir restaurante aplicaci n 11 Diagrama de estados A adir restaurante servidor 12 Diagrama de estados Puntuar plato aplicaci n 13 Diagrama de estados Puntuar plato servidor 14 Diagrama de secuencia Buscar restaurantes 15 Diagrama de secuencia A adir restaurante 16 Diagrama de secuencia Puntuar plato 17 Diagrama de clases Paquetes del proyecto 18 Diagrama de clases com aplicacion ui 19 Diagrama de clases com aplicacion conexion
73. que no desea usar GPS Inserta direcci n No hay resultados Notificar que no hay resultados Ha seleccionado que desea usar GPS Hay resultados Figura 2 8 Diagrama de estados Buscar restaurante aplicaci n Para buscar un restaurante deberemos navegar por las distintas pantallas de la aplicaci n rellenando los datos pertinentes En caso de que hayamos seleccionado que no queremos utilizar el gps adem s de el nombre de la comida que deseemos deberemos insertar una direcci n Con estos datos se har una llamada al servidor que nos responder con los datos que se mostrar n por pantalla 10 CAP TULO 2 DOCUMENTACI N 2 2 2 2 Buscar restaurantes Servidor Recibir una petici n de busqueda Obtener datos Buscar restautantes entorno a la posici n en la BBDD Hay resultados Buscar la comida en los restaurantes obtenidos en la BBDD No hay resultados No hay resultados Hay resultados Buscar pagina web en la BBDD No tiene p gina web en la BBDD Tiene p gina web en la BBDD Buscar comida en la p gina web Hay resultados No hay resultados Enviar respuesta Figura 2 9 Diagrama de estados Buscar restaurante servidor Cuando el servidor recibe una petici n de b squeda de restaurantes lo primero que hace es obtener los datos de la petici n Con estos datos consulta la base de datos en busca de restaurantes que est n en torno a la posici n recibida Si hay r
74. rantes public ArrayList lt Restaurante gt restaurantes JR RE KK I EE KI I HRK HE RI I AXA AZ K AK A I KI I RIK I RK I Constructor vacio de la clase restaurantes KKK KK AA I K AK AK Z K AK A A K KAZ Z AZ K AK X K AK AX Z K AKA AX KA Z KARA KARA public Restaurantes this restaurantes new ArrayList lt Restaurante gt KK KKK I EH I De HR RK II RI X AX Ge AX AK KAZ I IK I RK I kk Constructor de la clase Restaurante param ArrayList lt String gt r Lista de restaurantes KKK KA K K AK A Z K AK A A K KA Z K AK ZX K AK AX Z K AKA AX RARA KARA ARRAY public Restaurantes ArrayList lt Restaurante gt r this restaurantes r JR OR Re HR XXX Z K AK HR AK AX AX KARA KAR KK kA AK Z RR kk Obtiene la lista de restaurantes return ArrayList lt String 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 90 AP NDICE B C DIGO FUENTE KKK KK AAA KK AK Z K AK A X K AKA X X K AK AX AX KARA KAZ AX KARA KARA ARRAY public ArrayList lt Restaurante gt getRestaurantes return restaurantes kkkkkkkk kk HE AA I K AK AX AX K AK AX KARA KARA KA AX Z IRI k k Modifica la lista de restaurantes P x return ArrayList lt String gt r Lista de restaurantes XAAKKKKAKKKARKKKARKKK
75. t System out println XnInserte plato 2 direccion teclado next System out printin nInserte PUNTA cion aux teclado next p Float parseFloat aux resultado insertPlato nombre direccion p System out println resultado 07 08 09 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 137 138 139 140 141 B 1 C DIGO JAVA 95 break CASE System out println nSaliendo de loa vaplacacvon Hasta uegor break default System out println nOpcion no vello Ue break opcion menu private static int menu VO DERO System out print nOPERACIONES CON LA BBDDYn Serenm OU APT E S PCO TRA O Consultar mediante coordenadas NNE Insertar un restaurante n t2 Puntuar un Platon ES Ae opcion teclado nextInt return opcion JR RER KK I KR RI I De Z K AKA AXA AX RK I Xe Re Xe Z K k Z kk Funcion para conectarse a la bbdd KKK k KK AA K K AK AK Z K AK AX A K KAZ Z AZ K AK X K AK AX ZX K AKA KAZ KARA KARA private static void conectarBBDD throws ClassNotFoundException SOLException InstantiationException IllegalAccessException SVS CM UE a gi Coneceando el BBD e Class forName unDriver cn DriverManager getConnection URLConn user pass System out println Conectado 1
76. t getParameter Y comida request getParameter contada out println Gestor obtenerRestaurantes x y comida break case 1 nombre request getParameter nombre dir request getParameter dir x Double valueo0f request getParameter X y Double valueo0f request getParameter Y web request getParameter web out println Gestor insertRestaurante nombre dir x r Yr web break case 2 nombre request getParameter nombre comida request getParameter platon puntuacion Float valueOf request getParameter puntuacion out println Gestor insertPlato nombre comida puntuacion break default out println No hay texto para eso 61 62 63 64 65 66 67 110 Ger mr V lt body gt lt html gt AP NDICE B C DIGO FUENTE
77. te Si no hay puntuaciones es 1 Es del tipo float web id uri id restaurante id Se trata del identificador de las direcciones web Es de tipo integer ni co autoincremental y no puede ser nulo a uri Es una cadena de doscientos caracteres como maximo Es el la direc ci n web del restaurante No puede ser nulo id restaurante Es el indice de restaurante al que pertenede la web Es clave foranea as pues no puede ser nulo Es del tipo integer 2 5 DOCUMENTACI N DE LA BASE DE DATOS plato id plato calificaci n id restaurante 23 id Se trata del identificador de los platos Es de tipo integer nico autoin cremental y no puede ser nulo plato Es una cadena de sesenta caracteres como m ximo Es el nombre del plato No puede ser nulo calificacion Es la calificaci n del plato Es del tipo float id_restaurante Es el indice de restaurante al que pertenede el plato Es clave foranea as pues no puede ser nulo Es del tipo integer 2 5 2 Modelo relacional direccion coord X coord Y nombre restaurante 1 puntuacion a plato d restaura nte Figura 2 22 Modelo relacional de la base de datos d restaura nte 26 CAP TULO 2 DOCUMENTACI N Cap tulo 3 Versiones y mejoras 28 CAP TULO 3 VERSIONES Y MEJORAS Tras la presentaci n de este proyecto nos planteamos n
78. to de la aplicacion param AttributeSet Atributos KKK RH HRK AK Z K AK AX A K KA Z K KARA K AK AX Z KA Xe XX XXE public ControlPuntuar Context context AttributeSet attrs SUPeMICOntTex tr ACES CAS KK KKK I HR EE XK AK A AX I AK AK AX AX KARA KARA KAR I AK I RK I Inicializa la interfaz para ser mostrada KKK KK AA K K AK AK Z K AK AX A K KAZ AX ZAZ K AK X K AK AX Z K Xe KARA KARA private Vordi an ee String interfaz Context LAYOUT INFLATER SERVICE LayoutInflater inflater LayoutInflater getContext getSystemService interfaz inflater inflate R layout puntuar this true ERestaurante EditText findViewById R id edit restaurante EPlato EditText findViewByld R id edit_plato grupo RadioGroup findViewById R id grupo acept Button findViewById R id button Puntuar clear Button findViewById R id button Clear addEvents KK KKK I KR RI I EE Z K AK HE RIKI KR ORI I kA RRR I RK I I 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 60 AP NDICE B C DIGO FUENTE Anade los eventos a los botones de la pantalla KR KR KK AAA KK AK Z K AK A X K AK AZ X K AKA X K AK AX AZ KA
79. ts return resTurn KK KKK I HR KARA KARA KARA KA X A KARA KARA I RIK IK I Obtiene restaurantes que tienen una comida deseada tras buscar en la bbdd param Restaurantes restaurantes lista de restaurantes que se quiere comprobar si tienen la comida deseada param String comida comida que se desea buscar param Restaurantes rests lisya der estaurantes que ya se sabe que tienen la comida buscada x return ArrayList lt Restaurantes gt KKK KK AZ K K AK AZ Z K AK AX A K KA Z AZ K AK X K AKA Z KARA KAR kk Y private static ArrayList lt Restaurantes gt restaurantesComidaBBDD Restaurantes restaurantes String comida Restaurantes rests ResultSet resultSetPlat null SENO CST Statement statement ArrayList lt Restaurantes gt resTurn new ArrayList lt Restaurantes boolean esta false 271 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 310 311 100 AP NDICE B C DIGO FUENTE Restaurantes aux new Restaurantes ey statement cn createStatement Iterator lt Restaurante gt ite restaurantes getRestaurantes iterator while ite hasNext ArrayList lt String gt plas new ArrayList lt String gt esta false Restaurante rest new Restaurante
80. uarios por ejemplo poner Corrientes 123 puede llevar a equ vocos y es menos ex cto que poner av Corrien tes 123 incluso si quisieramos ser m s estrictos podr amos poner av Corrientes 123 Buenos Aires haciendo as que no haya duda alguna de la localizaci n del restaurante Nombre del restaurante ayres de patagonia Direcci n av alicia moreau de justo 1798 eb del restaurante A adir Borrar Figura A 7 Mensaje de alta correcta de un restaurante A 4 PUNTUAR UN PLATO 35 Nombre del restaurante rodizio Plato Malo Regular Bueno Muy bueno Puntuar Borrar Figura A 8 Formulario para puntuar un plato A 4 Puntuar un plato La puntuaci n que tiene cada uno de los restaurantes viene dada por la media de la puntuaci n de los platos que tiene registrado as pues este paso es funda mental para que la aplicaci n pueda aportar mayor informaci n en cuanto a la calidad de los restaurantes Para poder puntuar un plato deber pulsar la opci n Puntuar plato del submenu Esto le conducir a un formulario en el cual deber completar el nombre del restaurante del plato y la puntuaci n que des e darle En caso de que el restaurante no exista la aplicaci n dar un mensaje de error invitandole a agregar ese restaurante a la aplicaci n Con estos simples consejos ya est en disposic n de sacar el mayor rendi miento a la aplicaci n Buen provecho 36 AP NDICE A
81. uesta lastIndexof il return respuesta else EE mulnip Override protected String doInBackground ArrayList lt String gt params return getServerDataString params 0 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 82 AP NDICE B C DIGO FUENTE B 1 3 Paquete serviOcios Clase Restaurante java JR RER HR RK II I HR KARA K AKA X K RI I AKA Z K AKA k k Fichero Restaurante java Clase gue caracteriza un restaurante author Eduardo Campos de Diago version 1 2 KKK KK AA I AK Z K AK AK Z K AK AZ Z K RARA K AK AX Z KARA KARA KARA KARA Y package serviOcios import java util Arraylist public class Restaurante Mok ok Mek kok Kok Yok Hoh Mo ub ub ub ub ub ub ub Este Fake Bake lic Lake LRG HO oe kelo S S rang tring double double TOA KPUMEUACHO nombre direcemon Coordi COOL O ub tE Arrayl Arrayl jist lt String gt web SES SERIO platos KKK HR RK I I AK AK A I K AK AX AXA K AK X K AK AZ ZX AK RIK I ke Xe k k Br he ar Or r am ar Constructor param param param param param param de la clase Restaurante mia ak aloe el MAD ac doub doub String n nombre DUN SOCH SCC le x coordenada x le y coordenada y JOER OZP EA SHP EA pubire Restaurante E ETC
82. uevos usos y mejoras para la aplicaci n como A adir capacidades para buscar pel culas de cine A adir capacidades para buscar obras de teatro Optimizar interfaz gr fica Realizar un registro de usuarios Realizar funciones batch en el servidor que comprueben la consistencia de los datos de la base de datos Ap ndice A Manual de usuario 30 AP NDICE A MANUAL DE USUARIO Con esta aplicaci n podr localizar de un modo sencillo restaurantes que dis pongan de la comida que busque tanto a su alrededor como en torno a una di recci n que indique Adem s podr a adir restaurantes y puntuar los platos que ha degustado haciendo que tanto usted como otros usuarios se beneficien de las ventajas que esto supone En este peque o manual vamos a explicar paso a paso como sacar el m ximo rendimiento a esta aplicaci n A 1 Iniciando nuestro uso en serviOcios Cuando inicie la aplicaci n encontrar una pantalla en la cual podr seleccio nar qu tipo de alternativa de ocio desea buscar Actualmente solo est disponible la opci n Restaurantes Restaurantes Cines Teatros Figura A 1 Pantalla inicial Esto le conducir a un submen en el que tendr varias alternativas para reali zar buscar restaurantes a adir un restaurante o puntuar un plato A 2 BUSCANDO RESTAURANTES 31 Buscar A adir un restaurante Puntuar un plato Figura A 2 Submenu A 2 Buscando restaurantes Si
83. urante e AA US q jalea sp MENU y PUNTA ao SS aio mi er AUS resultado statement exX query if resultado 1 float aux 0 does 0 cuteUpdate query SELECT calificacion FROM Plato WHERE id restaurante id restaurante LA BESUE SEE statement executeQuery query 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 B 1 C DIGO JAVA while aux ca aly gt le aux aux i query resultado LIE N AU wher resultSet next 107 ACACIA 8 fam id restaurante resultado resJson else resJson 1 aux resultSet getFloat update restaurante set puntuacion statement executeUpdate query NS ye NOK gt ESP date UE vo catch ClassNotFoundException CNFE System out println CNFE getMessage 1 catch SOLException SOLE System out println SQLE getMessage 2 catch InstantiationException IE System out println IE getMessage 3 catch IllegalAccessException IAE System out println IAE getMessage 4 return resJson 20 21 22 23 24 25 108 AP NDICE B C DIGO FUENTE B 2
84. va priva priva priva priva java util ArrayList java util concurrent ExecutionException com apl icac T on conexion POSE an an an an an an an an an droid widget Button droid widget Toast droid widget LinearLayout droid droudecontenit s widget RadioGroup Context AOA CASE view LayoutInflater drordi droid view View droid widget EditText class ControlPuntuar extends LinearLayout ES TE eo BS Bu COnMaICcepE ES Bu Econ cleans EditText ERestaurante Ecce PATOS RadioGroup gr upo Constructor de la clase ControlPuntuar param Context contesto de la aplicacion 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 B 1 C DIGO JAVA 59 KKK KA HRK A AK Z K AK AX A K KAZ Z A K AK X K RARA K ee ee ee ee ARRAY public ControlPuntuar Context context super context net roulez 0 KK KK HR HR EE HR EE HE I RI ORI I HR RI I RK I kh x Constructor de larclase Cont rolPpunkuar param Context contes

Download Pdf Manuals

image

Related Search

Related Contents

CD Player  VGN-FS635B/W  saving water: there`s an app for that!  Franke 9899459 sink  SHAKE-5  manual do usuário  油圧装置の取付、試運転および保守  UC864-E/G/WD/WDU Software User Guide  STAZIONE SOLARE AD INCASSO INKA SOLAR  User Manual - Parts Express  

Copyright © All rights reserved.
Failed to retrieve file