Put Firebase link on every Android app button

-1

I need the image button to take the Firebase link to download the application image. I'll introduce my App to be clearer.

I have this app:

IwasabletousethetextandimageoftheFirebaseDatabaseandFirebaseStore.Theyareappearingcorrectly.

IwanteachimagetohaveitsowndownloadlinkthroughanArrayusingtheFirebaseDatabase.Ineedtoputthislinkoneverybuttoninthearray.Theneachimagewillhaveitsowndownloadbuttonlink.

Forme,itiseitherinTextVieworButton.Hereisthecodebelow:

  

MainActivityclass

publicclassMainActivityextendsAppCompatActivity{privateStorageReferencemStorageReference;privateRecyclerViewmImageList;privateDatabaseReferencemDatabase;DownloadManagerdm;longqueueid;@OverrideprotectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);mDatabase=FirebaseDatabase.getInstance().getReference().child("Image");

        mImageList = (RecyclerView) findViewById(R.id.image_list);
        mImageList.setHasFixedSize(true);
        mImageList.setLayoutManager(new LinearLayoutManager(this));
    }

@Override
protected  void onStart(){
    super.onStart();

    FirebaseRecyclerAdapter<Image, ImageViewHolder> firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<Image, ImageViewHolder>(
            Image.class,
            R.layout.image_row,
            ImageViewHolder.class,
            mDatabase
    ){
        @Override
        protected void populateViewHolder (ImageViewHolder viewHolder, Image model,int position)
        {
            viewHolder.setTitle(model.getTitle());
            viewHolder.setImage(getApplicationContext(),model.getImage());
        }
    };
    mImageList.setAdapter(firebaseRecyclerAdapter);
}

    public static class ImageViewHolder extends RecyclerView.ViewHolder{
        View mView;


        //constructor
        public ImageViewHolder(View itemView) {
            super(itemView);

            mView = itemView;
        }

        public void setTitle(String title){
            TextView post_title = (TextView) mView.findViewById(R.id.post_title);
            post_title.setText(title);
        }

        public void setImage(Context ctx, String image){
            ImageView post_image = (ImageView) mView.findViewById(R.id.post_image);
           /* Glide.with(ctx)
                    .load(image)
                    .into(post_image);*/
            Picasso.with(ctx).load(image).into(post_image);
        }

    }

}
  

Class Image

public class Image {

    private String title;
    private String download;
    private String image;
    DownloadManager dm;

    public Image(){

    }

    public Image(String title, String download, String image){
        this.title = title;
        this.download = download;
        this.image = image;
    }

    public String getTitle() {
        return title;
    }

    public String getDownload() {
        return download;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image){
        this.image = image;
    }
}
    
asked by anonymous 19.10.2017 / 20:03

1 answer

1

Place in:

  @Override
        protected void populateViewHolder (ImageViewHolder viewHolder, Image model,int position)
        {
            viewHolder.setTitle(model.getTitle());
            viewHolder.setImage(getApplicationContext(),model.getImage());
            viewHolder.setDownload(getAplicationContext(), model.getDownload());

        }
    
19.10.2017 / 21:47