Converted Java View classes to Kotlin

This commit is contained in:
Prathamesh More 2022-04-13 00:04:36 +05:30
parent ad90694879
commit a4d44406d6
18 changed files with 274 additions and 994 deletions

View file

@ -0,0 +1,27 @@
package code.name.monkey.retromusic
import android.content.Context
import android.content.ContextWrapper
import android.os.LocaleList
import code.name.monkey.appthemehelper.util.VersionUtils.hasNougatMR
import com.google.android.gms.common.annotation.KeepName
import java.util.*
class LanguageContextWrapper(base: Context?) : ContextWrapper(base) {
companion object {
@KeepName
fun wrap(context: Context?, newLocale: Locale?): LanguageContextWrapper {
if (context == null) return LanguageContextWrapper(context)
val configuration = context.resources.configuration
if (hasNougatMR()) {
configuration.setLocale(newLocale)
val localeList = LocaleList(newLocale)
LocaleList.setDefault(localeList)
configuration.setLocales(localeList)
} else {
configuration.setLocale(newLocale)
}
return LanguageContextWrapper(context.createConfigurationContext(configuration))
}
}
}