Search in sources :

Example 1 with OnFastScrollStateChangeListener

use of com.simplecityapps.recyclerview_fastscroll.interfaces.OnFastScrollStateChangeListener in project Shuttle by timusus.

the class QueueFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.fragment_queue, container, false);
    header = rootView.findViewById(R.id.header);
    if (ShuttleUtils.isLandscape() || ShuttleUtils.isTablet()) {
        header.setVisibility(View.GONE);
    } else {
        header.setVisibility(View.VISIBLE);
    }
    lineTwo = (TextView) rootView.findViewById(R.id.line2);
    recyclerView = (ScrollBlockingRecyclerView) rootView.findViewById(R.id.recyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.setRecyclerListener(this);
    recyclerView.setAdapter(songAdapter);
    recyclerView.setStateChangeListener(new OnFastScrollStateChangeListener() {

        @Override
        public void onFastScrollStart() {
            recyclerView.setBlockScroll(false);
        }

        @Override
        public void onFastScrollStop() {
            recyclerView.setBlockScroll(true);
        }
    });
    itemTouchHelper = new ItemTouchHelper(new ItemTouchHelperCallback((fromPosition, toPosition) -> {
        songAdapter.moveItem(fromPosition, toPosition);
    }, (fromPosition, toPosition) -> {
        MusicUtils.moveQueueItem(fromPosition, toPosition);
        recyclerView.setBlockScroll(true);
    }, () -> {
        //We've finished our drag event. Allow the sliding up panel to intercept touch events
        recyclerView.setBlockScroll(true);
    }));
    itemTouchHelper.attachToRecyclerView(recyclerView);
    themeUIComponents();
    updateTrackInfo();
    return rootView;
}
Also used : ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) OnFastScrollStateChangeListener(com.simplecityapps.recyclerview_fastscroll.interfaces.OnFastScrollStateChangeListener) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ItemTouchHelperCallback(com.simplecity.amp_library.ui.recyclerview.ItemTouchHelperCallback)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)1 ItemTouchHelperCallback (com.simplecity.amp_library.ui.recyclerview.ItemTouchHelperCallback)1 OnFastScrollStateChangeListener (com.simplecityapps.recyclerview_fastscroll.interfaces.OnFastScrollStateChangeListener)1