mirror of
https://github.com/skyline-emu/skyline.git
synced 2025-01-11 07:19:09 +01:00
Use coroutine
This commit is contained in:
parent
b2de510b2b
commit
d6eab932a7
@ -18,12 +18,14 @@ import android.widget.Toast
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat.startActivity
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONTokener
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.net.URL
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
class AppUpdater : BroadcastReceiver() {
|
||||
private var downloadID = 0L
|
||||
@ -68,14 +70,14 @@ class AppUpdater : BroadcastReceiver() {
|
||||
companion object {
|
||||
private const val baseUrl = "https://skyline-builds.alula.gay"
|
||||
private const val branch = "ftx1"
|
||||
|
||||
@JvmStatic
|
||||
fun checkForUpdates(applicationContext : Context) {
|
||||
val myExecutor = Executors.newSingleThreadExecutor()
|
||||
val myHandler = Handler(Looper.getMainLooper())
|
||||
val builder = AlertDialog.Builder(applicationContext)
|
||||
|
||||
val url = URL("$baseUrl/builds")
|
||||
myExecutor.execute {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
try {
|
||||
val response = url.readText()
|
||||
val jsonBuilds = JSONTokener(response).nextValue() as JSONArray
|
||||
|
Loading…
x
Reference in New Issue
Block a user