Hello Guys, am new to jet pack Compose and this is...
# compose
k
Hello Guys, am new to jet pack Compose and this is the error am facing, on my Phone my app can display images from my backend server, but on my Tab it displays a black screen am using the coil library to load images, and am not understanding why is there any specific library I should use for images to display on tablets, let me attach the screenshot
c
Using coil to load images? Enable debug logging in coil, and see what logs show up on the tablet. although... it does seem like the header image loads. so thats a good sign.
👍 1
f
trust any ssl:
Copy code
fun getUnsafeClient(): OkHttpClient {
    val trustAllCerts: Array<TrustManager> = arrayOf(
        object : X509TrustManager {
            @Throws(CertificateException::class)
            override fun checkClientTrusted(chain: Array<X509Certificate>, authType: String) {
            }

            @Throws(CertificateException::class)
            override fun checkServerTrusted(chain: Array<X509Certificate>, authType: String) {
            }

            override fun getAcceptedIssuers(): Array<X509Certificate> {
                return arrayOf()
            }
        }
    )
    val sslContext = SSLContext.getInstance("SSL")
    sslContext.init(null, trustAllCerts, SecureRandom())
    val sslSocketFactory: SSLSocketFactory = sslContext.socketFactory
    val okHttpClientBuilder = OkHttpClient.Builder()
    okHttpClientBuilder.sslSocketFactory(sslSocketFactory, trustAllCerts[0] as X509TrustManager)
    okHttpClientBuilder.hostnameVerifier { _, _ -> true }
    return okHttpClientBuilder.build()
}
Copy code
actual fun imageLoader(context: Any?): ImageLoader  {
    val insecureOkHttpClient = getUnsafeClient()

    // Create a Call.Factory using the insecure client
    val callFactory = OkHttpClientCallFactory(insecureOkHttpClient)

    // Create an ImageLoader using the insecure client
    return ImageLoader.Builder(context as Context)
        .components {
            add(
                OkHttpNetworkFetcherFactory({
                    OkHttpClient.Builder().build()
                })
            )
        }
        .build()
}

class OkHttpClientCallFactory(private val client: OkHttpClient) : Call.Factory {
    override fun newCall(request: okhttp3.Request): Call {
        return client.newCall(request)
    }
}