Search in sources :

Example 1 with OnZoomListener

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;
}
Also used : PhotoMultiGridAdapter(io.github.wangeason.multiphotopicker.adapter.PhotoMultiGridAdapter) OnZoomListener(io.github.wangeason.multiphotopicker.event.OnZoomListener) RecyclerView(android.support.v7.widget.RecyclerView) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) ArrayList(java.util.ArrayList) List(java.util.List) PopupDirectoryListAdapter(io.github.wangeason.multiphotopicker.adapter.PopupDirectoryListAdapter) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Aggregations

DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)1 RecyclerView (android.support.v7.widget.RecyclerView)1 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)1 View (android.view.View)1 PhotoMultiGridAdapter (io.github.wangeason.multiphotopicker.adapter.PhotoMultiGridAdapter)1 PopupDirectoryListAdapter (io.github.wangeason.multiphotopicker.adapter.PopupDirectoryListAdapter)1 OnZoomListener (io.github.wangeason.multiphotopicker.event.OnZoomListener)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1