Search in sources :

Example 1 with Image

use of me.nereo.multi_image_selector.bean.Image in project MultiImageSelector by lovetuzitong.

the class MultiImageSelectorFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final int mode = selectMode();
    if (mode == MODE_MULTI) {
        ArrayList<String> tmp = getArguments().getStringArrayList(EXTRA_DEFAULT_SELECTED_LIST);
        if (tmp != null && tmp.size() > 0) {
            resultList = tmp;
        }
    }
    mImageAdapter = new ImageGridAdapter(getActivity(), showCamera(), 3);
    mImageAdapter.showSelectIndicator(mode == MODE_MULTI);
    mPopupAnchorView = view.findViewById(R.id.footer);
    mCategoryText = (TextView) view.findViewById(R.id.category_btn);
    mCategoryText.setText(R.string.mis_folder_all);
    mCategoryText.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (mFolderPopupWindow == null) {
                createPopupFolderList();
            }
            if (mFolderPopupWindow.isShowing()) {
                mFolderPopupWindow.dismiss();
            } else {
                mFolderPopupWindow.show();
                int index = mFolderAdapter.getSelectIndex();
                index = index == 0 ? index : index - 1;
                mFolderPopupWindow.getListView().setSelection(index);
            }
        }
    });
    mGridView = (GridView) view.findViewById(R.id.grid);
    mGridView.setAdapter(mImageAdapter);
    mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (mImageAdapter.isShowCamera()) {
                if (i == 0) {
                    showCameraAction();
                } else {
                    Image image = (Image) adapterView.getAdapter().getItem(i);
                    selectImageFromGrid(image, mode);
                }
            } else {
                Image image = (Image) adapterView.getAdapter().getItem(i);
                selectImageFromGrid(image, mode);
            }
        }
    });
    mGridView.setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            if (scrollState == SCROLL_STATE_FLING) {
                Picasso.with(view.getContext()).pauseTag(TAG);
            } else {
                Picasso.with(view.getContext()).resumeTag(TAG);
            }
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
        }
    });
    mFolderAdapter = new FolderAdapter(getActivity());
}
Also used : ImageGridAdapter(me.nereo.multi_image_selector.adapter.ImageGridAdapter) AbsListView(android.widget.AbsListView) Image(me.nereo.multi_image_selector.bean.Image) GridView(android.widget.GridView) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) Point(android.graphics.Point) FolderAdapter(me.nereo.multi_image_selector.adapter.FolderAdapter) AdapterView(android.widget.AdapterView)

Aggregations

Point (android.graphics.Point)1 View (android.view.View)1 AbsListView (android.widget.AbsListView)1 AdapterView (android.widget.AdapterView)1 GridView (android.widget.GridView)1 TextView (android.widget.TextView)1 FolderAdapter (me.nereo.multi_image_selector.adapter.FolderAdapter)1 ImageGridAdapter (me.nereo.multi_image_selector.adapter.ImageGridAdapter)1 Image (me.nereo.multi_image_selector.bean.Image)1