getdoubleValuer () returns 0.0 when the number is negative

0

I have a datasnapshot of a firebase node and its data is all right as I need it, the problem I have when I try to take the messenger.getLng_dir_ini () since it always returns 0.0 and its cosola value from the datasnapshot .getValue (). toString () a negative double looks good

           //Inicializar la lista de mensjaeros conectados
        MensajerosConectados = new ArrayList<>();
        ListenerLocacionConectados = new ChildEventListener() {
            @Override
            public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {

                Mensajeros mensajero = dataSnapshot.getValue(Mensajeros.class);
                MensajerosConectados.add(mensajero);
                //aqui agregamos el marcador de cada mensajero
                if (mensajero!=null) {
                        LatLng poscision_mensajero = new LatLng(mensajero.getLat_dir_ini(),mensajero.getLng_dir_ini());
                        map.addMarker(new MarkerOptions()
                                .position(poscision_mensajero)
                                .title(mensajero.getNombre())
                                .icon(BitmapDescriptorFactory.fromResource(R.mipmap.boton_carro)));
                }

// aqui la consola imprime para lat_dir_ini un valor entero pero lng_dir_ini // aparece como 0.0 y ese es mi error ya que no se porque en el datasnapshot si // se ve el numero pero en el objeto mensajero me trae 0.0
                if (dataSnapshot.getValue()!=null) {
                    Log.i("On Child Aded data "," "+mensajero.getLat_dir_ini()+ mensajero.getLng_dir_ini() );

// here I print the values well in console, where lng_dir_ini has a negative double value.                         Log.i ("On Child Aded data", "" + dataSnapshot.getValue (). ToString ());                         try {                             Log.i ("Messengers Messengers", "there are" + MessengersConnected.size ());                         } catch (Exception e) {                             e.printStackTrace ();                         }                     }

            }

            @Override
            public void onChildChanged(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {

            }

            @Override
            public void onChildRemoved(@NonNull DataSnapshot dataSnapshot) {
                Mensajeros mensajero = dataSnapshot.getValue(Mensajeros.class);

                if (mensajero!=null && MensajerosConectados.size()>0) {
                    for(int i = 0; i< MensajerosConectados.size();i++){
                        if(mensajero.getCodigo().equals(MensajerosConectados.get(i).getCodigo())){

                            Log.i("quitar Mensajeros","remover  "+MensajerosConectados.get(i).getNombre());
                            MensajerosConectados.remove(i);
                        }
                    }
                }

            }

            @Override
            public void onChildMoved(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {

            }

            @Override
            public void onCancelled(@NonNull DatabaseError databaseError) {

            }
        };
        Query_conectados.addChildEventListener(ListenerLocacionConectados);

// clase mensajeros
public class Mensajeros {

    private String nombre;
    private float calificacion;
    private String placa;
    private String codigo;
    private String urlFoto;
    private String telefono;
    private String token;
    private double lat_dir_ini;
    private double lng_dir_ini;






    public  Mensajeros(){

    }

    public Mensajeros(String nombre,String urlFoto,float calificacion,
                      String codigo,String placa, String telefono,double lat_dir_ini,double lng_dir_ini, String token){

        Log.d("Clase Mensajeros","longitud "+lng_dir_ini);

        this.nombre = nombre;
        this.calificacion = calificacion;
        this.urlFoto = urlFoto;
        this.codigo = codigo;
        this.placa = placa;
        this.telefono = telefono;
        this.lat_dir_ini = lat_dir_ini;
        this.lng_dir_ini = lng_dir_ini;
        this.token = token;

    }

    public String getTelefono() {
        return telefono;
    }

    public void setTelefono(String telefono) {
        this.telefono = telefono;
    }

    public String getNombre() {
        return nombre;
    }


    public float getCalificacion() {
        return calificacion;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public void setCalificacion(float calificacion) {
        this.calificacion = calificacion;
    }
    public String getUrlFoto() {
        return urlFoto;
    }

    public void setUrlFoto(String urlFoto) {
        this.urlFoto = urlFoto;
    }



    public String getPlaca() {
        return placa;
    }

    public void setPlaca(String placa) {
        this.placa = placa;
    }

    public String getCodigo() {
        return codigo;
    }

    public void setCodigo(String codigo) {
        this.codigo = codigo;
    }

    public String getToken() {
        return token;
    }

    public double getLat_dir_ini() {
        return lat_dir_ini;
    }

    public double getLng_dir_ini() {

    //*** aqui tengo el problema, en mi nodo esto es un double negativo pero aqui me imprime 0.0
        Log.d("Clase Mensajeros","longitud"+lng_dir_ini);
        return lng_dir_ini;
    }
}
    
asked by Alexandre CR 15.07.2018 в 18:10
source

1 answer

0

I'm ashamed to say it but the problem was an error in the names of the variables, which was in firebase as lgn_dir_ini and in java as getLng_dir_ini () that's why I always returned the value 0.0 I thank everyone for their intention.

    
answered by 16.07.2018 в 04:39