// create a new ImageView for each item referenced by the Adapter public View getView(int position, View convertView, ViewGroup parent) { ImageView imageView; if (convertView == null) { // if it's not recycled, initialize some attributes imageView = new ImageView(mActivity); imageView.setLayoutParams(new Gallery.LayoutParams(300, 300)); imageView.setScaleType(ImageView.ScaleType.FIT_XY); } else { imageView = (ImageView) convertView; } try { // imageView.setImageURI(mUris.get(position)); imageView.setImageBitmap( Utils.decodeFile(10, new File(Utils.getPath(mActivity, mUris.get(position))))); imageView.setTag(mUris.get(position).toString()); } catch (IOException e) { Log.e(TAG, "Error in getView()", e); } return imageView; }
public void addToAdapter(Uri uri) { mUris.add(uri); this.notifyDataSetChanged(); }
public void addAll(Collection<Uri> uris) { if (uris != null) { mUris.addAll(uris); } }
public int getCount() { return mUris == null ? 0 : mUris.size(); }