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");
}
}
Aggregations