After a lot of searching I decided to ask them why I can not find the answer to my problem. I am making an application to show the information of the products that a business has using Firebase. In "Database" I have all the product information (name, description, etc.) and in "Storage" I have stored an image related to each product.
Through an Adapter achievement, download the information of "Database" and arrange it in a GridView. I have the problem when I want to associate the image with the product information through the Firebase URL. As I was watching (and I tried it manually) to do this I must get the URL of the style "https: // ....." and what I get is a URL of the style "com.google.android.gms.tasks. zzn @ 42041500 "that is not serving me to bring the image from Firebase.
I do not know if it's important, but I've uploaded the images directly to the "Storage" and not through the app.
I leave the codes to see if anyone can help me.
Thank you very much !!!!!
AccessoriesActivity
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.productos_grid_view);
// FirebaseDatabase
FirebaseDatabase accesoriosDatabase = FirebaseDatabase.getInstance();
DatabaseReference accesoriosDatabaseRef = accesoriosDatabase.getReference().child("accesorios");
// FirebaseStorage
final FirebaseStorage storage = FirebaseStorage.getInstance();
final StorageReference storageRef = storage.getReference();
// Initialize message ListView and its adapter
ArrayList<AccesoriosObject> accesorios = new ArrayList<>();
final AccesoriosAdapter adapter = new AccesoriosAdapter(this, accesorios);
GridView gridView = findViewById(R.id.grid_view);
gridView.setAdapter(adapter);
// tomar info desde firebase
ChildEventListener childEventListener = new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
// This is the method that gets called whenever a new message is inserted into the messages list.
final AccesoriosObject accesorios = dataSnapshot.getValue(AccesoriosObject.class);
final String key = dataSnapshot.getKey();
Task<Uri> downloadUrl = storageRef.child("accesorios_imagenes/" + key + ".jpg").getDownloadUrl();
Log.v("downloadUrl", String.valueOf(downloadUrl));
accesorios.setImagenProducto(String.valueOf(downloadUrl));
adapter.add(accesorios);
}
AccessoriesAdapter
(...) // Find the ImageView in the child_list_view.xml
ImageView imagenImageView = listItemView.findViewById(R.id.gridView_imagen_producto);
// Get the version name from the current Word object and set this text on the Nombre del Producto
assert currentAccesorio != null;
Glide.with(imagenImageView.getContext()).load(currentAccesorio.getImagenProducto()).into(imagenImageView); (...)
AccessoriesObject
(...) public AccesoriosObject(String nombreProducto, String descripcionProducto,
String precioProducto, String unidadProducto,String imagenProductoUrl,
String tipoProducto) (...)
// Tomar la Url de la imagen del Producto.
public String getImagenProducto() {
return mImagenProductoUrl;
}
// Set url de la imagen del producto
public void setImagenProducto(String imagenProductoUrl){
this.mImagenProductoUrl = imagenProductoUrl;
}