Scroll crash fixed

This commit is contained in:
h4h13 2018-12-10 13:24:43 +05:30
parent 3da441b02f
commit db4d182356
2 changed files with 14 additions and 9 deletions

View file

@ -52,9 +52,9 @@ abstract class AbsOffsetSongAdapter : SongAdapter {
}
override fun getSectionName(position: Int): String {
var positionFinal = position
positionFinal--
return if (position < 0) "" else super.getSectionName(positionFinal)
var positionF = position
positionF--
return if (positionF < 0) "" else super.getSectionName(positionF)
}
open inner class ViewHolder(itemView: View) : SongAdapter.ViewHolder(itemView) {

View file

@ -157,12 +157,17 @@ open class SongAdapter @JvmOverloads constructor(protected val activity: AppComp
}
override fun getSectionName(position: Int): String {
var sectionName: String? = null
when (PreferenceUtil.getInstance().songSortOrder) {
SortOrder.SongSortOrder.SONG_A_Z, SortOrder.SongSortOrder.SONG_Z_A -> sectionName = dataSet[position].title
SortOrder.SongSortOrder.SONG_ALBUM -> sectionName = dataSet[position].albumName
SortOrder.SongSortOrder.SONG_ARTIST -> sectionName = dataSet[position].artistName
if (!showSectionName) {
return "";
}
val sectionName: String? = when (PreferenceUtil.getInstance().songSortOrder) {
SortOrder.SongSortOrder.SONG_A_Z, SortOrder.SongSortOrder.SONG_Z_A -> dataSet[position].title
SortOrder.SongSortOrder.SONG_ALBUM -> dataSet[position].albumName
SortOrder.SongSortOrder.SONG_ARTIST -> dataSet[position].artistName
SortOrder.SongSortOrder.SONG_YEAR -> return MusicUtil.getYearString(dataSet[position].year)
else -> {
return ""
}
}
return MusicUtil.getSectionName(sectionName)
@ -221,6 +226,6 @@ open class SongAdapter @JvmOverloads constructor(protected val activity: AppComp
companion object {
val TAG = SongAdapter::class.java.simpleName
val TAG:String = SongAdapter::class.java.simpleName
}
}