0

i try to retrieve image url store in my realtime database using Glide, but it doesn't work .

this is my Onbind view :

public void onBindViewHolder(@NonNull NewRecipeAdapter.ViewRecipeHolder holder, @SuppressLint("RecyclerView") int position) {
    Recipe recipe = list_of_recipe.get(position);
    holder.newname.setText(recipe.getRecipe_name());
    
    Glide.with(context).load(recipe.getImage()).centerCrop().into(holder.newImage);

    holder.itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            String id = list_of_recipe.get(position).getRecipe_id();

            Intent intent = new Intent(context,RecipePage.class);
            intent.putExtra("recipe_id_home",id);
            context.startActivity(intent);
        }
    });

}

@Override
public int getItemCount() {
    return list_of_recipe.size();
}


public class ViewRecipeHolder extends RecyclerView.ViewHolder {

    ImageView newImage;
    TextView newname,calory,carb,protein,fat,time;
    RelativeLayout new_layout ;

    public ViewRecipeHolder(@NonNull View itemView) {

        super(itemView);

        new_layout = (RelativeLayout) itemView.findViewById(R.id.new_parent);
        newImage = (ImageView) itemView.findViewById(R.id.new_image);
        newname = (TextView) itemView.findViewById(R.id.new_name);
        time=(TextView) itemView.findViewById(R.id.time);

        fat= (TextView)itemView.findViewById(R.id.fat_value);
        calory = (TextView) itemView.findViewById(R.id.calory_value);
        carb = (TextView) itemView.findViewById(R.id.carb_value);
        protein = (TextView) itemView.findViewById(R.id.pro_value);

    }

this is my database :

enter image description here

is there a better way to save image and retrieve it?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • By default the Glide library doesn't know how to load `gs://` URLs. There's an add-on in FirebaseUI that recognizes them: https://firebaseopensource.com/projects/firebase/firebaseui-android/storage/readme/. Alternative, you can write a normal `https://` URL as shown here: https://stackoverflow.com/questions/66407385/android-glide-failed-to-load-resource-of-firebase-storage and https://stackoverflow.com/questions/73290480/how-to-load-an-image-in-imageview-with-the-help-of-glide-from-cloud-storage-with – Frank van Puffelen Sep 06 '22 at 19:15

0 Answers0