53 lines
1.5 KiB
Kotlin
53 lines
1.5 KiB
Kotlin
package com.gh.common.util
|
|
|
|
import com.gh.common.constant.Config
|
|
import com.gh.gamecenter.entity.SettingsEntity
|
|
|
|
object AdHelper {
|
|
|
|
// 搜索为空/求版本/意见反馈-功能收录/发现/模拟器游戏
|
|
const val LOCATION_SEARCH_EMPTY = "search_empty"
|
|
const val LOCATION_GAME_REQUEST_VERSION = "game_request_version"
|
|
const val LOCATION_SUGGESTION_FUNCTION = "suggestion_function"
|
|
const val LOCATION_DISCOVER = "discover"
|
|
const val LOCATION_SIMULATOR_GAME = "simulator_game"
|
|
|
|
fun getAd(location: String): SettingsEntity.AD? {
|
|
val adList = Config.getSettings()?.adList ?: return null
|
|
|
|
for (ad in adList) {
|
|
if (ad.location == location) return ad
|
|
}
|
|
return null
|
|
}
|
|
|
|
fun getDiscoverAds(): List<SettingsEntity.AD> {
|
|
val adList = Config.getSettings()?.adList ?: return listOf()
|
|
|
|
val discoverAdList = arrayListOf<SettingsEntity.AD>()
|
|
|
|
for (ad in adList) {
|
|
if (ad.location == LOCATION_DISCOVER) {
|
|
discoverAdList.add(ad)
|
|
}
|
|
}
|
|
|
|
return discoverAdList
|
|
}
|
|
|
|
fun getAdForLocation(location: String): SettingsEntity.AD? {
|
|
val adList = Config.getSettings()?.adList ?: return null
|
|
|
|
var result: SettingsEntity.AD? = null
|
|
run outside@ {
|
|
for (ad in adList) {
|
|
if (ad.location == location) {
|
|
result = ad
|
|
return@outside
|
|
}
|
|
}
|
|
}
|
|
|
|
return result
|
|
}
|
|
} |