use of io.github.wangeason.multiphotopicker.event.OnZoomListener in project MultiPhotoPicker by wangeason.
the class PhotoPickerFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.fragment_photo_picker, container, false);
photoGridAdapter = new PhotoMultiGridAdapter(getActivity(), directories);
listAdapter = new PopupDirectoryListAdapter(getActivity(), directories);
RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.rv_photos);
StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(3, OrientationHelper.VERTICAL);
layoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(photoGridAdapter);
recyclerView.setItemAnimator(new DefaultItemAnimator());
photoGridAdapter.setOnZoomListener(new OnZoomListener() {
@Override
public void onClick(View v, int position) {
List<String> photos = photoGridAdapter.getCurrentPhotoPaths();
int[] screenLocation = new int[2];
v.getLocationOnScreen(screenLocation);
ImagePagerFragment imagePagerFragment = ImagePagerFragment.newInstance(photos, position, screenLocation, v.getWidth(), v.getHeight());
((PhotoPickerActivity) getActivity()).addImagePagerFragment(imagePagerFragment, false);
}
});
return rootView;
}
Aggregations