0
I need to download a firebase image and display it in a custom infowindow on a map.
public class MapaFocosActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener, GoogleMap.OnInfoWindowClickListener, OnMapReadyCallback , GoogleMap.InfoWindowAdapter{
private GoogleMap mMap;
private FirebaseStorage storage;
private StorageReference storageRef;
private ImageView img;
private View v;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
.
.
.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.fragment_mapa);
mapFragment.getMapAsync(this);
storage = FirebaseStorage.getInstance();
storageRef = storage.getReferenceFromUrl("gs://...com");
}
.
.
.
@Override
public void onInfoWindowClick(Marker marker) {
}
@Override
public View getInfoWindow(Marker marker) {
return null;
}
@Override
public View getInfoContents(Marker marker) {
StorageReference imageRef = storageRef.child(marker.getTag().toString()+".jpg");
v = getLayoutInflater().inflate(R.layout.marker_window_info, null);
img = (ImageView) v.findViewById(R.id.img_foco_info);
Glide.with(MapaFocosActivity.this)
.using(new FirebaseImageLoader())
.load(imageRef)
.into(img);
File localFile = null;
Bitmap bitmap=null;
try {
localFile = File.createTempFile("images", "jpg");
final File finalLocalFile = localFile;
imageRef.getFile(localFile).addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() {
@Override
public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
// Local temp file has been created
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle any errors
}
});
bitmap= BitmapFactory.decodeFile(finalLocalFile.getAbsolutePath());
} catch (IOException e) {
e.printStackTrace();
Log.e("FOTO", "o Arquivo nao foi criado!");
}
img.setImageBitmap(bitmap);
TextView txt_desc = (TextView) v.findViewById(R.id.txt_desc_foco_info);
txt_desc.setText(marker.getTag()+"\n"+marker.getPosition());
return v;
}
}
I tested and the image does not appear. How can I make it appear in the imageView?