Skip to content

Commit

Permalink
🎨 💄 Apply final touch (#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
kittinunf authored Apr 30, 2018
1 parent 5f1d550 commit 6c597ad
Show file tree
Hide file tree
Showing 13 changed files with 160 additions and 139 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ before_script:

script:
- ./gradlew test --stacktrace

after_success:
- ./gradlew jacocoTestReport
- bash <(curl -s https://codecov.io/bash)
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ buildscript {
publishVersion = '1.12.1'

//dependencies version
kotlinVersion = '1.2.31'
kotlinVersion = '1.2.40'
resultVersion = '1.4.0'
rxjavaVersion = '2.1.12'
archLifecycleVersion = "1.1.1"
Expand Down Expand Up @@ -31,7 +31,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.2'
classpath 'com.novoda:bintray-release:0.8.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
Expand Down
12 changes: 7 additions & 5 deletions fuel-coroutines/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ sourceSets {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutinesVersion"
implementation project(':fuel')
testImplementation project(':fuel-jackson')
testImplementation "junit:junit:$junitVersion"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutinesVersion"

compile project(':fuel')

testCompile project(':fuel-jackson')
testCompile "junit:junit:$junitVersion"
}

kotlin {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
import com.github.kittinunf.fuel.core.Deserializable
import com.github.kittinunf.fuel.core.FuelError
import com.github.kittinunf.fuel.core.Request
import com.github.kittinunf.fuel.core.Response
import com.github.kittinunf.fuel.core.ResponseDeserializable
import com.github.kittinunf.fuel.core.Request.Companion.byteArrayDeserializer
import com.github.kittinunf.fuel.core.Request.Companion.stringDeserializer
import com.github.kittinunf.fuel.core.Response
import com.github.kittinunf.fuel.core.ResponseDeserializable
import com.github.kittinunf.fuel.core.response
import com.github.kittinunf.result.Result
import kotlinx.coroutines.experimental.suspendCancellableCoroutine
import java.nio.charset.Charset

private suspend fun <T : Any, U : Deserializable<T>> Request.await(
deserializable: U
deserializable: U
): Triple<Request, Response, Result<T, FuelError>> =
suspendCancellableCoroutine { continuation ->
continuation.invokeOnCompletion {
if (continuation.isCancelled) {
continuation.cancel()
suspendCancellableCoroutine { continuation ->
continuation.invokeOnCompletion {
if (continuation.isCancelled) {
continuation.cancel()
}
}
}

response(deserializable) { request: Request, response: Response, result: Result<T, FuelError> ->
result.fold({
continuation.resume(Triple(request, response, result))
}, {
continuation.resumeWithException(it.exception)
})
response(deserializable) { request: Request, response: Response, result: Result<T, FuelError> ->
result.fold({
continuation.resume(Triple(request, response, result))
}, {
continuation.resumeWithException(it.exception)
})
}
}
}

suspend fun Request.awaitResponse(): Triple<Request, Response, Result<ByteArray, FuelError>> =
await(byteArrayDeserializer())
await(byteArrayDeserializer())

suspend fun Request.awaitString(
charset: Charset = Charsets.UTF_8
charset: Charset = Charsets.UTF_8
): Triple<Request, Response, Result<String, FuelError>> = await(stringDeserializer(charset))

suspend fun <U : Any> Request.awaitObject(
deserializable: ResponseDeserializable<U>
deserializable: ResponseDeserializable<U>
): Triple<Request, Response, Result<U, FuelError>> = await(deserializable)

suspend fun Request.awaitResponseResult(): ByteArray = awaitResponse().third.get()

suspend fun Request.awaitStringResult(
charset: Charset = Charsets.UTF_8
charset: Charset = Charsets.UTF_8
): String = awaitString(charset).third.get()

suspend fun <U : Any> Request.awaitObjectResult(
deserializable: ResponseDeserializable<U>
deserializable: ResponseDeserializable<U>
): U = await(deserializable).third.get()
5 changes: 3 additions & 2 deletions fuel-forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ sourceSets {
}

dependencies {
compile project(':fuel')
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
compile "com.github.kittinunf.forge:forge:$forgeVersion"

compile project(':fuel')

testCompile "junit:junit:$junitVersion"
}

Expand All @@ -32,4 +33,4 @@ publish {
publishVersion = publishVersion
uploadName = 'Fuel-Android'
website = 'https://github.com/kittinunf/Fuel'
}
}
6 changes: 4 additions & 2 deletions fuel-gson/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ sourceSets {
}

dependencies {
compile "com.google.code.gson:gson:$gsonVersion"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
compile "com.google.code.gson:gson:$gsonVersion"

compile project(':fuel')

testCompile "junit:junit:$junitVersion"
}

Expand All @@ -31,4 +33,4 @@ publish {
publishVersion = publishVersion
uploadName = 'Fuel-Android'
website = 'https://github.com/kittinunf/Fuel'
}
}
6 changes: 3 additions & 3 deletions fuel-jackson/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}


sourceSets {
main.java.srcDirs += 'src/main/kotlin'
test.java.srcDirs += 'src/test/kotlin'
}

dependencies {
compile "com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonVersion"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
compile "com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonVersion"

compile project(':fuel')

testCompile "junit:junit:$junitVersion"
}


jacocoTestReport {
reports {
html.enabled = false
Expand Down
4 changes: 3 additions & 1 deletion fuel-livedata/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ jacocoAndroidUnitTestReport {
}

dependencies {
compile "android.arch.lifecycle:extensions:$archLifecycleVersion"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
compile "android.arch.lifecycle:extensions:$archLifecycleVersion"

compile project(':fuel')

testCompile "junit:junit:$junitVersion"
testCompile "org.robolectric:robolectric:$robolectricVersion"
}
Expand Down
5 changes: 3 additions & 2 deletions fuel-moshi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ sourceSets {
}

dependencies {
compile project(':fuel')
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
compile "com.squareup.moshi:moshi-kotlin:$moshiVersion"

compile project(':fuel')

testCompile "junit:junit:$junitVersion"
}

Expand All @@ -32,4 +33,4 @@ publish {
publishVersion = publishVersion
uploadName = 'Fuel-Android'
website = 'https://github.com/kittinunf/Fuel'
}
}
7 changes: 2 additions & 5 deletions sample-java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.android.support:appcompat-v7:$androidSupportVersion"

compile "com.android.support:appcompat-v7:$androidSupportVersion"

compile project(':fuel-android')
api project(':fuel-android')
}

40 changes: 25 additions & 15 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,35 @@ android {
}

dependencies {
compile "com.android.support:appcompat-v7:$androidSupportVersion"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
compile "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinCoroutinesVersion"
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile project(':fuel-rxjava')
compile project(':fuel-android')
compile project(':fuel-livedata')
compile project(':fuel-gson')
compile project(':fuel-coroutines')

androidTestCompile "com.android.support:support-annotations:$androidSupportVersion"
androidTestCompile "com.android.support.test:runner:$runnerVersion"
androidTestCompile "com.android.support.test:rules:$rulesVersion"
androidTestCompile "com.android.support.test.espresso:espresso-core:$espressoVersion"
androidTestCompile "com.android.support.test.espresso:espresso-intents:$espressoVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"

implementation "com.android.support:appcompat-v7:$androidSupportVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinCoroutinesVersion"
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'

api project(':fuel-rxjava')
api project(':fuel-android')
api project(':fuel-livedata')
api project(':fuel-gson')
api project(':fuel-coroutines')

androidTestImplementation "com.android.support:support-annotations:$androidSupportVersion"
androidTestImplementation "com.android.support.test:runner:$runnerVersion"
androidTestImplementation "com.android.support.test:rules:$rulesVersion"
androidTestImplementation "com.android.support.test.espresso:espresso-core:$espressoVersion"
androidTestImplementation "com.android.support.test.espresso:espresso-intents:$espressoVersion"
}

kotlin {
experimental {
coroutines "enable"
}
}

configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'android.arch.lifecycle') {
details.useVersion '1.1.1'
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ class MainActivityTest {
@Test
fun testItDisplaysRequestInformationFromCoroutineCall() {
onView(withId(R.id.mainGoCoroutineButton))
.perform(click())
.perform(click())

Thread.sleep(4000) // Wait network to finish call the ugly way

onView(withId(R.id.mainResultText))
.check(matches(not(withText(""))))
.check(matches(not(withText(""))))
}

}
Loading

0 comments on commit 6c597ad

Please sign in to comment.