I'm using Firebase as a database and a preview to get information about the saved data, now I can bring both the image and the name of that image in my view, but now I would like to be able to click on the quick view and open a new fragment or activity where the same image or publication can be displayed that is clicked, that is, the photo, the name and the power to include other data within that new fragment or activity when clicking on the recyclerview post.
In a few words for example: a clothing store, you have a recycling view with your products and your name, click on that product opens but with all the other details and specifications you have.
I am currently using: Firebase navigation button with fragments
Fragment where the recyclerview is shown:
mRecyclerView = v.findViewById(R.id.recycler_view);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
mUploads = new ArrayList<>();
mDatabaseRef = FirebaseDatabase.getInstance().getReference("Posts");
mDatabaseRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) {
Uploads uploads = postSnapshot.getValue(Uploads.class);
mUploads.add(uploads);
}
mAdapter = new ImageAdapter(getActivity(), mUploads);
mRecyclerView.setAdapter(mAdapter);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});return v;
//adapter code
public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ImageViewHolder> {
private Context mContext;
private List<Uploads> mUploads;
public ImageAdapter(Context context, List<Uploads> uploads) {
mContext = context;
mUploads = uploads;
}
@Override
public ImageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(mContext).inflate(R.layout.home_item, parent, false);
return new ImageViewHolder(v);
}
@Override
public void onBindViewHolder(ImageViewHolder holder, final int position) {
Uploads uploadCurrent = mUploads.get(position);
holder.textViewName.setText(uploadCurrent.getName());
Picasso.get()
.load(uploadCurrent.getImageUrl())
.placeholder(R.mipmap.ic_launcher)
.into(holder.imageView);
}
@Override
public int getItemCount() {
return mUploads.size();
}
public class ImageViewHolder extends RecyclerView.ViewHolder {
public TextView textViewName;
public ImageView imageView;
public ImageViewHolder(View itemView) {
super(itemView);
textViewName = itemView.findViewById(R.id.Descripcion);
imageView = itemView.findViewById(R.id.ImagePro);
}
}
}