Compatible for Larger tablet
This commit is contained in:
parent
a7ce34a60e
commit
579a8d06eb
51 changed files with 309 additions and 151 deletions
|
@ -113,7 +113,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView {
|
|||
}
|
||||
|
||||
private fun setupRecyclerView() {
|
||||
simpleSongAdapter = SimpleSongAdapter(this, ArrayList(), R.layout.item_song, false)
|
||||
simpleSongAdapter = SimpleSongAdapter(this, ArrayList(), R.layout.item_song)
|
||||
recyclerView.apply {
|
||||
layoutManager = LinearLayoutManager(this@AlbumDetailsActivity)
|
||||
itemAnimator = DefaultItemAnimator()
|
||||
|
|
|
@ -172,7 +172,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView {
|
|||
layoutManager = GridLayoutManager(this.context, 1, GridLayoutManager.HORIZONTAL, false)
|
||||
adapter = albumAdapter
|
||||
}
|
||||
songAdapter = SimpleSongAdapter(this, ArrayList(), R.layout.item_song, false)
|
||||
songAdapter = SimpleSongAdapter(this, ArrayList(), R.layout.item_song)
|
||||
recyclerView.apply {
|
||||
itemAnimator = DefaultItemAnimator()
|
||||
layoutManager = LinearLayoutManager(this.context)
|
||||
|
|
|
@ -4,8 +4,6 @@ import android.view.LayoutInflater
|
|||
import android.view.ViewGroup
|
||||
import androidx.annotation.LayoutRes
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.TintHelper
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import java.util.*
|
||||
|
@ -13,14 +11,8 @@ import java.util.*
|
|||
|
||||
class SimpleSongAdapter(context: AppCompatActivity,
|
||||
songs: ArrayList<Song>,
|
||||
@LayoutRes i: Int,
|
||||
val useNumbers: Boolean) : SongAdapter(context, songs, i, false, null) {
|
||||
@LayoutRes i: Int) : SongAdapter(context, songs, i, false, null) {
|
||||
|
||||
private var textColor: Int = 0
|
||||
|
||||
init {
|
||||
textColor = ThemeStore.textColorPrimary(context)
|
||||
}
|
||||
|
||||
override fun swapDataSet(dataSet: ArrayList<Song>) {
|
||||
this.dataSet.clear()
|
||||
|
@ -36,33 +28,11 @@ class SimpleSongAdapter(context: AppCompatActivity,
|
|||
super.onBindViewHolder(holder, position)
|
||||
val fixedTrackNumber = MusicUtil.getFixedTrackNumber(dataSet[position].trackNumber)
|
||||
|
||||
if (holder.imageText != null) {
|
||||
if (useNumbers) {
|
||||
holder.imageText!!.text = (position + 1).toString()
|
||||
} else {
|
||||
holder.imageText!!.text = if (fixedTrackNumber > 0) fixedTrackNumber.toString() else "-"
|
||||
}
|
||||
holder.imageText!!.setTextColor(textColor)
|
||||
}
|
||||
|
||||
if (holder.time != null) {
|
||||
holder.time!!.text = MusicUtil.getReadableDurationString(dataSet[position].duration)
|
||||
holder.time!!.setTextColor(textColor)
|
||||
}
|
||||
if (holder.title != null) {
|
||||
holder.title!!.setTextColor(textColor)
|
||||
}
|
||||
if (holder.menu != null) {
|
||||
TintHelper.setTintAuto(holder.menu!!, textColor, false)
|
||||
}
|
||||
holder.imageText?.text = if (fixedTrackNumber > 0) fixedTrackNumber.toString() else "-"
|
||||
holder.time?.text = MusicUtil.getReadableDurationString(dataSet[position].duration)
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return dataSet.size
|
||||
}
|
||||
|
||||
fun setTextColor(textColor: Int) {
|
||||
this.textColor = textColor
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue