key removed from gradle properties moved to keys string

This commit is contained in:
2020-05-17 18:46:39 +01:00
parent 62f0b6d9da
commit 154d674de4
2 changed files with 7 additions and 3 deletions

View File

@@ -24,7 +24,7 @@ class AppClass : Application(), KodeinAware {
// instance() can be context or other binding created
bind() from singleton { NetworkConnectionInterceptor(instance()) }
bind() from singleton { QueryInterceptor() }
bind() from singleton { QueryInterceptor(instance()) }
bind() from singleton { CurrencyApi(instance(),instance()) }
bind() from singleton { PreferenceProvider(instance()) }
bind() from singleton { RepositoryImpl(instance(), instance(), instance()) }

View File

@@ -1,6 +1,8 @@
package com.appttude.h_mal.easycc.data.network.interceptors
import android.content.Context
import com.appttude.h_mal.easycc.BuildConfig
import com.appttude.h_mal.easycc.R
import okhttp3.HttpUrl
import okhttp3.Interceptor
import okhttp3.Request
@@ -10,14 +12,16 @@ import okhttp3.Response
* Interceptor used in CurrencyApi
* Adds apiKey to query parameters
*/
class QueryInterceptor() : Interceptor {
class QueryInterceptor(
val context: Context
) : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
val original: Request = chain.request()
val originalHttpUrl: HttpUrl = original.url()
val url = originalHttpUrl.newBuilder()
.addQueryParameter("apiKey", "a4f93cc2ff05dd772321")
.addQueryParameter("apiKey", context.getString(R.string.apiKey))
.build()
// Add amended Url back to request