Search in sources :

Example 1 with AlbumSongsAdapter

use of com.naman14.timber.adapters.AlbumSongsAdapter in project Timber by naman14.

the class AlbumDetailFragment method onCreateView.

@TargetApi(21)
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.fragment_album_detail, container, false);
    albumArt = (ImageView) rootView.findViewById(R.id.album_art);
    artistArt = (ImageView) rootView.findViewById(R.id.artist_art);
    albumTitle = (TextView) rootView.findViewById(R.id.album_title);
    albumDetails = (TextView) rootView.findViewById(R.id.album_details);
    toolbar = (Toolbar) rootView.findViewById(R.id.toolbar);
    fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
    if (getArguments().getBoolean("transition")) {
        albumArt.setTransitionName(getArguments().getString("transition_name"));
    }
    recyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerview);
    collapsingToolbarLayout = (CollapsingToolbarLayout) rootView.findViewById(R.id.collapsing_toolbar);
    appBarLayout = (AppBarLayout) rootView.findViewById(R.id.app_bar);
    recyclerView.setEnabled(false);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    album = AlbumLoader.getAlbum(getActivity(), albumID);
    setAlbumart();
    setUpEverything();
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Handler handler = new Handler();
            handler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    AlbumSongsAdapter adapter = (AlbumSongsAdapter) recyclerView.getAdapter();
                    MusicPlayer.playAll(getActivity(), adapter.getSongIds(), 0, albumID, TimberUtils.IdType.Album, true);
                    NavigationUtils.navigateToNowplaying(getActivity(), false);
                }
            }, 150);
        }
    });
    return rootView;
}
Also used : AlbumSongsAdapter(com.naman14.timber.adapters.AlbumSongsAdapter) Handler(android.os.Handler) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) TargetApi(android.annotation.TargetApi)

Example 2 with AlbumSongsAdapter

use of com.naman14.timber.adapters.AlbumSongsAdapter in project Timber by naman14.

the class AlbumDetailFragment method setUpAlbumSongs.

private void setUpAlbumSongs() {
    List<Song> songList = AlbumSongLoader.getSongsForAlbum(getActivity(), albumID);
    mAdapter = new AlbumSongsAdapter(getActivity(), songList, albumID);
    recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
    recyclerView.setAdapter(mAdapter);
}
Also used : Song(com.naman14.timber.models.Song) AlbumSongsAdapter(com.naman14.timber.adapters.AlbumSongsAdapter) DividerItemDecoration(com.naman14.timber.widgets.DividerItemDecoration)

Aggregations

AlbumSongsAdapter (com.naman14.timber.adapters.AlbumSongsAdapter)2 TargetApi (android.annotation.TargetApi)1 Handler (android.os.Handler)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 Song (com.naman14.timber.models.Song)1 DividerItemDecoration (com.naman14.timber.widgets.DividerItemDecoration)1