Search in sources :

Example 1 with DragSortRecycler

use of com.naman14.timber.widgets.DragSortRecycler in project Timber by naman14.

the class PlaylistDetailActivity method setUpSongs.

private void setUpSongs() {
    Runnable navigation = playlistsMap.get(action);
    if (navigation != null) {
        navigation.run();
        DragSortRecycler dragSortRecycler = new DragSortRecycler();
        dragSortRecycler.setViewHandleId(R.id.reorder);
        dragSortRecycler.setOnItemMovedListener(new DragSortRecycler.OnItemMovedListener() {

            @Override
            public void onItemMoved(int from, int to) {
                Log.d("playlist", "onItemMoved " + from + " to " + to);
                Song song = mAdapter.getSongAt(from);
                mAdapter.removeSongAt(from);
                mAdapter.addSongTo(to, song);
                mAdapter.notifyDataSetChanged();
                MediaStore.Audio.Playlists.Members.moveItem(getContentResolver(), playlistID, from, to);
            }
        });
        recyclerView.addItemDecoration(dragSortRecycler);
        recyclerView.addOnItemTouchListener(dragSortRecycler);
        recyclerView.addOnScrollListener(dragSortRecycler.getScrollListener());
    } else {
        Log.d("PlaylistDetail", "mo action specified");
    }
}
Also used : Song(com.naman14.timber.models.Song) DragSortRecycler(com.naman14.timber.widgets.DragSortRecycler)

Aggregations

Song (com.naman14.timber.models.Song)1 DragSortRecycler (com.naman14.timber.widgets.DragSortRecycler)1