Hello, I've a question. When I click the button, e...
# android
h
Hello, I've a question. When I click the button, encrypted's value changes, but for body isn't changed. Retrofit always saves previous values of encrypted. Is it depend on Retrofit? If yes, how can I clear caches? class RemoteDataSource @Inject constructor() { companion object { var string: String?=null fun setEncr(string: String){ this.string=string } fun getEncr():String{ return this.string!! } } private fun getRetrofitClient( context: Context? = null): OkHttpClient { val authenticator:Authenticator?=null val encryp= getEncr() val body = "{\r\n\"Data\":\"${encryp}\"\r\n}" .toRequestBody("application/json; charset=utf-8".toMediaTypeOrNull()) return OkHttpClient.Builder() .cache(null) .addInterceptor { chain -> chain.proceed(chain.request().newBuilder().also { it.addHeader("Accept", "application/json") it.method("POST", body) }.build()) }.also { client -> authenticator?.let { client.authenticator(it) } if (BuildConfig.DEBUG) { val logging = HttpLoggingInterceptor() logging.setLevel(HttpLoggingInterceptor.Level.BODY) client.addInterceptor(logging) } }.build() } } in MainActivity binding.buttonLogin.setOnClickListener { val clientId = binding.edittxtClientId.text.toString().trim() encrypted = encrypt(clientId, publicKey) setStr(encrypted) viewModel.loginResponse.observe(this, Observer { when (it) { is Resource.Success -> { ..... } }
😶 3
l
Hello @Hovhannes, please check the topic of this channel and move your messages to a better place accordingly. We want to limit this channel (and others in this Slack) to Kotlin related topics, because that's what most of us come for. Thanks for your understanding. Side note: Very long snippets like that one (that doesn't even have formatting?) flood the channel, burying other messages (especially on mobile), so please, try to keep messages short, and use threads (like that one) when you have a lot of details to share.