This commit is contained in:
2024-08-14 00:04:53 +08:00
parent d5067ca05b
commit e8140579e0
9 changed files with 85 additions and 12 deletions

View File

@@ -1,5 +1,10 @@
package com.aiosman.riderpro.utils
import android.content.Context
import coil.ImageLoader
import coil.request.CachePolicy
import com.aiosman.riderpro.data.api.getUnsafeOkHttpClient
object Utils {
fun generateRandomString(length: Int): String {
val allowedChars = ('A'..'Z') + ('a'..'z') + ('0'..'9')
@@ -7,4 +12,15 @@ object Utils {
.map { allowedChars.random() }
.joinToString("")
}
fun getImageLoader(context: Context): ImageLoader {
val okHttpClient = getUnsafeOkHttpClient()
return ImageLoader.Builder(context)
.okHttpClient(okHttpClient)
.diskCachePolicy(CachePolicy.ENABLED)
.memoryCachePolicy(CachePolicy.ENABLED)
.components {
}
.build()
}
}