@Override public View getView(int position, View convertView, ViewGroup viewGroup) { Holder holder = null; View rowView = convertView; FileObj fileObj = filePathList.get(position); if (rowView == null) { Bitmap bitmap = BitmapFactory.decodeFile(fileObj.getFilePath()); holder = new Holder(); rowView = mInflater.inflate(R.layout.image_file_item, viewGroup, false); holder.picture = (ImageView) rowView.findViewById(R.id.picture); holder.text = (TextView) rowView.findViewById(R.id.text); holder.picture.setScaleType(ImageView.ScaleType.CENTER_CROP); holder.picture.setImageBitmap(bitmap); holder.picture.setScaleType(ImageView.ScaleType.CENTER_CROP); holder.text.setText(fileObj.getCreateTime()); rowView.setTag(holder); } else { Bitmap bitmap = BitmapFactory.decodeFile(fileObj.getFilePath()); holder = (Holder) rowView.getTag(); holder.picture.setImageBitmap(bitmap); holder.picture.setScaleType(ImageView.ScaleType.CENTER_CROP); holder.text.setText(fileObj.getCreateTime()); } return rowView; }
public View createView(Cursor ds, int position, View convertView, final ViewGroup parent) { super.createView(ds, position, convertView, parent); try { ds.moveToPosition(position); } catch (Exception e) { return mLayoutInflater.inflate(R.layout.empty, parent, false); } Holder tag = null; Data data = null; if (convertView != null) { tag = (Holder) convertView.getTag(mTagViewId); data = (Data) convertView.getTag(mTagDataId); } else { convertView = mLayoutInflater.inflate(DATAVIEW_RESID, parent, false); tag = new Holder(); tag.name = (TextView) convertView.findViewById(R.id.name); tag.picture = (ImageView) convertView.findViewById(R.id.profilepic); convertView.setTag(mTagViewId, tag); } tag.setPosition(position); if (data == null) { data = new Data(); } // parse one row of data try { user.parseCursor(ds, mDisplayColumns); } catch (StaleDataException e) { return convertView; } catch (IllegalStateException e) { return convertView; } data.actorname = user.name; data.uid = user.uid; data.profileImageUri = user.pic_square; convertView.setTag(mTagDataId, data); // fill in data if (user != null) { // Logger.l(Logger.DEBUG, LOG_TAG, "num users : "+ds.getCount()); String state = null; String zip = null; String country = null; String city = null; JSONObject htl; tag.name.setText(user.name); String imageUrl = user.pic_square; Bitmap profileImageBitmap = App.mImageUrlLoader2.loadImage(imageUrl, true); if (profileImageBitmap == null) { // TODO Object pool AsyncLoaderInput profileImageBitmap = mDefaultProfileImage; AsyncLoaderInput input = new AsyncLoaderInput(); input.imageUri = imageUrl; input.imageView = tag.picture; input.groupCode = position; input.code = position; App.mImageUrlLoader2.loadImageAsync( App.INSTANCE.mExecScopeImageLoaderTask, input, mAsyncLoaderListener); } tag.picture.setImageBitmap(profileImageBitmap); } return convertView; }