Back to project page photos.
The source code is released under:
MIT License
If you think the Android project photos listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.ericfarraro.photos.adapters; /* w ww. j av a 2 s. com*/ import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; import com.ericfarraro.photos.R; import com.ericfarraro.photos.singletons.PhotoCache; import com.ericfarraro.photos.core.ImageDownloader; import com.ericfarraro.sdk.models.Photo; import java.util.List; /** * Created by Eric on 10/7/2014. */ public class PhotoGalleryItemListAdapter extends ArrayAdapter<Photo> { protected ImageDownloader mImageDownloadHandler; public PhotoGalleryItemListAdapter( Context context, List<Photo> objects, ImageDownloader downloader) { super(context, 0, objects); mImageDownloadHandler = downloader; } @Override public View getView(int position, View convertView, ViewGroup parent) { if(convertView == null) { LayoutInflater inflater = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.grid_item_photo, parent, false); } ImageView image = (ImageView)convertView.findViewById(R.id.grid_item_photo_root); Photo photo = getItem(position); // set a default placeholder image.setImageResource(R.drawable.image_placeholder); // store a reference to the image's URL so that we can retrieve it later image.setTag(photo.getUrl()); if(PhotoCache.getInstance().get(photo.getUrl()) != null) { image.setImageBitmap(PhotoCache.getInstance().get(photo.getUrl())); } else { mImageDownloadHandler.queueImageUrl(image, photo.getUrl()); } return convertView; } }