packageorg.marcinzelent.liberavem;importandroid.content.Context;importandroid.support.v7.widget.RecyclerView;importandroid.view.LayoutInflater;importandroid.view.View;importandroid.view.ViewGroup;importandroid.widget.BaseAdapter;importandroid.widget.ImageView;importandroid.widget.TextView;importcom.squareup.picasso.Picasso;publicclassAtlasGridAdapterextendsBaseAdapter{privateContextmContext;privateBird[]birds;publicAtlasGridAdapter(Contextc,Bird[]b){mContext=c;birds=b;}publicintgetCount(){returnbirds.length;}publicObjectgetItem(intposition){returnnull;}publiclonggetItemId(intposition){return0;}// create a new ImageView for each item referenced by the AdapterpublicViewgetView(intposition,ViewconvertView,ViewGroupparent){ViewHolderviewHolder;finalViewresult;if(convertView==null){viewHolder=newViewHolder();LayoutInflaterinflater=LayoutInflater.from(mContext);convertView=inflater.inflate(R.layout.atlas_grid_item,parent,false);viewHolder.photo=convertView.findViewById(R.id.atlas_photo);viewHolder.name=convertView.findViewById(R.id.atlas_name);result=convertView;convertView.setTag(viewHolder);}else{viewHolder=(ViewHolder)convertView.getTag();result=convertView;}Picasso.get().load(birds[position].getPhotoUrl()).into(viewHolder.photo);viewHolder.name.setText(birds[position].getNameEnglish());returnconvertView;}privatestaticclassViewHolder{ImageViewphoto;TextViewname;}}