42 lines
1.5 KiB
Kotlin
42 lines
1.5 KiB
Kotlin
package com.gh.vspace
|
|
|
|
import android.content.Intent
|
|
import android.view.LayoutInflater
|
|
import android.view.View
|
|
import android.view.ViewGroup
|
|
import androidx.annotation.Keep
|
|
import com.gh.gamecenter.R
|
|
import com.gh.gamecenter.core.utils.ToastUtils
|
|
import com.gh.gamecenter.databinding.LayoutPersonalOtherItemBinding
|
|
import com.gh.vspace.installexternalgames.InstallExternalGameActivity
|
|
import com.lightgame.utils.Utils
|
|
import java.io.File
|
|
|
|
@Keep
|
|
class ExternalGameUsage : ITestCase {
|
|
|
|
private fun buttonTemplate(viewParent: ViewGroup, id: Int, fn: (LayoutPersonalOtherItemBinding) -> Unit) {
|
|
val context = viewParent.context
|
|
viewParent.findViewById<View>(id) ?: run {
|
|
val binding = LayoutPersonalOtherItemBinding.inflate(LayoutInflater.from(context)).apply {
|
|
root.id = id
|
|
fn(this)
|
|
}
|
|
viewParent.addView(binding.root, 0)
|
|
}
|
|
}
|
|
|
|
override fun addInstallExternalGameButton(viewParent: ViewGroup) {
|
|
val context = viewParent.context
|
|
buttonTemplate(viewParent, R.id.install_game_from_external) {
|
|
it.titleTv.text = context.getString(R.string.title_install_external_game)
|
|
it.iconIv.setImageResource(R.drawable.ic_personal_my_game)
|
|
it.root.setOnClickListener {
|
|
context.startActivity(
|
|
InstallExternalGameActivity.getIntent(context)
|
|
.apply { flags = flags or Intent.FLAG_ACTIVITY_NEW_TASK })
|
|
}
|
|
}
|
|
}
|
|
|
|
} |