Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

Commit

Permalink
Kotlin 1.3 migration (#55)
Browse files Browse the repository at this point in the history
Fixes #52
  • Loading branch information
mirland authored Nov 13, 2018
1 parent b96a9f6 commit 27c002e
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 31 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies {
implementation "com.google.code.gson:gson:${libraryVersion.gson}"
implementation "com.google.dagger:dagger-android-support:${libraryVersion.dagger}"
implementation "com.google.dagger:dagger:${libraryVersion.dagger}"
implementation "com.jakewharton.retrofit:retrofit2-kotlin-coroutines-experimental-adapter:${libraryVersion.kotlinCoroutinesRetrofitAdapter}"
implementation "com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:${libraryVersion.kotlinCoroutinesRetrofitAdapter}"
implementation "com.jakewharton.timber:timber:${libraryVersion.timber}"
implementation "com.squareup.okhttp3:logging-interceptor:${libraryVersion.okHttp}"
implementation "com.squareup.okhttp3:okhttp:${libraryVersion.okHttp}"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/xmartlabs/sample/di/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.facebook.stetho.okhttp3.StethoInterceptor
import com.google.gson.FieldNamingPolicy
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import com.jakewharton.retrofit2.adapter.kotlin.coroutines.experimental.CoroutineCallAdapterFactory
import com.jakewharton.retrofit2.adapter.kotlin.coroutines.CoroutineCallAdapterFactory
import com.xmartlabs.sample.db.AppDb
import com.xmartlabs.sample.service.UserService
import dagger.Module
Expand All @@ -32,7 +32,7 @@ class AppModule {
@Singleton
@Provides
fun provideOkHttpClient(): OkHttpClient {
val loggingInterceptor = HttpLoggingInterceptor { message -> Timber.tag("OkHttp").d(message) }
val loggingInterceptor = HttpLoggingInterceptor { Timber.tag("OkHttp").d(it) }
loggingInterceptor.level = HttpLoggingInterceptor.Level.BODY

return OkHttpClient.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.xmartlabs.sample.db.UserDao
import com.xmartlabs.sample.model.User
import com.xmartlabs.sample.model.service.GhListResponse
import com.xmartlabs.sample.service.UserService
import kotlinx.coroutines.experimental.Deferred
import kotlinx.coroutines.Deferred
import javax.inject.Inject
import javax.inject.Singleton

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.xmartlabs.sample.service
import com.xmartlabs.sample.model.User
import com.xmartlabs.sample.model.service.GhListResponse
import io.reactivex.Single
import kotlinx.coroutines.experimental.Deferred
import kotlinx.coroutines.Deferred
import retrofit2.Call
import retrofit2.http.GET
import retrofit2.http.Query
Expand Down
6 changes: 0 additions & 6 deletions fountain-coroutines/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ dependencies {
testImplementation project(':fountain-testutils')
}

kotlin {
experimental {
coroutines "enable"
}
}

dokka {
outputDirectory = "$buildDir/docs"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ import com.xmartlabs.fountain.coroutines.adapter.toBaseNetworkDataSourceAdapter
import com.xmartlabs.fountain.coroutines.common.toExecutor
import com.xmartlabs.fountain.feature.cachednetwork.CachedNetworkListingCreator
import com.xmartlabs.fountain.feature.network.NetworkPagedListingCreator
import kotlinx.coroutines.experimental.CoroutineDispatcher
import kotlinx.coroutines.experimental.CoroutineScope
import kotlinx.coroutines.experimental.Dispatchers
import kotlinx.coroutines.experimental.GlobalScope
import kotlinx.coroutines.experimental.IO
import kotlinx.coroutines.experimental.asCoroutineDispatcher
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.asCoroutineDispatcher

/** A [Listing] factory */
object FountainCoroutines {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import com.xmartlabs.fountain.ListResponseWithEntityCount
import com.xmartlabs.fountain.ListResponseWithPageCount
import com.xmartlabs.fountain.common.FountainConstants
import com.xmartlabs.fountain.common.KnownSizeResponseManager
import kotlinx.coroutines.experimental.CompletableDeferred
import kotlinx.coroutines.experimental.Deferred
import kotlinx.coroutines.experimental.runBlocking
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.runBlocking

/** A [CoroutineNetworkDataSourceAdapter] factory */
object CoroutineNetworkDataSourceAdapterFactory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.xmartlabs.fountain.coroutines.adapter

import com.xmartlabs.fountain.ListResponse
import com.xmartlabs.fountain.adapter.NetworkDataSourceAdapter
import kotlinx.coroutines.experimental.Deferred
import kotlinx.coroutines.Deferred

/**
* It's used to fetch each page from the service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.xmartlabs.fountain.adapter.BasePageFetcher
import com.xmartlabs.fountain.adapter.NetworkResultListener
import com.xmartlabs.fountain.common.BaseNetworkDataSourceAdapterFactory
import com.xmartlabs.fountain.common.notifyFromCallable
import kotlinx.coroutines.experimental.runBlocking
import kotlinx.coroutines.runBlocking

private fun <T : ListResponse<*>> CoroutinePageFetcher<T>.toBasePageFetcher(): BasePageFetcher<T> {
return object : BasePageFetcher<T> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.xmartlabs.fountain.coroutines.common

import kotlinx.coroutines.experimental.CoroutineDispatcher
import kotlinx.coroutines.experimental.CoroutineScope
import kotlinx.coroutines.experimental.launch
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import java.util.concurrent.Executor

internal fun CoroutineDispatcher.toExecutor(coroutineScope: CoroutineScope) = Executor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.xmartlabs.fountain.coroutines.adapter.NotPagedCoroutinePageFetcher
import com.xmartlabs.fountain.testutils.InstantExecutor
import com.xmartlabs.fountain.testutils.IntMockedCachedDataSourceAdapter
import com.xmartlabs.fountain.testutils.TestConstants
import kotlinx.coroutines.experimental.asCoroutineDispatcher
import kotlinx.coroutines.asCoroutineDispatcher

object IntMockedListingCreator {
fun createNetworkListing(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import com.xmartlabs.fountain.testutils.extensions.generateSpecificIntPageRespon
import com.xmartlabs.fountain.testutils.extensions.toListResponse
import com.xmartlabs.fountain.testutils.extensions.toListResponseEntityCount
import com.xmartlabs.fountain.testutils.extensions.toListResponsePageCount
import kotlinx.coroutines.experimental.CompletableDeferred
import kotlinx.coroutines.experimental.Deferred
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.Deferred

class MockedPageFetcher(var error: Boolean = false) : CoroutinePageFetcher<ListResponse<Int>> {
override fun fetchPage(page: Int, pageSize: Int) =
Expand Down
6 changes: 3 additions & 3 deletions versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ ext {
gson : '2.8.5',
jacoco : '0.12.0',
junit : '4.12',
kotlin : '1.2.71',
kotlinCoroutines : '0.26.0',
kotlinCoroutinesRetrofitAdapter: '1.0.0',
kotlin : '1.3.0',
kotlinCoroutines : '1.0.1',
kotlinCoroutinesRetrofitAdapter: '0.9.2',
mavenPlugin : '2.0',
mockito : '2.16.0',
okHttp : '3.10.0',
Expand Down

0 comments on commit 27c002e

Please sign in to comment.