diff options
-rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt | 5 | ||||
-rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/MemoryUtil.kt | 20 |
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 - } } |