Search in sources :

Example 1 with ImageItem

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();
            }
        }
    });
}
Also used : ViewHolderBase(com.github.obsessive.library.adapter.ViewHolderBase) Intent(android.content.Intent) GridView(android.widget.GridView) ImageView(android.widget.ImageView) InjectView(butterknife.InjectView) View(android.view.View) AdapterView(android.widget.AdapterView) LayoutInflater(android.view.LayoutInflater) AdapterView(android.widget.AdapterView) ImageItem(com.github.obsessive.library.picker.ImageItem) ImageView(android.widget.ImageView) ViewHolderCreator(com.github.obsessive.library.adapter.ViewHolderCreator)

Aggregations

Intent (android.content.Intent)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 GridView (android.widget.GridView)1 ImageView (android.widget.ImageView)1 InjectView (butterknife.InjectView)1 ViewHolderBase (com.github.obsessive.library.adapter.ViewHolderBase)1 ViewHolderCreator (com.github.obsessive.library.adapter.ViewHolderCreator)1 ImageItem (com.github.obsessive.library.picker.ImageItem)1