Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Commit

Permalink
v2.4.0-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
Moriafly committed Jan 24, 2021
1 parent 695e8d0 commit cf4b629
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DetailPlaylistAdapter
@JvmOverloads
constructor(private val songDataList: ArrayList<StandardSongData>,
private val activity: Activity,
private val tag: Int = PLAYLIST_TAG_NORMAL): RecyclerView.Adapter<DetailPlaylistAdapter.ViewHolder>() {
private val tag: Int? = PLAYLIST_TAG_NORMAL): RecyclerView.Adapter<DetailPlaylistAdapter.ViewHolder>() {

inner class ViewHolder(view: View): RecyclerView.ViewHolder(view) {
val tvNumber: TextView = view.findViewById(R.id.tvNumber)
Expand Down Expand Up @@ -63,11 +63,15 @@ class DetailPlaylistAdapter
}
// 更多点击,每首歌右边的三点菜单
ivMore.setOnClickListener {
SongMenuDialog(it.context, activity, song, tag).show()
if (tag != null) {
SongMenuDialog(it.context, activity, song, tag).show()
}
}
// 长按
clSong.setOnLongClickListener {
SongMenuDialog(it.context, activity, song, tag).show()
if (tag != null) {
SongMenuDialog(it.context, activity, song, tag).show()
}
return@setOnLongClickListener true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import com.dirror.music.MyApplication
import com.dirror.music.R
import com.dirror.music.adapter.DetailPlaylistAdapter
import com.dirror.music.data.PLAYLIST_TAG_MY_FAVORITE
import com.dirror.music.data.PLAYLIST_TAG_NORMAL
import com.dirror.music.databinding.ActivityPlaylistBinding
import com.dirror.music.music.standard.SongPicture
Expand Down Expand Up @@ -62,7 +63,7 @@ class PlaylistActivity2: BaseActivity() {
// 获取歌单 id
playlistViewModel.id = intent.getLongExtra(EXTRA_LONG_PLAYLIST_ID, 0L)
// 获取 tag
playlistViewModel.tag = intent.getIntExtra(EXTRA_INT_TAG, PLAYLIST_TAG_NORMAL)
playlistViewModel.tag.value = intent.getIntExtra(EXTRA_INT_TAG, PLAYLIST_TAG_NORMAL)

binding.lottieLoading.repeatCount = -1
binding.lottieLoading.playAnimation()
Expand Down Expand Up @@ -112,12 +113,17 @@ class PlaylistActivity2: BaseActivity() {
override fun initObserver() {
playlistViewModel.apply {
playlist.observe(this@PlaylistActivity2, {
detailPlaylistAdapter = DetailPlaylistAdapter(it, this@PlaylistActivity2, tag)
detailPlaylistAdapter = DetailPlaylistAdapter(it, this@PlaylistActivity2, tag.value)
binding.rvPlaylist.adapter = detailPlaylistAdapter
binding.tvPlayAll.text = "播放全部(${it.size})"
binding.clLoading.visibility = View.GONE
binding.lottieLoading.pauseAnimation()
})
tag.observe(this@PlaylistActivity2, {
if (tag.value == PLAYLIST_TAG_MY_FAVORITE) {
binding.tvName.text = getString(R.string.my_favorite_songs)
}
})
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class PlaylistViewModel: ViewModel() {
var source = SOURCE_NETEASE

// tag
var tag = PLAYLIST_TAG_NORMAL
var tag = MutableLiveData<Int>().also {
it.value = PLAYLIST_TAG_NORMAL
}

// 歌单
var playlist = MutableLiveData<ArrayList<StandardSongData>>()
Expand All @@ -44,4 +46,8 @@ class PlaylistViewModel: ViewModel() {

}

fun setTag(newTag: Int) {
tag.value = newTag
}

}

0 comments on commit cf4b629

Please sign in to comment.