From 5f8ea93f36fd615ffbde5f9b9afb1b0bcde3f923 Mon Sep 17 00:00:00 2001 From: Tamim Hossain <132823494+CodeWithTamim@users.noreply.github.com> Date: Fri, 25 Oct 2024 16:55:56 +0600 Subject: [PATCH] Refactor attachBaseContext for Null Safety and Clean Code (#3769) Simplified the attachBaseContext function by removing redundant let block and ensuring null safety with concise null handling. This refactor improves readability and ensures that null cases are handled directly. --- V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/BaseActivity.kt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/BaseActivity.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/BaseActivity.kt index 8a2c7fda..f2d4ba94 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/BaseActivity.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/BaseActivity.kt @@ -34,9 +34,6 @@ abstract class BaseActivity : AppCompatActivity() { @RequiresApi(Build.VERSION_CODES.N) override fun attachBaseContext(newBase: Context?) { - val context = newBase?.let { - MyContextWrapper.wrap(newBase, Utils.getLocale()) - } - super.attachBaseContext(context) + super.attachBaseContext(MyContextWrapper.wrap(newBase ?: return, Utils.getLocale())) } }