use of com.github.obsessive.library.picker.ImageItem in project SimplifyReader by chentao0707.
the class CommonImagePickerDetailActivity method initViewsAndEvents.
@Override
protected void initViewsAndEvents() {
mGridViewAdapter = new ListViewDataAdapter<>(new ViewHolderCreator<ImageItem>() {
@Override
public ViewHolderBase<ImageItem> createViewHolder(int position) {
return new ViewHolderBase<ImageItem>() {
ImageView mItemImage;
@Override
public View createView(LayoutInflater layoutInflater) {
View convertView = layoutInflater.inflate(R.layout.grid_item_common_image_picker, null);
mItemImage = ButterKnife.findById(convertView, R.id.grid_item_common_image_picker_image);
return convertView;
}
@Override
public void showData(int position, ImageItem itemData) {
if (null != itemData) {
String imagePath = itemData.getImagePath();
if (!CommonUtils.isEmpty(imagePath)) {
ImageLoader.getInstance().displayImage("file://" + imagePath, mItemImage, ImageLoaderHelper.getInstance(mContext).getDisplayOptions());
}
}
}
};
}
});
mGridViewAdapter.getDataList().addAll(mGridListData);
commonImagePickerDetailGridView.setAdapter(mGridViewAdapter);
commonImagePickerDetailGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (null != mGridViewAdapter && null != mGridViewAdapter.getDataList() && !mGridViewAdapter.getDataList().isEmpty() && position < mGridViewAdapter.getDataList().size()) {
Intent intent = new Intent();
intent.putExtra(KEY_BUNDLE_RESULT_IMAGE_PATH, mGridViewAdapter.getDataList().get(position).getImagePath());
setResult(RESULT_OK, intent);
finish();
}
}
});
}
Aggregations