Commit acf052d8 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Update SettingsFragment.kt

parent e318f11d
...@@ -31,7 +31,13 @@ import timber.log.Timber ...@@ -31,7 +31,13 @@ import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
internal const val TAG_SETTINGS_FRAGMENT = "SettingsFragment" internal const val TAG_SETTINGS_FRAGMENT = "SettingsFragment"
private val LOCALES = arrayOf(
fun newInstance(): Fragment = SettingsFragment()
class SettingsFragment : Fragment(), SettingsView, AppLanguageView {
@Inject lateinit var analyticsManager: AnalyticsManager
@Inject lateinit var presenter: SettingsPresenter
private val locales = arrayListOf(
"en", "en",
"ar", "ar",
"de", "de",
...@@ -48,15 +54,7 @@ private val LOCALES = arrayOf( ...@@ -48,15 +54,7 @@ private val LOCALES = arrayOf(
"uk", "uk",
"zh,CN", "zh,CN",
"zh,TW" "zh,TW"
) )
fun newInstance(): Fragment = SettingsFragment()
class SettingsFragment : Fragment(), SettingsView, AppLanguageView {
@Inject
lateinit var analyticsManager: AnalyticsManager
@Inject
lateinit var presenter: SettingsPresenter
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
...@@ -185,7 +183,7 @@ class SettingsFragment : Fragment(), SettingsView, AppLanguageView { ...@@ -185,7 +183,7 @@ class SettingsFragment : Fragment(), SettingsView, AppLanguageView {
context?.let { context?.let {
val selectedLocale = presenter.getCurrentLocale(it) val selectedLocale = presenter.getCurrentLocale(it)
var localeIndex = -1 var localeIndex = -1
LOCALES.forEachIndexed { index, locale -> locales.forEachIndexed { index, locale ->
val array = locale.split(",") val array = locale.split(",")
val language = array[0] val language = array[0]
val country = if (array.size > 1) array[1] else "" val country = if (array.size > 1) array[1] else ""
...@@ -205,7 +203,7 @@ class SettingsFragment : Fragment(), SettingsView, AppLanguageView { ...@@ -205,7 +203,7 @@ class SettingsFragment : Fragment(), SettingsView, AppLanguageView {
.setSingleChoiceItems( .setSingleChoiceItems(
resources.getStringArray(R.array.languages), localeIndex resources.getStringArray(R.array.languages), localeIndex
) { dialog, option -> ) { dialog, option ->
val array = LOCALES[option].split(",") val array = locales[option].split(",")
if (array.size > 1) { if (array.size > 1) {
updateLanguage(array[0], array[1]) updateLanguage(array[0], array[1])
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment