0
How do I go through these ids I generated through the push and that I can get the value of this id I will need to use for the time q the user click on a list I pass this id parameter to another screen so I can load this piece of information there
final FirebaseDatabase database = FirebaseDatabase.getInstance();
final DatabaseReference ref = database.getReferenceFromUrl("https://appassistencia-8e7b9.firebaseio.com/empresa");
ref.addChildEventListener(new Childeventlistener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
final String areaAtuacao = (String) dataSnapshot.child("areaAtuacao").getValue();
final String empresaCidade = (String) dataSnapshot.child("empresaCidade").getValue();
final String empresaEstado = (String) dataSnapshot.child("empresaEstado").getValue();
final String empresaImagem = (String) dataSnapshot.child("empresaImagem").getValue();
final String empresaNome = (String) dataSnapshot.child("empresaNome").getValue();
I’m managing to catch id aq with String s, but the first time it comes null and with an id less at the end.
System.out.println(s);
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReferenceFromUrl("gs://appassistencia-8e7b9.appspot.com/imagens").child(empresaImagem);
try {
final File localFile = File.createTempFile("images", "png");
storageRef.getFile(localFile).addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() {
@Override
public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
Log.e("Test", "success!");
bitmap = BitmapFactory.decodeFile(localFile.getAbsolutePath());
items.add(new Empresa(empresaNome, areaAtuacao, empresaCidade, empresaEstado, bitmap));
}
});
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(s);
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}});
recycler.setAdapter(new EmpresaAdapter(items, new EmpresaAdapter.OnItemClickListener() {
public void onItemClick(Empresa item) {
startActivity(new Intent(EmpresaActivity.this, Activity_Tab_Empresa.class));
}
}));
}}