This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2020-08-05 15:01:49.120 8677-8772/zoeknow.com.bossnow.dev E/FRESHCHAT: Exception on HMD Global Nokia 8.1 Android API 10 (29) >>>>> Not allowed to start service Intent { cmp=zoeknow.com.bossnow.dev/com.freshchat.consumer.sdk.service.FreshchatService }: app is in background uid UidRecord{9a7fdaf u0a219 CAC bg:+1m0s970ms idle change:cached procs:1 seq(0,0,0)} | |
java.lang.IllegalStateException: Not allowed to start service Intent { cmp=zoeknow.com.bossnow.dev/com.freshchat.consumer.sdk.service.FreshchatService }: app is in background uid UidRecord{9a7fdaf u0a219 CAC bg:+1m0s970ms idle change:cached procs:1 seq(0,0,0)} | |
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1616) | |
at android.app.ContextImpl.startService(ContextImpl.java:1571) | |
at android.content.ContextWrapper.startService(ContextWrapper.java:669) | |
at com.freshchat.consumer.sdk.service.FreshchatService.r(Unknown Source:7) | |
at com.freshchat.consumer.sdk.service.FreshchatService.a(Unknown Source:10) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val builder = OkHttpClient.Builder() | |
builder.addInterceptor(get<HttpLoggingInterceptor>()) | |
builder.addInterceptor(get<ApiInterceptor>()) | |
builder.protocols(listOf(Protocol.HTTP_1_1, Protocol.HTTP_2)) | |
var httpClient = builder.build() | |
Retrofit.Builder() | |
…(略) | |
.client(httpClient) // 加到 Retrofit | |
.build() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApiInterceptor : Interceptor { | |
override fun intercept(chain: Interceptor.Chain): Response { | |
var request = chain.request() | |
val url = request.url.newBuilder().addQueryParameter("api_key", BuildConfig.TMDB_API_KEY).build() | |
request = request.newBuilder().url(url).build() | |
return chain.proceed(request) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface MovieApiService { | |
@GET("movie/{list}") | |
fun fetchMovieList( | |
... | |
@Query("api_key") apiKey: String | |
): Single<TmdbApiResponse<MovieListResponse>> | |
@GET("movie/{movieId}") | |
fun fetchMovieDetail( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val builder = OkHttpClient.Builder() | |
builder.protocols(listOf(Protocol.HTTP_1_1, Protocol.HTTP_2)) | |
// TODO: set timeout, cache...etc. | |
val httpClient = builder.build() | |
Retrofit.Builder() | |
…(略) | |
.client(httpClient) // 加到 Retrofit | |
.build() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class MovieListResponse( | |
@SerializedName("id") | |
val id: String, | |
@SerializedName("poster_path") | |
val posterPath: String?, | |
@SerializedName("title") | |
val title: String?, | |
... | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface MovieApiService { | |
@GET("movie/{list}") | |
fun fetchMovieList( | |
@Path("list") list: String, | |
@Query("page") page: Int? = null | |
): Single<TmdbApiResponse<MovieListResponse>> | |
@GET("movie/{movieId}") | |
fun fetchMovieDetail(@Path("movieId") movieId: String): Single<MovieDetailResponse> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Retrofit.Builder() | |
.baseUrl(BuildConfig.API_ROOT) | |
.addCallAdapterFactory(RxJava2CallAdapterFactory.create()) | |
.addConverterFactory(GsonConverterFactory.create()) | |
.build() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Config { | |
const val API_ROOT = "\"https://api.themoviedb.org/3/\"" | |
const val STAGING_API_ROOT = "\"https://staging-api.themoviedb.org/3/\"" | |
} | |
productFlavors { | |
create("staging") { | |
buildConfigField("String", "API_ROOT", Config.STAGING_API_ROOT) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Config { | |
const val API_ROOT = "\"https://api.themoviedb.org/3/\"" | |
const val IMAGE_API_ROOT = "\"https://image.tmdb.org/t/p/\"" | |
} | |
defaultConfig { | |
... | |
buildConfigField("String", "API_ROOT", Config.API_ROOT) | |
buildConfigField("String", "TMDB_API_KEY", TMDB_API_KEY) |