@Override
protected Bitmap doInBackground(String... imageurl)
{
try {
URL url = new URL(imageurl[0]);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.connect();
InputStream in = urlConnection.getInputStream();
bitmap = BitmapFactory.decodeStream(in);
return bitmap;
}catch (Exception e)
{
e.printStackTrace();
return null;
}
}
@Override
protected void onPostExecute(Bitmap result) {
super.onPostExecute(result);
if(result!=null && imageReference!=null) {
ImageView imgview = (ImageView) imageReference.get();
if (imgview != null) {
imgview.setImageBitmap(bitmap);
}
}
}
}
@Override
public void onBindViewHolder(MyViewHolder holder, int position) {
ItemData current=data.get(position);
try {
Mytask mytask=new Mytask(holder.getImageview());
mytask.execute(current.imageUrl);
} catch (Exception e) {
e.printStackTrace();
}
}
public void setClickListener(ClickListener clickListener)
{
this.clickListener=clickListener;
Bundle extras=new Bundle();
extras.putParcelable("image",bitmap);
}
@Override
public int getItemCount() {
return data.size();
}
public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
ImageView icon;
public MyViewHolder(View itemView) {
super(itemView);
itemView.setOnClickListener(this);
icon=(ImageView)itemView.findViewById(R.id.item_icon);
}
public ImageView getImageview()
{
return icon;
}
public void onClick(View view)
{
if(clickListener!=null)
{
clickListener.itemClicked(view,getAdapterPosition());
}
}
}
public interface ClickListener{
public void itemClicked(View view,int position);
}
The above is the MyAdapter method. I want to pass the value of the bitmap to another activity in order to display the onItemClicked image from the RecyclerView list into another activity. My another question is that do I need to pass the intent stuff in my MainActivity's class method in
@override
Public void itemClickedmethod(View view,int position) {
Bundle extras=new bundle();
and so. .the intent stuff. or somewhere else. Please help.