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

0

Good morning, everyone. My question is relative only to the display part of the GridView image. Look at the steps that are already working:

  • I can upload to Firebase Storage.
  • Each time an image is sent to the server your uri is saved in the Firebase Database.
  • I have a GridView displaying images saved in the drawable folder.
  • Firebase Storage is correctly configured because I can get an image of it and display it in an ImageView via uri saved in the Database.
  • I still can not understand how I can loop in the Database and through Picasso display in the GridView. Thanks to anyone who can help.

    Following the GridView Code:

    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
    };
    

    }

        
    asked by anonymous 05.01.2018 / 11:45

    1 answer

    0

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

        
    19.01.2018 / 16:10