2

We have used Glide to fetch a single image from a folder in firebase storage, and tried populating a RecyclerView. Used the firebaseImageLoader class. But are unable to fetch multiple images directly from a folder . Here is the adapter.

public class GalleryAdapter extends 
RecyclerView.Adapter<GalleryAdapter.MyViewHolder> {
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef;
private Context mContext;

public class MyViewHolder extends RecyclerView.ViewHolder {
    public ImageView thumbnail;

    public MyViewHolder(View view) {
        super(view);
        thumbnail = (ImageView) view.findViewById(R.id.thumbnail);
    }
}


public GalleryAdapter(Context context, StorageReference Ref) {
    mContext = context;
    this.storageRef = Ref;
}

@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View itemView = LayoutInflater.from(parent.getContext())
            .inflate(R.layout.gallery_thumbnail, parent, false);

    return new MyViewHolder(itemView);
}

@Override
public void onBindViewHolder(MyViewHolder holder, int position) {
   // Image image = storageRef.get(position);

    Glide.with(mContext).using(new FirebaseImageLoader())
            .load(storageRef)
            .thumbnail(0.5f)
            .crossFade()
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .into(holder.thumbnail);
}

@Override
public int getItemCount() {
    return storage.hashCode() ;
}

And this is how in the MainActivity we are passing the bucket address of our console.

String uri="gs://gallery-sync.appspot.com/images/p2.jpg";
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReferenceFromUrl(uri);

We are beginners and, cannot seem to find a "Easy to understand" way of integrating the firebase DATABASE into our simple app. IF THERE IS A WAY BY WHICH, WE CAN OBTAIN A JASON STRUCTURE OF OUR DATA STORED IN THE firebase 'STORAGE'. We might just be able to work around it. Thank You.

  • There is no API in Firebase Storage that allows you to retrieve a list of the files. If you need such a list, you will need to store it elsewhere (e.g. in the Firebase Database) when you upload the files. See http://stackoverflow.com/questions/37335102/how-to-get-an-array-with-all-pictures – Frank van Puffelen Nov 13 '16 at 15:50
  • https://www.geeksforgeeks.org/how-to-view-all-the-uploaded-images-in-firebase-storage/ This is answer – Meet Bhavsar Jan 12 '22 at 06:11

0 Answers0