Update PreferenceUtil.kt

main
Hemanth S 2020-10-18 02:20:40 +05:30
parent 24159557df
commit 9b677573a3
1 changed files with 9 additions and 7 deletions

View File

@ -399,8 +399,8 @@ object PreferenceUtil {
val position = sharedPreferences.getStringOrDefault( val position = sharedPreferences.getStringOrDefault(
HOME_ARTIST_GRID_STYLE, "0" HOME_ARTIST_GRID_STYLE, "0"
).toInt() ).toInt()
val typedArray = val typedArray = App.getContext()
App.getContext().resources.obtainTypedArray(R.array.pref_home_grid_style_layout) .resources.obtainTypedArray(R.array.pref_home_grid_style_layout)
val layoutRes = typedArray.getResourceId(position, 0) val layoutRes = typedArray.getResourceId(position, 0)
typedArray.recycle() typedArray.recycle()
return if (layoutRes == 0) { return if (layoutRes == 0) {
@ -410,10 +410,12 @@ object PreferenceUtil {
val homeAlbumGridStyle: Int val homeAlbumGridStyle: Int
get() { get() {
val position = sharedPreferences.getStringOrDefault(HOME_ALBUM_GRID_STYLE, "4").toInt() val position = sharedPreferences.getStringOrDefault(
val typedArray = HOME_ALBUM_GRID_STYLE, "4"
App.getContext().resources.obtainTypedArray(R.array.pref_home_grid_style_layout) ).toInt()
val layoutRes = typedArray.getResourceId(position, 0) val typedArray = App.getContext()
.resources.obtainTypedArray(R.array.pref_home_grid_style_layout)
val layoutRes = typedArray.getResourceId(position, 4)
typedArray.recycle() typedArray.recycle()
return if (layoutRes == 0) { return if (layoutRes == 0) {
R.layout.item_artist R.layout.item_artist
@ -423,7 +425,7 @@ object PreferenceUtil {
val tabTitleMode: Int val tabTitleMode: Int
get() { get() {
return when (sharedPreferences.getStringOrDefault( return when (sharedPreferences.getStringOrDefault(
TAB_TEXT_MODE, "0" TAB_TEXT_MODE, "1"
).toInt()) { ).toInt()) {
1 -> LabelVisibilityMode.LABEL_VISIBILITY_LABELED 1 -> LabelVisibilityMode.LABEL_VISIBILITY_LABELED
0 -> LabelVisibilityMode.LABEL_VISIBILITY_AUTO 0 -> LabelVisibilityMode.LABEL_VISIBILITY_AUTO