summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCharles Lombardo <clombardo169@gmail.com>2023-06-28 21:05:32 +0200
committerCharles Lombardo <clombardo169@gmail.com>2023-06-29 02:00:25 +0200
commita1dd5dfba5ed87242ca6498a5baa8a105ee72a64 (patch)
treee3eda9442211edb63ee392e206fb2dec43cf44c3 /src
parentMerge pull request #10945 from t895/android-14 (diff)
downloadyuzu-a1dd5dfba5ed87242ca6498a5baa8a105ee72a64.tar
yuzu-a1dd5dfba5ed87242ca6498a5baa8a105ee72a64.tar.gz
yuzu-a1dd5dfba5ed87242ca6498a5baa8a105ee72a64.tar.bz2
yuzu-a1dd5dfba5ed87242ca6498a5baa8a105ee72a64.tar.lz
yuzu-a1dd5dfba5ed87242ca6498a5baa8a105ee72a64.tar.xz
yuzu-a1dd5dfba5ed87242ca6498a5baa8a105ee72a64.tar.zst
yuzu-a1dd5dfba5ed87242ca6498a5baa8a105ee72a64.zip
Diffstat (limited to 'src')
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt5
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/MemoryUtil.kt20
2 files changed, 12 insertions, 13 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt
index ae665ed2e..4052eead5 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt
@@ -106,13 +106,12 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
inputHandler = InputHandler()
inputHandler.initialize()
- val memoryUtil = MemoryUtil(this)
- if (memoryUtil.isLessThan(8, MemoryUtil.Gb)) {
+ if (MemoryUtil.isLessThan(8, MemoryUtil.Gb)) {
Toast.makeText(
this,
getString(
R.string.device_memory_inadequate,
- memoryUtil.getDeviceRAM(),
+ MemoryUtil.getDeviceRAM(),
"8 ${getString(R.string.memory_gigabyte)}"
),
Toast.LENGTH_LONG
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/MemoryUtil.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/MemoryUtil.kt
index 18e5fa0b0..59e9f8f87 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/MemoryUtil.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/MemoryUtil.kt
@@ -6,13 +6,22 @@ package org.yuzu.yuzu_emu.utils
import android.app.ActivityManager
import android.content.Context
import org.yuzu.yuzu_emu.R
+import org.yuzu.yuzu_emu.YuzuApplication
import java.util.Locale
-class MemoryUtil(val context: Context) {
+object MemoryUtil {
+ private val context get() = YuzuApplication.appContext
private val Long.floatForm: String
get() = String.format(Locale.ROOT, "%.2f", this.toDouble())
+ const val Kb: Long = 1024
+ const val Mb = Kb * 1024
+ const val Gb = Mb * 1024
+ const val Tb = Gb * 1024
+ const val Pb = Tb * 1024
+ const val Eb = Pb * 1024
+
private fun bytesToSizeUnit(size: Long): String {
return when {
size < Kb -> "${size.floatForm} ${context.getString(R.string.memory_byte)}"
@@ -47,13 +56,4 @@ class MemoryUtil(val context: Context) {
fun getDeviceRAM(): String {
return bytesToSizeUnit(totalMemory)
}
-
- companion object {
- const val Kb: Long = 1024
- const val Mb = Kb * 1024
- const val Gb = Mb * 1024
- const val Tb = Gb * 1024
- const val Pb = Tb * 1024
- const val Eb = Pb * 1024
- }
}