mirror of
https://github.com/Michatec/michas-droid.git
synced 2026-06-15 16:13:24 +02:00
- Refactor code to use idiomatic Kotlin functions like isNullOrEmpty(), associateBy, and appendRange
- Increase `DiffUtil` threshold in `CursorRecyclerAdapter` to 500 and optimize equality checks - Simplify locale configuration by removing legacy Android SDK version checks - Remove unnecessary `@SuppressLint` annotations and `@Volatile` modifiers - Improve performance of collection operations in `ProductFragment` and `Preferences` using `associateBy` and `firstOrNull` - Suppress deprecation warnings for `getOpacity` in `DrawableWrapper` and `TabsFragment` - Clean up service binding logic in `Connection.kt` with better type casting
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package com.michatec.store.utility
|
||||
|
||||
import android.animation.ValueAnimator
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.pm.Signature
|
||||
import android.content.res.Configuration
|
||||
@@ -67,17 +66,11 @@ object Utils {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SuspiciousIndentation")
|
||||
fun configureLocale(context: Context): Context {
|
||||
val supportedLanguages = BuildConfig.LANGUAGES.toSet()
|
||||
val configuration = context.resources.configuration
|
||||
val currentLocales = if (Android.sdk(24)) {
|
||||
val localesList = configuration.locales
|
||||
(0 until localesList.size()).map(localesList::get)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
listOf(configuration.locale)
|
||||
}
|
||||
val localesList = configuration.locales
|
||||
val currentLocales = (0 until localesList.size()).map(localesList::get)
|
||||
val compatibleLocales = currentLocales
|
||||
.filter { it.language in supportedLanguages }
|
||||
.let { it.ifEmpty { listOf(Locale.US) } }
|
||||
|
||||
Reference in New Issue
Block a user