Przeglądaj źródła

017多语言处理

wbspool 1 rok temu
rodzic
commit
5ec9b369e8

+ 10 - 24
BusinessSetting/src/main/java/com/develop/setting/ui/LanguageActivity.kt

@@ -196,32 +196,18 @@ class LanguageActivity : BaseBindingActivity<ActivityLanguageBinding>() {
     }
 
     private fun getSelectedPos(): Int {
-        return when (MMkvUtils.getString(CURRENT_LANGUAGE)) {
-            EN -> {
-                updateSelectionPos(0)
-                0
-            }
-
-            ZH -> {
-                updateSelectionPos(1)
-                1
-            }
-
-            FR -> {
-                updateSelectionPos(2)
-                2
-            }
-
-            JA -> {
-                updateSelectionPos(3)
-                3
-            }
-
-            else -> {
-                updateSelectionPos(0)
-                0
+        val language = MMkvUtils.getString(CURRENT_LANGUAGE)
+        for (i in binding.languageRecycle.models?.indices!!) {
+            var l = binding.languageRecycle.models!![i] as ConfigUtils.Lang;
+            if (language == l.value) {
+                selectedPosition = i
             }
         }
+        if(selectedPosition == -1){
+            selectedPosition = 0
+        }
+        return selectedPosition
+
     }
 
     @Subscribe