mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-09-07 00:43:28 +00:00
Merge pull request #16 from MNCHL/MNCHL-patch-17
Update MainActivity.kt
This commit is contained in:
commit
9629cdf9cd
|
@ -51,13 +51,6 @@ import java.io.BufferedOutputStream
|
||||||
import java.util.zip.ZipEntry
|
import java.util.zip.ZipEntry
|
||||||
import java.util.zip.ZipInputStream
|
import java.util.zip.ZipInputStream
|
||||||
import org.yuzu.yuzu_emu.UpdateManager
|
import org.yuzu.yuzu_emu.UpdateManager
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.GlobalScope
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import okhttp3.OkHttpClient
|
|
||||||
import okhttp3.Request
|
|
||||||
import okhttp3.Response
|
|
||||||
import android.util.Log
|
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity(), ThemeProvider {
|
class MainActivity : AppCompatActivity(), ThemeProvider {
|
||||||
private lateinit var binding: ActivityMainBinding
|
private lateinit var binding: ActivityMainBinding
|
||||||
|
@ -70,36 +63,7 @@ class MainActivity : AppCompatActivity(), ThemeProvider {
|
||||||
override var themeId: Int = 0
|
override var themeId: Int = 0
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
private fun fetchData() {
|
UpdateManager.checkAndInstallUpdate(this)
|
||||||
val client = OkHttpClient()
|
|
||||||
val url = "http://mkoc.cn/aip/version.php"
|
|
||||||
|
|
||||||
val request = Request.Builder()
|
|
||||||
.url(url)
|
|
||||||
.build()
|
|
||||||
|
|
||||||
// 使用协程来执行网络请求
|
|
||||||
GlobalScope.launch(Dispatchers.IO) {
|
|
||||||
try {
|
|
||||||
val response: Response = client.newCall(request).execute()
|
|
||||||
|
|
||||||
if (response.isSuccessful) {
|
|
||||||
val responseBody = response.body?.string()
|
|
||||||
Log.d("MainActivity", "Response: $responseBody")
|
|
||||||
|
|
||||||
// 在这里处理响应数据,可以更新 UI
|
|
||||||
// 例如,你可以使用 runOnUiThread 来更新 UI 控件
|
|
||||||
} else {
|
|
||||||
Log.e("MainActivity", "Request failed with code: ${response.code}")
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.e("MainActivity", "Error: ${e.message}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val updateManager = UpdateManager(this)
|
|
||||||
updateManager.checkForUpdates()
|
|
||||||
val splashScreen = installSplashScreen()
|
val splashScreen = installSplashScreen()
|
||||||
splashScreen.setKeepOnScreenCondition { !DirectoryInitialization.areDirectoriesReady }
|
splashScreen.setKeepOnScreenCondition { !DirectoryInitialization.areDirectoriesReady }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue