How to add an image stored in firebase storage to the imageView inside an infowindow of a marker?

0

I need to download a firebase image and open 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 it and the image does not appear. How can I make it appear in the imageView?

    
asked by anonymous 11.07.2017 / 06:21

1 answer

0

You can not pass the imageReference directly to Glide as in the

StorageReference imageRef = storageRef.child(marker.getTag().toString()+".jpg");
Glide.with(MapaFocosActivity.this)
                .using(new FirebaseImageLoader())
                .load(imageRef) // <--- Aqui não pode ser assim.
                .into(img);

, you have to pass the direct reference download URL.

I do not use the Loader, I always get straight to the Download URL of the file and load. But one thing I do I leave the read permission enabled if there is no time for it to open the image.

    
27.07.2017 / 16:10