Android Open Source - UniversalImagePick Pick Grid Adapter






From Project

Back to project page UniversalImagePick.

License

The source code is released under:

Apache License

If you think the Android project UniversalImagePick listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.luffyjet.universalimagepick.adapter;
/* w ww. j av a  2s. c om*/
import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;

import com.luffyjet.universalimagepick.App.ImgLoaderOpts;
import com.luffyjet.universalimagepick.R;
import com.luffyjet.universalimagepick.model.Image;
import com.nostra13.universalimageloader.core.ImageLoader;

public class PickGridAdapter extends BaseAdapter
{
  private ArrayList<Image> mList = new ArrayList<Image>();
  private Context mContext;
  
  public PickGridAdapter(ArrayList<Image> mList, Context mContext)
  {
    super();
    this.mList = mList;
    this.mContext = mContext;
  }

  @Override
  public int getCount()
  {
    return mList.size();
  }

  @Override
  public Image getItem(int position)
  {
    return mList.get(position);
  }

  @Override
  public long getItemId(int position)
  {
    return position;
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent)
  {
    ViewHolder vHolder = null;
    Image image = getItem(position);
    if (null==convertView)
    {
      vHolder = new ViewHolder();
      convertView = LayoutInflater.from(mContext).inflate(R.layout.image_pick_item, null);
      vHolder.imageView = (ImageView) convertView.findViewById(R.id.image);
      vHolder.checkBox = (CheckBox) convertView.findViewById(R.id.checkbox);
      convertView.setTag(vHolder);
    }else {
      vHolder = (ViewHolder) convertView.getTag();
    }
    
    ImageLoader.getInstance().displayImage("file://"+image.path,vHolder.imageView,ImgLoaderOpts.forImgSelect);
    return convertView;
  }
  
  static class ViewHolder{
    public ImageView imageView;
    public CheckBox checkBox;
  }
}




Java Source Code List

com.luffyjet.universalimagepick.App.java
com.luffyjet.universalimagepick.Constants.java
com.luffyjet.universalimagepick.MainActivity.java
com.luffyjet.universalimagepick.Test.java
com.luffyjet.universalimagepick.adapter.BucketAdapter.java
com.luffyjet.universalimagepick.adapter.GalleryAdapter.java
com.luffyjet.universalimagepick.adapter.PickGridAdapter.java
com.luffyjet.universalimagepick.adapter.PreviewAdapter.java
com.luffyjet.universalimagepick.adapter.ResultAdapter.java
com.luffyjet.universalimagepick.model.ImageBucket.java
com.luffyjet.universalimagepick.model.Image.java
com.luffyjet.universalimagepick.model.ImagesHelper.java
com.luffyjet.universalimagepick.model.Thumbnail.java
com.luffyjet.universalimagepick.ui.BaseActivity.java
com.luffyjet.universalimagepick.ui.GalleryActivity.java
com.luffyjet.universalimagepick.ui.PickActivity.java
com.luffyjet.universalimagepick.utils.LogUtil.java
com.luffyjet.universalimagepick.widget.CropImageView.java
com.luffyjet.universalimagepick.widget.CustomGridView.java
com.luffyjet.universalimagepick.widget.MulitPointTouchListener.java
com.luffyjet.universalimagepick.widget.ViewfinderView.java