79 lines
2.6 KiB
Kotlin
79 lines
2.6 KiB
Kotlin
package com.gh.common.util
|
|
|
|
import com.gh.gamecenter.common.entity.Display
|
|
import com.gh.gamecenter.common.utils.toJson
|
|
import com.gh.gamecenter.core.utils.GsonUtils
|
|
import com.gh.gamecenter.core.utils.SPUtils
|
|
import com.gh.gamecenter.entity.SubjectRecommendEntity
|
|
import com.halo.assistant.HaloApp
|
|
|
|
object HomeBottomBarHelper {
|
|
private const val GAME_BAR_KEY = "game_bar_key"
|
|
private const val VIDEO_BAR_KEY = "video_bar_key"
|
|
|
|
@JvmStatic
|
|
fun getDefaultGameBarData(): SubjectRecommendEntity {
|
|
try {
|
|
val json = SPUtils.getString(GAME_BAR_KEY)
|
|
if (json.isNotEmpty()) {
|
|
return GsonUtils.fromJson(json, SubjectRecommendEntity::class.java)
|
|
}
|
|
} catch (ignore: Exception) {
|
|
|
|
}
|
|
val animationCode = HaloApp.getInstance().application.assets
|
|
.open("lottie/tab_game.json")
|
|
.bufferedReader().use { it.readText() }
|
|
return SubjectRecommendEntity(
|
|
link = "5de21b5d75e6fa054f784882",
|
|
type = "block",
|
|
text = "游戏库",
|
|
name = "游戏库",
|
|
position = 2,
|
|
iconSelect = "https://resource.ghzs.com/image/game/library/entrance/5e183202913fbd002c75f247.png",
|
|
iconUnselect = "https://resource.ghzs.com/image/game/library/entrance/5e1831fd913fbd003024641e.png",
|
|
animationCode = animationCode,
|
|
default = false,
|
|
display = Display()
|
|
)
|
|
}
|
|
|
|
@JvmStatic
|
|
fun getDefaultVideoData(): SubjectRecommendEntity {
|
|
try {
|
|
val json = SPUtils.getString(VIDEO_BAR_KEY)
|
|
if (json.isNotEmpty()) {
|
|
return GsonUtils.fromJson(json, SubjectRecommendEntity::class.java)
|
|
}
|
|
} catch (ignore: Exception) {
|
|
|
|
}
|
|
return getDefaultVideoEntity()
|
|
}
|
|
|
|
@JvmStatic
|
|
fun getDefaultVideoEntity(): SubjectRecommendEntity {
|
|
val animationCode = HaloApp.getInstance().application.assets
|
|
.open("lottie/tab_video.json")
|
|
.bufferedReader().use { it.readText() }
|
|
return SubjectRecommendEntity(
|
|
type = "video_stream",
|
|
text = "视频",
|
|
name = "视频",
|
|
position = 4,
|
|
animationCode = animationCode,
|
|
default = false,
|
|
display = Display()
|
|
)
|
|
}
|
|
|
|
@JvmStatic
|
|
fun updateDefaultGameBarData(data: SubjectRecommendEntity) {
|
|
SPUtils.setString(GAME_BAR_KEY, data.toJson())
|
|
}
|
|
|
|
@JvmStatic
|
|
fun updateDefaultVideoBarData(data: SubjectRecommendEntity) {
|
|
SPUtils.setString(VIDEO_BAR_KEY, data.toJson())
|
|
}
|
|
} |