|
@@ -6,32 +6,19 @@ import android.os.Handler
|
|
import android.os.Looper
|
|
import android.os.Looper
|
|
import android.os.Message
|
|
import android.os.Message
|
|
import android.view.KeyEvent
|
|
import android.view.KeyEvent
|
|
|
|
+import android.view.View
|
|
import android.widget.*
|
|
import android.widget.*
|
|
-import androidx.activity.compose.setContent
|
|
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
-import androidx.compose.foundation.layout.Column
|
|
|
|
-import androidx.compose.foundation.layout.fillMaxSize
|
|
|
|
-import androidx.compose.foundation.layout.padding
|
|
|
|
-import androidx.compose.foundation.rememberScrollState
|
|
|
|
-import androidx.compose.foundation.verticalScroll
|
|
|
|
-import androidx.compose.material.Button
|
|
|
|
-import androidx.compose.material.MaterialTheme
|
|
|
|
-import androidx.compose.material.Surface
|
|
|
|
-import androidx.compose.material.Text
|
|
|
|
-import androidx.compose.runtime.*
|
|
|
|
-import androidx.compose.ui.Modifier
|
|
|
|
-import androidx.compose.ui.graphics.Color
|
|
|
|
-import androidx.compose.ui.tooling.preview.Preview
|
|
|
|
-import androidx.compose.ui.unit.dp
|
|
|
|
import cn.yyxx.eyuangame.base.EYuanGame
|
|
import cn.yyxx.eyuangame.base.EYuanGame
|
|
import cn.yyxx.eyuangame.base.entity.SdkChargeInfo
|
|
import cn.yyxx.eyuangame.base.entity.SdkChargeInfo
|
|
import cn.yyxx.eyuangame.base.entity.SdkEvent
|
|
import cn.yyxx.eyuangame.base.entity.SdkEvent
|
|
import cn.yyxx.eyuangame.base.entity.SdkRoleInfo
|
|
import cn.yyxx.eyuangame.base.entity.SdkRoleInfo
|
|
import cn.yyxx.eyuangame.base.internal.ICallback
|
|
import cn.yyxx.eyuangame.base.internal.ICallback
|
|
|
|
+import cn.yyxx.eyuangame.core.entity.ResultInfo
|
|
|
|
+import cn.yyxx.eyuangame.core.internal.IRequestCallback
|
|
import cn.yyxx.eyuangame.core.network.SdkRequest
|
|
import cn.yyxx.eyuangame.core.network.SdkRequest
|
|
import cn.yyxx.support.hawkeye.LogUtils
|
|
import cn.yyxx.support.hawkeye.LogUtils
|
|
import cn.yyxx.support.hawkeye.ToastUtils
|
|
import cn.yyxx.support.hawkeye.ToastUtils
|
|
-import com.eyuangame.demo.ui.theme.EYuanGameSdkKTXTheme
|
|
|
|
import kotlin.system.exitProcess
|
|
import kotlin.system.exitProcess
|
|
|
|
|
|
|
|
|
|
@@ -39,7 +26,7 @@ import kotlin.system.exitProcess
|
|
* @author #Suyghur.
|
|
* @author #Suyghur.
|
|
* Created on 2021/06/09
|
|
* Created on 2021/06/09
|
|
*/
|
|
*/
|
|
-class DemoActivity : AppCompatActivity() {
|
|
|
|
|
|
+class DemoActivity : AppCompatActivity(), View.OnClickListener {
|
|
|
|
|
|
private val events = mutableListOf(
|
|
private val events = mutableListOf(
|
|
Item(0, "00 接口环境切换"),
|
|
Item(0, "00 接口环境切换"),
|
|
@@ -57,17 +44,20 @@ class DemoActivity : AppCompatActivity() {
|
|
Item(12, "12 sdk日志上报测试")
|
|
Item(12, "12 sdk日志上报测试")
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+ private lateinit var layout: LinearLayout
|
|
|
|
+ private lateinit var mTextView: TextView
|
|
private var cacheRoleInfo: CacheRoleInfo.RoleInfo? = null
|
|
private var cacheRoleInfo: CacheRoleInfo.RoleInfo? = null
|
|
- private val messageBuffer by lazy {
|
|
|
|
|
|
+
|
|
|
|
+ private val message: StringBuilder by lazy {
|
|
StringBuilder()
|
|
StringBuilder()
|
|
}
|
|
}
|
|
- private var message by mutableStateOf("")
|
|
|
|
|
|
+
|
|
private val handler = object : Handler(Looper.getMainLooper()) {
|
|
private val handler = object : Handler(Looper.getMainLooper()) {
|
|
override fun handleMessage(msg: Message) {
|
|
override fun handleMessage(msg: Message) {
|
|
when (msg.what) {
|
|
when (msg.what) {
|
|
10001 -> {
|
|
10001 -> {
|
|
- messageBuffer.append(msg.obj.toString())
|
|
|
|
- message = messageBuffer.toString()
|
|
|
|
|
|
+ message.append(msg.obj.toString())
|
|
|
|
+ mTextView.text = message.toString()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -75,14 +65,7 @@ class DemoActivity : AppCompatActivity() {
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
super.onCreate(savedInstanceState)
|
|
-
|
|
|
|
- setContent {
|
|
|
|
- EYuanGameSdkKTXTheme {
|
|
|
|
- Surface(color = Color.White) {
|
|
|
|
- DemoPage()
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ initView()
|
|
LogUtils.handler = handler
|
|
LogUtils.handler = handler
|
|
EYuanGame.getInstance().initialize(this, true, object : ICallback {
|
|
EYuanGame.getInstance().initialize(this, true, object : ICallback {
|
|
override fun onResult(code: Int, result: String) {
|
|
override fun onResult(code: Int, result: String) {
|
|
@@ -91,110 +74,116 @@ class DemoActivity : AppCompatActivity() {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private fun initView() {
|
|
|
|
+ layout = LinearLayout(this)
|
|
|
|
+ layout.orientation = LinearLayout.VERTICAL
|
|
|
|
|
|
- @Composable
|
|
|
|
- fun DemoPage() {
|
|
|
|
- Column(
|
|
|
|
- modifier = Modifier
|
|
|
|
- .fillMaxSize()
|
|
|
|
- .verticalScroll(rememberScrollState()),
|
|
|
|
- ) {
|
|
|
|
- events.forEach {
|
|
|
|
- Button(
|
|
|
|
- modifier = Modifier
|
|
|
|
- .fillMaxSize()
|
|
|
|
- .padding(start = 10.dp, end = 10.dp),
|
|
|
|
- onClick = { onClick(it.id) }
|
|
|
|
- ) {
|
|
|
|
- Text(text = it.name)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- Text(text = message)
|
|
|
|
|
|
+ initButton()
|
|
|
|
+ mTextView = TextView(this)
|
|
|
|
+ with(mTextView) {
|
|
|
|
+ text = ""
|
|
|
|
+ this@DemoActivity.layout.addView(this)
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ val scrollView = ScrollView(this)
|
|
|
|
+ scrollView.addView(layout)
|
|
|
|
+ setContentView(scrollView)
|
|
}
|
|
}
|
|
|
|
|
|
- @Preview
|
|
|
|
- @Composable
|
|
|
|
- fun PreviewDemoPage() {
|
|
|
|
- EYuanGameSdkKTXTheme {
|
|
|
|
- Surface(color = MaterialTheme.colors.background) {
|
|
|
|
- DemoPage()
|
|
|
|
|
|
+ private fun initButton() {
|
|
|
|
+ for (event in events) {
|
|
|
|
+ with(Button(this)) {
|
|
|
|
+ text = event.name
|
|
|
|
+ tag = event.id
|
|
|
|
+ id = event.id
|
|
|
|
+ setOnClickListener(this@DemoActivity)
|
|
|
|
+ this@DemoActivity.layout.addView(this)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private fun onClick(action: Int) {
|
|
|
|
- messageBuffer.clear()
|
|
|
|
- when (action) {
|
|
|
|
- 0 -> EnvActivity.start(this@DemoActivity)
|
|
|
|
- 1 -> {
|
|
|
|
- EYuanGame.getInstance().login(this@DemoActivity, true, object : ICallback {
|
|
|
|
- override fun onResult(code: Int, result: String) {
|
|
|
|
- ToastUtils.toastInfo(this@DemoActivity, "---- demo提示不做翻译 ----\ncode : $code\n msg : $result\n ---- demo提示不做翻译 ----")
|
|
|
|
- if (code == 0) {
|
|
|
|
- cacheRoleInfo = CacheRoleInfo.getDemoRoleInfo(this@DemoActivity, EYuanGame.getInstance().getCurrentUserId())
|
|
|
|
|
|
+ override fun onClick(v: View?) {
|
|
|
|
+ mTextView.text = ""
|
|
|
|
+ message.clear()
|
|
|
|
+ v?.apply {
|
|
|
|
+ when (tag as Int) {
|
|
|
|
+ 0 -> EnvActivity.start(this@DemoActivity)
|
|
|
|
+ 1 -> {
|
|
|
|
+ EYuanGame.getInstance().login(this@DemoActivity, true, object : ICallback {
|
|
|
|
+ override fun onResult(code: Int, result: String) {
|
|
|
|
+ ToastUtils.toastInfo(this@DemoActivity, "---- demo提示不做翻译 ----\ncode : $code\n msg : $result\n ---- demo提示不做翻译 ----")
|
|
|
|
+ if (code == 0) {
|
|
|
|
+ cacheRoleInfo = CacheRoleInfo.getDemoRoleInfo(this@DemoActivity, EYuanGame.getInstance().getCurrentUserId())
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- 2 -> {
|
|
|
|
- EYuanGame.getInstance().logout(this@DemoActivity, object : ICallback {
|
|
|
|
- override fun onResult(code: Int, result: String) {
|
|
|
|
- if (code == 0) {
|
|
|
|
- EYuanGame.getInstance().login(this@DemoActivity, false, object : ICallback {
|
|
|
|
- override fun onResult(code: Int, result: String) {
|
|
|
|
- ToastUtils.toastInfo(this@DemoActivity, "---- demo提示不做翻译 ----\ncode : $code\n msg : $result\n ---- demo提示不做翻译 ----")
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ 2 -> {
|
|
|
|
+ EYuanGame.getInstance().logout(this@DemoActivity, object : ICallback {
|
|
|
|
+ override fun onResult(code: Int, result: String) {
|
|
|
|
+ if (code == 0) {
|
|
|
|
+ EYuanGame.getInstance().login(this@DemoActivity, false, object : ICallback {
|
|
|
|
+ override fun onResult(code: Int, result: String) {
|
|
|
|
+ ToastUtils.toastInfo(this@DemoActivity, "---- demo提示不做翻译 ----\ncode : $code\n msg : $result\n ---- demo提示不做翻译 ----")
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ 3 -> {
|
|
|
|
+ cacheRoleInfo = null
|
|
|
|
+ cacheRoleInfo = CacheRoleInfo.setDemoRoleInfo(this@DemoActivity, EYuanGame.getInstance().getCurrentUserId())
|
|
|
|
+ EYuanGame.getInstance().roleCreate(this@DemoActivity, getGameRoleInfo())
|
|
|
|
+ }
|
|
|
|
+ 4 -> EYuanGame.getInstance().roleLauncher(this@DemoActivity, getGameRoleInfo())
|
|
|
|
+ 5 -> EYuanGame.getInstance().roleLevelUp(this@DemoActivity, getGameRoleInfo())
|
|
|
|
+ 6 -> {
|
|
|
|
+ EYuanGame.getInstance().charge(this@DemoActivity, getGameChargeInfo(), true, object : ICallback {
|
|
|
|
+ override fun onResult(code: Int, result: String) {
|
|
|
|
+ ToastUtils.toastInfo(this@DemoActivity, "---- demo提示不做翻译 ----\ncode : $code\n msg : $result\n ---- demo提示不做翻译 ----")
|
|
}
|
|
}
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- 3 -> {
|
|
|
|
- cacheRoleInfo = null
|
|
|
|
- cacheRoleInfo = CacheRoleInfo.setDemoRoleInfo(this@DemoActivity, EYuanGame.getInstance().getCurrentUserId())
|
|
|
|
- EYuanGame.getInstance().roleCreate(this@DemoActivity, getGameRoleInfo())
|
|
|
|
- }
|
|
|
|
- 4 -> EYuanGame.getInstance().roleLauncher(this@DemoActivity, getGameRoleInfo())
|
|
|
|
- 5 -> EYuanGame.getInstance().roleLevelUp(this@DemoActivity, getGameRoleInfo())
|
|
|
|
- 6 -> {
|
|
|
|
- EYuanGame.getInstance().charge(this@DemoActivity, getGameChargeInfo(), true, object : ICallback {
|
|
|
|
- override fun onResult(code: Int, result: String) {
|
|
|
|
- ToastUtils.toastInfo(this@DemoActivity, "---- demo提示不做翻译 ----\ncode : $code\n msg : $result\n ---- demo提示不做翻译 ----")
|
|
|
|
- }
|
|
|
|
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- 7 -> {
|
|
|
|
- EYuanGame.getInstance().charge(this@DemoActivity, getGameChargeInfo(), false, object : ICallback {
|
|
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ 7 -> {
|
|
|
|
+ EYuanGame.getInstance().charge(this@DemoActivity, getGameChargeInfo(), false, object : ICallback {
|
|
|
|
+ override fun onResult(code: Int, result: String) {
|
|
|
|
+ ToastUtils.toastInfo(this@DemoActivity, "---- demo提示不做翻译 ----\ncode : $code\n msg : $result\n ---- demo提示不做翻译 ----")
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ 8 -> {
|
|
|
|
+ val sdkEvent = SdkEvent()
|
|
|
|
+ sdkEvent.eventName = "tutorial"
|
|
|
|
+ sdkEvent.standard = true
|
|
|
|
+ sdkEvent.fbAliasName = "fb_mobile_tutorial_completion"
|
|
|
|
+ EYuanGame.getInstance().linkingEvent(this@DemoActivity, sdkEvent)
|
|
|
|
+ }
|
|
|
|
+ 9 -> {
|
|
|
|
+ val sdkEvent = SdkEvent()
|
|
|
|
+ sdkEvent.eventName = "finish_marry"
|
|
|
|
+ sdkEvent.standard = false
|
|
|
|
+ EYuanGame.getInstance().linkingEvent(this@DemoActivity, sdkEvent)
|
|
|
|
+ }
|
|
|
|
+ 10 -> throw RuntimeException("Test Crashlytics Feature")
|
|
|
|
+ 11 -> EYuanGame.getInstance().share(this@DemoActivity, "https://www.baidu.com", "#测试标签", "测试引文", object : ICallback {
|
|
override fun onResult(code: Int, result: String) {
|
|
override fun onResult(code: Int, result: String) {
|
|
- ToastUtils.toastInfo(this@DemoActivity, "---- demo提示不做翻译 ----\ncode : $code\n msg : $result\n ---- demo提示不做翻译 ----")
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
})
|
|
})
|
|
- }
|
|
|
|
- 8 -> {
|
|
|
|
- val sdkEvent = SdkEvent()
|
|
|
|
- sdkEvent.eventName = "tutorial"
|
|
|
|
- sdkEvent.standard = true
|
|
|
|
- sdkEvent.fbAliasName = "fb_mobile_tutorial_completion"
|
|
|
|
- EYuanGame.getInstance().linkingEvent(this@DemoActivity, sdkEvent)
|
|
|
|
- }
|
|
|
|
- 9 -> {
|
|
|
|
- val sdkEvent = SdkEvent()
|
|
|
|
- sdkEvent.eventName = "finish_marry"
|
|
|
|
- sdkEvent.standard = false
|
|
|
|
- EYuanGame.getInstance().linkingEvent(this@DemoActivity, sdkEvent)
|
|
|
|
- }
|
|
|
|
- 10 -> throw RuntimeException("Test Crashlytics Feature")
|
|
|
|
- 11 -> EYuanGame.getInstance().share(this@DemoActivity, "https://www.baidu.com", "#测试标签", "测试引文", object : ICallback {
|
|
|
|
- override fun onResult(code: Int, result: String) {
|
|
|
|
-
|
|
|
|
|
|
+ 12 -> {
|
|
|
|
+ SdkRequest.instance.uploadLogFile(this@DemoActivity, true, object : IRequestCallback {
|
|
|
|
+ override fun onResponse(resultInfo: ResultInfo) {
|
|
|
|
+ ToastUtils.toastInfo(
|
|
|
|
+ this@DemoActivity,
|
|
|
|
+ "---- demo提示不做翻译 ----\ncode : ${resultInfo.code}\n msg : ${resultInfo.msg}\n ---- demo提示不做翻译 ----"
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
-
|
|
|
|
- })
|
|
|
|
- 12 -> {
|
|
|
|
- SdkRequest.instance.uploadLogFile(this)
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|