How to show in gridview the data from firebase Storage using Picasso?

Asked

Viewed 189 times

0

Good morning to all. My doubt relates only to the display part of the Gridview image. See the steps that are already working:

  1. I can upload to Firebase Storage.
  2. Each time an image is sent to your server your Uri is saved in the Firebase Database.
  3. I have a Gridview displaying saved images in the drawable folder.
  4. The Firebase Storage is correctly configured because I can take an image of it and display in a Imagemview Saved in the Database.

I still can not understand how I can make the loop in Database and through Picasso display in Gridview. Thanks to those who can help.

Follow the Code of Gridview:

public class ImageAdapter extends BaseAdapter {

FirebaseStorage storage = FirebaseStorage.getInstance();    

private Context mContext;

public ImageAdapter(Context c) {
    mContext = c;
}

public int getCount() {
    return mThumbIds.length;
}

public Object getItem(int position) {
    return null;
}

public long getItemId(int position) {
    return 0;
}

// create a new ImageView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
    ImageView imageView;
    if (convertView == null) {
        // if it's not recycled, initialize some attributes
        imageView = new ImageView(mContext);
        imageView.setLayoutParams(new GridView.LayoutParams(200, 200));
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        imageView.setPadding(8, 8, 8, 8);
    } else {
        imageView = (ImageView) convertView;
    }

    imageView.setImageResource(mThumbIds[position]);




    return imageView;
}

// references to our images
public Integer[] mThumbIds = {

        R.drawable.sample_2, R.drawable.sample_3,
        R.drawable.sample_4, R.drawable.sample_5,
        R.drawable.sample_6, R.drawable.sample_7,
        R.drawable.sample_0, R.drawable.sample_1,
        R.drawable.sample_2, R.drawable.sample_3,
        R.drawable.sample_4, R.drawable.sample_5,
        R.drawable.sample_6, R.drawable.sample_7,
        R.drawable.sample_0, R.drawable.sample_1,
        R.drawable.sample_2, R.drawable.sample_3,
        R.drawable.sample_4, R.drawable.sample_5,
        R.drawable.sample_6, R.drawable.sample_7
};

}

1 answer

0

The class that is using the ImageAdapter should pass the references of the images you uploaded from Firebase, replacing the array mThumbIds.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.