Search in sources :

Example 1 with PlaylistSongAdapter

use of com.kabouzeid.gramophone.adapter.song.PlaylistSongAdapter in project Phonograph by kabouzeid.

the class PlaylistDetailActivity method setUpRecyclerView.

private void setUpRecyclerView() {
    ViewUtil.setUpFastScrollRecyclerViewColor(this, ((FastScrollRecyclerView) recyclerView), ThemeStore.accentColor(this));
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    if (playlist instanceof AbsCustomPlaylist) {
        adapter = new PlaylistSongAdapter(this, new ArrayList<>(), R.layout.item_list, false, this);
        recyclerView.setAdapter(adapter);
    } else {
        recyclerViewDragDropManager = new RecyclerViewDragDropManager();
        final GeneralItemAnimator animator = new RefactoredDefaultItemAnimator();
        adapter = new OrderablePlaylistSongAdapter(this, new ArrayList<>(), R.layout.item_list, false, this, (fromPosition, toPosition) -> {
            if (PlaylistsUtil.moveItem(PlaylistDetailActivity.this, playlist.id, fromPosition, toPosition)) {
                Song song = adapter.getDataSet().remove(fromPosition);
                adapter.getDataSet().add(toPosition, song);
                adapter.notifyItemMoved(fromPosition, toPosition);
            }
        });
        wrappedAdapter = recyclerViewDragDropManager.createWrappedAdapter(adapter);
        recyclerView.setAdapter(wrappedAdapter);
        recyclerView.setItemAnimator(animator);
        recyclerViewDragDropManager.attachRecyclerView(recyclerView);
    }
    adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {

        @Override
        public void onChanged() {
            super.onChanged();
            checkIsEmpty();
        }
    });
}
Also used : MaterialCab(com.afollestad.materialcab.MaterialCab) Context(android.content.Context) Bundle(android.os.Bundle) ViewUtil(com.kabouzeid.gramophone.util.ViewUtil) ButterKnife(butterknife.ButterKnife) NonNull(androidx.annotation.NonNull) PlaylistSongLoader(com.kabouzeid.gramophone.loader.PlaylistSongLoader) MusicPlayerRemote(com.kabouzeid.gramophone.helper.MusicPlayerRemote) LoaderManager(androidx.loader.app.LoaderManager) WrappedAsyncTaskLoader(com.kabouzeid.gramophone.misc.WrappedAsyncTaskLoader) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) BindView(butterknife.BindView) ThemeStore(com.kabouzeid.appthemehelper.ThemeStore) Playlist(com.kabouzeid.gramophone.model.Playlist) LoaderIds(com.kabouzeid.gramophone.interfaces.LoaderIds) OrderablePlaylistSongAdapter(com.kabouzeid.gramophone.adapter.song.OrderablePlaylistSongAdapter) PlaylistsUtil(com.kabouzeid.gramophone.util.PlaylistsUtil) PhonographColorUtil(com.kabouzeid.gramophone.util.PhonographColorUtil) PlaylistLoader(com.kabouzeid.gramophone.loader.PlaylistLoader) Menu(android.view.Menu) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) RefactoredDefaultItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator) AbsCustomPlaylist(com.kabouzeid.gramophone.model.AbsCustomPlaylist) R(com.kabouzeid.gramophone.R) Loader(androidx.loader.content.Loader) WrapperAdapterUtils(com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils) FastScrollRecyclerView(com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView) SongAdapter(com.kabouzeid.gramophone.adapter.song.SongAdapter) Song(com.kabouzeid.gramophone.model.Song) PlaylistMenuHelper(com.kabouzeid.gramophone.helper.menu.PlaylistMenuHelper) RecyclerViewDragDropManager(com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager) List(java.util.List) TextView(android.widget.TextView) AbsSlidingMusicPanelActivity(com.kabouzeid.gramophone.ui.activities.base.AbsSlidingMusicPanelActivity) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) CabHolder(com.kabouzeid.gramophone.interfaces.CabHolder) PlaylistSongAdapter(com.kabouzeid.gramophone.adapter.song.PlaylistSongAdapter) Toolbar(androidx.appcompat.widget.Toolbar) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) OrderablePlaylistSongAdapter(com.kabouzeid.gramophone.adapter.song.OrderablePlaylistSongAdapter) PlaylistSongAdapter(com.kabouzeid.gramophone.adapter.song.PlaylistSongAdapter) ArrayList(java.util.ArrayList) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) RefactoredDefaultItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator) Song(com.kabouzeid.gramophone.model.Song) FastScrollRecyclerView(com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView) AbsCustomPlaylist(com.kabouzeid.gramophone.model.AbsCustomPlaylist) RecyclerView(androidx.recyclerview.widget.RecyclerView) FastScrollRecyclerView(com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) OrderablePlaylistSongAdapter(com.kabouzeid.gramophone.adapter.song.OrderablePlaylistSongAdapter) RecyclerViewDragDropManager(com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager)

Aggregations

Context (android.content.Context)1 Bundle (android.os.Bundle)1 Menu (android.view.Menu)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 TextView (android.widget.TextView)1 NonNull (androidx.annotation.NonNull)1 Toolbar (androidx.appcompat.widget.Toolbar)1 LoaderManager (androidx.loader.app.LoaderManager)1 Loader (androidx.loader.content.Loader)1 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 BindView (butterknife.BindView)1 ButterKnife (butterknife.ButterKnife)1 MaterialCab (com.afollestad.materialcab.MaterialCab)1 GeneralItemAnimator (com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator)1 RefactoredDefaultItemAnimator (com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator)1 RecyclerViewDragDropManager (com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager)1 WrapperAdapterUtils (com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils)1 ThemeStore (com.kabouzeid.appthemehelper.ThemeStore)1