Search in sources :

Example 1 with ArtistSongAdapter

use of com.lzx.nicemusic.module.artist.adapter.ArtistSongAdapter in project NiceMusic by lizixian18.

the class ArtistDetailActivity method init.

@Override
protected void init(Bundle savedInstanceState) {
    mSongInfo = getIntent().getParcelableExtra("songInfo");
    mSongName = findViewById(R.id.song_name);
    mArtistName = findViewById(R.id.artist_name);
    mSongCover = findViewById(R.id.song_cover);
    mArtistCover = findViewById(R.id.artist_cover);
    mArtistDesc = findViewById(R.id.artist_desc);
    mFloatingActionButton = findViewById(R.id.fab);
    mRecyclerView = findViewById(R.id.recycle_view);
    mNestedScrollView = findViewById(R.id.scrollView);
    mCoverLayout = findViewById(R.id.cover_layout);
    mArtistLayout = findViewById(R.id.artist_layout);
    mAppBarLayout = findViewById(R.id.app_bar_layout);
    mTextPeopleNum = findViewById(R.id.text_people_num);
    mTextPlayNum = findViewById(R.id.text_play_num);
    initUI(mSongInfo);
    mAdapter = new ArtistSongAdapter(this);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.setNestedScrollingEnabled(false);
    mRecyclerView.setAdapter(mAdapter);
    getPresenter().getArtistSongs(mSongInfo.getArtistId());
    getPresenter().getArtistInfo(mSongInfo.getArtistId());
    MusicManager.get().addPlayerEventListener(this);
    mAppBarLayout.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> setViewsTranslation(verticalOffset));
    mFloatingActionButton.setOnClickListener(view -> {
        List<SongInfo> songInfos = mAdapter.getSongInfoList();
        int position = 0;
        if (songInfos.size() > 0 && songInfos.contains(mSongInfo)) {
            position = QueueHelper.getMusicIndexOnQueue(songInfos, mSongInfo.getSongId());
        } else {
            songInfos.add(mSongInfo);
        }
        MusicManager.get().playMusic(songInfos, position);
        PlayingDetailActivity.launch(mContext, songInfos, position);
    });
    mAdapter.setOnItemClickListener((info, position) -> {
        List<SongInfo> songInfos = mAdapter.getSongInfoList();
        if (songInfos.size() > 0) {
            MusicManager.get().playMusic(songInfos, position);
        } else {
            MusicManager.get().playMusicByInfo(info);
        }
    });
    Bundle bundle = new Bundle();
    bundle.putString("name", "大妈的");
    MusicManager.get().updateNotificationContentIntent(bundle, null);
}
Also used : Bundle(android.os.Bundle) ArtistSongAdapter(com.lzx.nicemusic.module.artist.adapter.ArtistSongAdapter) SongInfo(com.lzx.musiclibrary.aidl.model.SongInfo) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 Bundle (android.os.Bundle)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 SongInfo (com.lzx.musiclibrary.aidl.model.SongInfo)1 ArtistSongAdapter (com.lzx.nicemusic.module.artist.adapter.ArtistSongAdapter)1