use of me.nereo.multi_image_selector.adapter.ImageGridAdapter 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());
}
Aggregations