From b6c164747600c54bf5fd767c7a3ab988ed473649 Mon Sep 17 00:00:00 2001 From: PabloG02 Date: Sat, 21 Jan 2023 17:12:15 +0100 Subject: [PATCH] Change equal to == --- app/src/main/java/emu/skyline/AppUpdater.kt | 17 +++++++++-------- app/src/main/java/emu/skyline/MainActivity.kt | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/emu/skyline/AppUpdater.kt b/app/src/main/java/emu/skyline/AppUpdater.kt index 022ac862..51cbb640 100644 --- a/app/src/main/java/emu/skyline/AppUpdater.kt +++ b/app/src/main/java/emu/skyline/AppUpdater.kt @@ -18,6 +18,7 @@ import android.widget.ImageView import android.widget.Toast import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity +import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat.startActivity import com.google.android.material.badge.BadgeDrawable import com.google.android.material.badge.BadgeDrawable.BOTTOM_END @@ -87,14 +88,14 @@ class AppUpdater : BroadcastReceiver() { val jsonBuilds = JSONTokener(response).nextValue() as JSONArray var ftx1Index = 0 - while (ftx1Index < jsonBuilds.length() && !jsonBuilds.getJSONObject(ftx1Index).get("branch").equals(branch)) { + while (ftx1Index < jsonBuilds.length() && jsonBuilds.getJSONObject(ftx1Index).get("branch") != branch) { ftx1Index++ } if (ftx1Index >= jsonBuilds.length()) ftx1Index = 0 val remoteBuildGitHash = jsonBuilds.getJSONObject(ftx1Index).getJSONObject("commit").getString("id") - if (!BuildConfig.GIT_HASH.equals(remoteBuildGitHash)) { + if (BuildConfig.GIT_HASH != remoteBuildGitHash) { val id = jsonBuilds.getJSONObject(ftx1Index).get("id") val apkName = jsonBuilds.getJSONObject(ftx1Index).get("apkName") val uri = Uri.parse("$baseUrl/cache/${id}/${apkName}") @@ -103,7 +104,7 @@ class AppUpdater : BroadcastReceiver() { builder.setTitle("New version ${jsonBuilds.getJSONObject(ftx1Index).get("runNumber")}") .setMessage(Html.fromHtml("Changelog

${jsonBuilds.getJSONObject(ftx1Index).getJSONObject("commit").getString("message")}

", 0)) .setCancelable(true) - .setPositiveButton("Update") { dialogInterface, it -> + .setPositiveButton("Update") { dialogInterface, _ -> val receiver = AppUpdater() applicationContext.registerReceiver(receiver, IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)) receiver.downloadApk(applicationContext, uri) @@ -115,7 +116,7 @@ class AppUpdater : BroadcastReceiver() { builder.setTitle("No updates available") .setMessage(Html.fromHtml("Changelog

${jsonBuilds.getJSONObject(ftx1Index).getJSONObject("commit").getString("message")}

", 0)) .setCancelable(true) - .setPositiveButton("Close") { dialogInterface, it -> + .setPositiveButton("Close") { dialogInterface, _ -> dialogInterface.dismiss() }.show() } @@ -130,25 +131,25 @@ class AppUpdater : BroadcastReceiver() { @com.google.android.material.badge.ExperimentalBadgeUtils fun checkForUpdates2(context : Context, icon: ImageView) { CoroutineScope(Dispatchers.IO).launch { - val url = URL("$baseUrl/builds") + val url = URL("$baseUrl/builds") try { val response = url.readText() val jsonBuilds = JSONTokener(response).nextValue() as JSONArray var ftx1Index = 0 - while (ftx1Index < jsonBuilds.length() && !jsonBuilds.getJSONObject(ftx1Index).get("branch").equals(branch)) { + while (ftx1Index < jsonBuilds.length() && jsonBuilds.getJSONObject(ftx1Index).get("branch") != branch) { ftx1Index++ } if (ftx1Index >= jsonBuilds.length()) ftx1Index = 0 val remoteBuildGitHash = jsonBuilds.getJSONObject(ftx1Index).getJSONObject("commit").getString("id") - if(!BuildConfig.GIT_HASH.equals(remoteBuildGitHash)){ + if(BuildConfig.GIT_HASH != remoteBuildGitHash){ val badge = BadgeDrawable.create(context) badge.badgeGravity = BOTTOM_END badge.verticalOffset = 25 badge.horizontalOffset = 25 - badge.backgroundColor = context.getResources().getColor(R.color.colorPrimary) + badge.backgroundColor = ContextCompat.getColor(context, R.color.colorPrimary) BadgeUtils.attachBadgeDrawable(badge, icon) } } catch (e : IOException) { diff --git a/app/src/main/java/emu/skyline/MainActivity.kt b/app/src/main/java/emu/skyline/MainActivity.kt index e904f2a5..f8213b09 100644 --- a/app/src/main/java/emu/skyline/MainActivity.kt +++ b/app/src/main/java/emu/skyline/MainActivity.kt @@ -151,7 +151,7 @@ class MainActivity : AppCompatActivity() { Snackbar.make(this@MainActivity.findViewById(android.R.id.content), getString(R.string.logs_not_found), Snackbar.LENGTH_SHORT).show() } } - if (BuildConfig.FLAVOR.equals("edge")) { + if (BuildConfig.FLAVOR == "edge") { binding.checkUpdatesIcon.visibility = View.GONE } else { AppUpdater.checkForUpdates2(context, binding.checkUpdatesIcon)