If I have a quote like the following on my web page:
"I think, therefore I am"
-Rene Descartes
What would be the proper HTML5 tags to represent that quote and its author? And how would they be structured correctly?
If I have a quote like the following on my web page:
"I think, therefore I am"
-Rene Descartes
What would be the proper HTML5 tags to represent that quote and its author? And how would they be structured correctly?
I am developing a contact form on the same page and hiding the form when submitting with PHP but I have problems validating the captcha image when pressing the submit button it shows me the two messages together when submitting:
The characters do not match the captcha code.
Thanks for your comments.
Through this code I get the captcha values of the image.
if($_SESSION['vcode'] != $_POST['vcode']) {}
Due to the problem of validating the captcha I have the doubt of where to include the validation of the form data with PHP.
UPDATE
Contact form.php
<!DOCTYPE html>
<html>
<head>
<title>Formulario de Contacto</title>
</head>
<body>
<?php
// Función para validar contra cualquier intento de inyección de correo electrónico
function IsInjected($str) {
$injections = array('(\n+)',
'(\r+)',
'(\t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)'
);
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str)) {
return true;
}else{
return false;
}
}
?>
<?php
session_start();
$errors = '';
$nombre = '';
$email = '';
$telefono = '';
$mensaje = '';
if(isset($_POST['submit'])) {
if($_SESSION['vcode'] != $_POST['vcode']) {
$errors .= "Los caracteres no coincide con el código captcha";
}
$nombre = $_POST["name"];
$email = $_POST["mail"];
$telefono = $_POST["phone"];
$mensaje = $_POST["message"];
if(empty($nombre)) {
$errors .= "\n Por favor ingresar su nombre. ";
}
if(empty($email)) {
$errors .= "\n Por favor ingresar su email. ";
}elseif (IsInjected($email)) {
$errors .= "\n email no valido. ";
}
if(empty($telefono)) {
$errors .= "\n Por favor ingresar su numero telefono. ";
}
if($_POST['producto'] == 0){
$errors .= "\n Debe seleccionar un producto";
}
if(empty($mensaje)) {
$errors .= "\n Por favor ingresar su mensaje. ";
}
if(empty($errors)) {
$asunto = "";
$message = "Usuario:".$_POST['name']." Email:".$_POST['mail']." Telefono ".$_POST['phone']." Informacion ".$_POST['message'];
$destino = "[email protected]";
$remitente = "From: [email protected]";
mail($destino,$asunto,$message,$remitente);
unset($_POST['submit']);
echo "Gracias por sus comentarios";
}
}else{
?>
<div class="error">
<?php
if(!empty($errors)){
echo "<p class='err'>".nl2br($errors)."</p>";
}
?>
</div>
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post" autocomplete="off" enctype="multipart/form-data">
<div class="touch">
<div class="name">
<input type="text" name="name" placeholder="Nombre" value='<?php echo htmlentities($nombre) ?>'>
</div>
<div class="email">
<input type="text" name="mail" placeholder="Email" value='<?php echo htmlentities($email) ?>'>
</div>
<div class="phone">
<input type="text" name="phone" placeholder="Phone" value='<?php echo htmlentities($telefono) ?>'>
</div>
<div class="select-pro">
<select name="producto">
<option value="0" selected>Asunto...</option>
<option value="1">Producto 1</option>
<option value="2">Producto 2<option>
<option value="3">Producto 3</option>
<option value="4">Otro</option>
</select>
</div>
<div class="Customer-message">
<textarea id="message" name="message" placeholder="Su consulta..."><?php echo htmlentities($mensaje) ?></textarea>
</div>
<div class="capcha">
<img src="image.php" name="vcode" id="phoca-captcha"/>
<input name="vcode" type="text" placeholder="Codigo captcha">
</div>
<input type="submit" name="submit" value="Enviar">
</div>
</form>
<?php } ?>
</body>
</html>
The desired thing is to hide the form when sending and display the following message Thank you for your comments but when sending either blank or the fields filled correctly or incorrectly, the additional form is hidden, the validation of the fields is lost because it does not show no error message.
Another bug is the function to validate against any email injection attempts, entering an invalid email example(false@aasadw) does not show the error message: invalid email.
To prevent the user from losing the information given in the form fields by not typing the characters of the captcha code correctly, I added this action to each field:
value='<?php echo htmlentities($nombre) ?>'
But select -> option
how do I avoid losing the product selection when sending.
My Android project works with Google maps, so it has 190 markers. The problem I am facing is that I would like to determine which of these is closest to my position, the problem is that I have no idea how to do it. This is how I added the markers:
map.addMarker(new MarkerOptions().position(marcador1).title("Ciclovia Callao").snippet("Calle / Bidireccional / Alcántara a Sánchez Fontecilla").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador2).title("Ciclovia Antonio Varas").snippet("Calle y Vereda / Bidireccional / Nueva Providencia a Irarrázaval").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador3).title("Ciclovia Cardenal Raúl Silva Henríquez / Américo Vespucio").snippet("Vereda, Calle y Bandejón / Bidireccional / Canal Torrente a Porvenir").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador4).title("Ciclovia Arzobispo Valdivieso").snippet("Vereda / Bidireccional / Comandante Véliz a Ocho Norte").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador5).title("Ciclovia Almirante Blanco Encalada").snippet("Almirante Blanco Encalada").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador6).title("Ciclovia Central Cardenal Silva Henríquez").snippet("Vereda / Bidireccional / Buenaventura a Américo Vespucio").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador7).title("Ciclovia Alberto Llona").snippet("Vereda / Bidireccional / Vicente Reyes a 5 de Abril").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador8).title("Ciclovia Clotario Blest").snippet("Vereda / Bidireccional / Carlos Valdovinos a Lo Ovalle").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador9).title("Ciclovia 5 de Abril / Parque por Simón Bolívar").snippet("Bandejón / Bidireccional / Vostok a Las Torres").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador10).title("Ciclovia 5 de Abril / Esquina Blanca").snippet("Vereda y bandejón / Bidireccional / Primera Transversal a Concepción del Oro").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador11).title("Ciclovia Carlos Valdovinos").snippet("Vereda / Bidireccional / Santa Rosa a Vicuña Mackenna").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador12).title("Ciclovia Carmen / Las Industrias").snippet("Vereda / Bidireccional / General Jofré a Comercio").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador13).title("Ciclovia Cardenal Raúl Silva Henríquez").snippet("Vereda / Bidireccional / Jorge Quevedo a San Gregorio").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador14).title("Ciclovia Chile España").snippet("Calle / Bidireccional / Simón Bolívar a Miguel de Cervantes").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador15).title("Ciclovia Calle G").snippet("Bandejón / Bidireccional / Juan Cristóbal a Juan Muñoz").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador16).title("Ciclovia IV Centenario ").snippet("Vereda / Bidireccional / Los Milagros a Los Pozos").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador17).title("Ciclovia Centenario (a)").snippet("Bandejón / Bidireccional / Club Hípico a Bascuñán Guerrero").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador18).title("Ciclovia Alameda / Pajaritos").snippet("Bandejón y Calle / Bidireccional / Teatinos a Escr. Jorge Inostroza").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador19).title("Ciclovia Camino a Melipilla / Pedro Aguirre Cerda").snippet("Calle y vereda / Bidireccional / Avenida Cuatro a Esquina Blanca").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador20).title("Ciclovia Brasil").snippet("Calle / Bidireccional / Huérfanos a Mapocho").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
MainActivity:
public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener, OnMapReadyCallback {
GoogleMap map;
String email;
LocationManager locationManager;
private static final int PERMS_REQUEST_CODE = 123;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
//obtener datos para la barra
if (user != null) {
String nombre = user.getDisplayName();
email = user.getEmail();
Uri foto = user.getPhotoUrl();
NavigationView navigationsView = (NavigationView) findViewById(R.id.nav_view);
View hView = navigationsView.getHeaderView(0);
TextView nav_user = (TextView) hView.findViewById(R.id.txtMail);
TextView name = (TextView) hView.findViewById(R.id.txtNombre);
ImageView img_user = (ImageView) hView.findViewById(R.id.profile_image);
name.setText(nombre);
nav_user.setText(email);
Picasso.with(this).load(foto).into(img_user);
} else {
SharedPreferences loginbdd = getSharedPreferences("login", Context.MODE_PRIVATE);
email = loginbdd.getString("nombre", "");
String nombre = loginbdd.getString("mail", "");
NavigationView navigationsView = (NavigationView) findViewById(R.id.nav_view);
View hView = navigationsView.getHeaderView(0);
TextView nav_user = (TextView) hView.findViewById(R.id.txtMail);
TextView name = (TextView) hView.findViewById(R.id.txtNombre);
ImageView img_user = (ImageView) hView.findViewById(R.id.profile_image);
nav_user.setText(email);
name.setText(nombre);
isLocationEnabled();
if(!isLocationEnabled()) {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle("Encienda su GPS")
.setMessage("Su GPS se encuentra desactivado, le gustaria activarlo?")
.setCancelable(false)
.setPositiveButton("Encencer GPS",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
}
});
AlertDialog alert = builder.create();
alert.show();
}
}
}
private boolean hasPermissions() {
int res = 0;
//string array of permissions,
String[] permissions = new String[]{Manifest.permission.ACCESS_FINE_LOCATION};
for (String perms : permissions) {
res = checkCallingOrSelfPermission(perms);
if (!(res == PackageManager.PERMISSION_GRANTED)) {
return false;
}
}
return true;
}
private void requestPerms() {
String[] permissions = new String[]{Manifest.permission.ACCESS_FINE_LOCATION};
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestPermissions(permissions, PERMS_REQUEST_CODE);
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
boolean allowed = true;
switch (requestCode) {
case PERMS_REQUEST_CODE:
for (int res : grantResults) {
// if user granted all permissions.
allowed = allowed && (res == PackageManager.PERMISSION_GRANTED);
onMapReady(map);
}
break;
default:
// if user not granted permissions.
allowed = false;
break;
}
if (allowed) {
onMapReady(map);
} else {
// we will give warning to user that they haven't granted permissions.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (shouldShowRequestPermissionRationale(Manifest.permission.ACCESS_FINE_LOCATION)) {
Toast.makeText(this, "Permisos de Ubicación Denegados.", Toast.LENGTH_SHORT).show();
}
}
}
}
private void goLogin() {
Intent intent = new Intent(this, Login.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
new AlertDialog.Builder(MainActivity.this)
.setIcon(R.drawable.cerrar).setTitle("Cerrar Aplicación").setMessage("Deseas cerrar CicloMapp?")
.setCancelable(true).setPositiveButton("Si", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
System.exit(0);
}
})
.setNegativeButton("No", null).show();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
} else if (id == R.id.endSession) {
new AlertDialog.Builder(MainActivity.this)
.setIcon(R.drawable.cerrar)
.setTitle("Cerrar sessión")
.setMessage("Deseas cerrar sesión?")
.setCancelable(true)
.setPositiveButton("Si", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if (user != null) {
LoginManager.getInstance().logOut();
FirebaseAuth.getInstance().signOut();
goLogin();
} else {
SharedPreferences loginbdd = getSharedPreferences("login", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = loginbdd.edit();
editor.remove("inicio");
editor.commit();
goLogin();
}
}
})
.setNegativeButton("No", null).show();
}
return super.onOptionsItemSelected(item);
}
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.AgregarRuta) {
// Intent i = new Intent(MainActivity.this, agregarRuta.class);
// i.putExtra("correo", email);
// startActivity(i);
} else if (id == R.id.ValorarRuta) {
Intent i = new Intent(MainActivity.this, Valoraraciones.class);
i.putExtra("correo", email);
startActivity(i);
} else if (id == R.id.ReportarRuta) {
Intent i = new Intent(MainActivity.this, Reportar.class);
i.putExtra("correos", email);
startActivity(i);
} else if (id == R.id.Eventos) {
} else if (id == R.id.tiendas) {
Intent i = new Intent(MainActivity.this, Tiendas.class);
startActivity(i);
} else if (id == R.id.Leyes) {
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
@Override
public void onMapReady(final GoogleMap googleMap) {
if (hasPermissions()) {
map = googleMap;
map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
map.getUiSettings().setMapToolbarEnabled(false);
map.getUiSettings().setMyLocationButtonEnabled(true);
map.setMyLocationEnabled(true);
map.getUiSettings().setZoomControlsEnabled(true);
CameraUpdate center = CameraUpdateFactory.newLatLng(new LatLng(-33.447487,-70.673676));
CameraUpdate zoom = CameraUpdateFactory.zoomTo(11);
map.moveCamera(center);
map.animateCamera(zoom);
//carga clase polylines y el metodo de agregar las polyline
Polyline po = new Polyline();
po.AddPolyline(map);
//ejecutar snackbar al hacer click en un marcador
map.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(final Marker marker) {
View v1 = (RelativeLayout)findViewById(R.id.content_main);
Snackbar snackbar= Snackbar.make(v1,"Aqui puedes \n Valorar o Reportar \n la ruta \n seleccionada",12000)
.setActionTextColor(Color.YELLOW)
.setAction("Opciones", new View.OnClickListener() {
@Override
public void onClick(View v) {
new AlertDialog.Builder(MainActivity.this)
.setIcon(R.drawable.cerrar)
.setTitle("Opciones")
.setMessage("Te gustaria valorar o reportar la ruta?")
.setCancelable(true)
.setPositiveButton("Valorar", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent i= new Intent(getApplicationContext(),Valoracion2.class);
i.putExtra("Nruta", marker.getTitle().toString());
startActivity(i);
}
})
.setNeutralButton("Cancelar", null)
.setNegativeButton("Reportar",new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog,int which){
}
}).show();
}
});
View snackbarView = snackbar.getView();
TextView textView = (TextView) snackbarView.findViewById(android.support.design.R.id.snackbar_text);
textView.setMaxLines(5);
snackbar.show();
return false;
}
});
//establecer tamaño del icono y mostrar marcadores
int height = 50;
int width = 50;
BitmapDrawable bitmapdraw = (BitmapDrawable) getResources().getDrawable(R.drawable.mruta);
Bitmap b = bitmapdraw.getBitmap();
Bitmap smallMarker = Bitmap.createScaledBitmap(b, width, height, false);
Marcadores ma=new Marcadores();
ma.MarcadoreBdd(map,smallMarker);
}
else {
requestPerms();
}
}
protected boolean isLocationEnabled(){
String le = Context.LOCATION_SERVICE;
locationManager = (LocationManager) getSystemService(le);
if(!locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)){
return false;
} else {
return true;
}
}
}
class where I have the markers, I will place 20, so that it is not an infinite post
public class Marcadores {
Connection con;
public void MarcadoreBdd(GoogleMap map,Bitmap smallMarker) {
//Marks
LatLng marcador1 = new LatLng(-33.377763, -70.655048);
LatLng marcador2 = new LatLng(-33.411492, -70.630575);
LatLng marcador3 = new LatLng(-33.418552, -70.595004);
LatLng marcador4 = new LatLng(-33.436021, -70.664835);
LatLng marcador5 = new LatLng(-33.440952, -70.613127);
LatLng marcador6 = new LatLng(-33.451081, -70.598126);
LatLng marcador7 = new LatLng(-33.457891, -70.669612);
LatLng marcador8 = new LatLng(-33.462861, -70.664945);
LatLng marcador9 = new LatLng(-33.464718, -70.725187);
LatLng marcador10 = new LatLng(-33.471569, -70.719421);
LatLng marcador11 = new LatLng(-33.474207, -70.6351);
LatLng marcador12 = new LatLng(-33.47576, -70.664878);
LatLng marcador13 = new LatLng(-33.484084, -70.63058);
LatLng marcador14 = new LatLng(-33.493925, -70.676427);
LatLng marcador15 = new LatLng(-33.50299, -70.711023);
LatLng marcador16 = new LatLng(-33.51035, -70.741265);
LatLng marcador17 = new LatLng(-33.515225, -70.693527);
LatLng marcador18 = new LatLng(-33.516518, -70.755622);
LatLng marcador19 = new LatLng(-33.540047, -70.620863);
LatLng marcador20 = new LatLng(-33.558337, -70.615721);
map.addMarker(new MarkerOptions().position(marcador1).title("Ciclovia Callao").snippet("Calle / Bidireccional / Alcántara a Sánchez Fontecilla").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador2).title("Ciclovia Antonio Varas").snippet("Calle y Vereda / Bidireccional / Nueva Providencia a Irarrázaval").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador3).title("Ciclovia Cardenal Raúl Silva Henríquez / Américo Vespucio").snippet("Vereda, Calle y Bandejón / Bidireccional / Canal Torrente a Porvenir").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador4).title("Ciclovia Arzobispo Valdivieso").snippet("Vereda / Bidireccional / Comandante Véliz a Ocho Norte").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador5).title("Ciclovia Almirante Blanco Encalada").snippet("Almirante Blanco Encalada").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador6).title("Ciclovia Central Cardenal Silva Henríquez").snippet("Vereda / Bidireccional / Buenaventura a Américo Vespucio").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador7).title("Ciclovia Alberto Llona").snippet("Vereda / Bidireccional / Vicente Reyes a 5 de Abril").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador8).title("Ciclovia Clotario Blest").snippet("Vereda / Bidireccional / Carlos Valdovinos a Lo Ovalle").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador9).title("Ciclovia 5 de Abril / Parque por Simón Bolívar").snippet("Bandejón / Bidireccional / Vostok a Las Torres").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador10).title("Ciclovia 5 de Abril / Esquina Blanca").snippet("Vereda y bandejón / Bidireccional / Primera Transversal a Concepción del Oro").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador11).title("Ciclovia Carlos Valdovinos").snippet("Vereda / Bidireccional / Santa Rosa a Vicuña Mackenna").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador12).title("Ciclovia Carmen / Las Industrias").snippet("Vereda / Bidireccional / General Jofré a Comercio").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador13).title("Ciclovia Cardenal Raúl Silva Henríquez").snippet("Vereda / Bidireccional / Jorge Quevedo a San Gregorio").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador14).title("Ciclovia Chile España").snippet("Calle / Bidireccional / Simón Bolívar a Miguel de Cervantes").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador15).title("Ciclovia Calle G").snippet("Bandejón / Bidireccional / Juan Cristóbal a Juan Muñoz").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador16).title("Ciclovia IV Centenario ").snippet("Vereda / Bidireccional / Los Milagros a Los Pozos").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador17).title("Ciclovia Centenario (a)").snippet("Bandejón / Bidireccional / Club Hípico a Bascuñán Guerrero").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador18).title("Ciclovia Alameda / Pajaritos").snippet("Bandejón y Calle / Bidireccional / Teatinos a Escr. Jorge Inostroza").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador19).title("Ciclovia Camino a Melipilla / Pedro Aguirre Cerda").snippet("Calle y vereda / Bidireccional / Avenida Cuatro a Esquina Blanca").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
map.addMarker(new MarkerOptions().position(marcador20).title("Ciclovia Brasil").snippet("Calle / Bidireccional / Huérfanos a Mapocho").icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
}
id_usuario
is PK , NN and AI
At the beginning, it did start from 1, but I deleted all the records and via my Java program I saved new ones, but the records did not start from 1, they started from the last number of the records that I had deleted.
Why don't the records start from number 1? They start from the number of the records that you had deleted before.
I want to copy a list in Java, and I found a method called clone
, which does that, and it works fine, but I think I'm not using it correctly, as I get a warning in Eclipse .
What I do is create a list, add an integer to it, and finally use the copy method.
ArrayList<Integer> lista = new ArrayList<Integer>();
list.add(5);
ArrayList<Integer> listaCopiada = (ArrayList<Integer>) lista.clone();
Apparently there was a problem, the method returns a Object
, so I had to cast it, and when I do this, it works for me, but I get a warning.
Type safety: Unchecked cast from Object to ArrayList<Integer>
I can click on the warning and see multiple solutions, but none of them convince me.
Extract to local variable:
This duplicates the line, and then I get another warning of the same type.
ArrayList<Integer> clone = (ArrayList<Integer>) lista.clone();
ArrayList<Integer> clone2 = clone;
ArrayList<Integer> clone1 = clone2;
ArrayList<Integer> clone21 = clone1;
ArrayList<Integer> clone11 = clone21;
Extract to method:
This makes me a private function, which has a line inside with the same warning.
ArrayList<Integer> listaCopiada = extracted(lista);
private static ArrayList<Integer> extracted(ArrayList<Integer> lista) {
return (ArrayList<Integer>) lista.clone();
}
When I try to fix that warning, I'm left with a recursive function, which seems pretty illogical to me since it removes the clone part.
private static ArrayList<Integer> extracted1(ArrayList<Integer> lista) {
return extracted1(lista);
}
Add parentheses around cast:
This adds some meaningless parentheses for me, and the warning follows.
ArrayList<Integer> listaCopiada = ((ArrayList<Integer>) lista.clone());
The suggestion I get is Remove extra parentheses , this is going back to how it was before.
Add SuppressWarnings 'unchecked':
This forces me to use a comment to the code, telling me not to throw the warning. This is the only way that I don't get the warning anymore, but I think it looks ugly.
@SuppressWarnings("unchecked")
Is there a way (if it's possible the official or correct one) to use clone
without warnings like this?