Skip to content

Commit

Permalink
Migrate to Android API Level 28 and AndroidX (kittinunf#561)
Browse files Browse the repository at this point in the history
* Migrate to Android API Level 28 and AndroidX

* Fixed LiveData Test
  • Loading branch information
iNoles authored Dec 17, 2018
1 parent 296ee2e commit 9c983f6
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 49 deletions.
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ env:
android:
components:
- tools
- build-tools-27.0.3
- android-27
- extra-android-support
- extra-android-m2repository
- build-tools-28.0.3
- android-28
licenses:
- android-sdk-license-.+

Expand Down
40 changes: 22 additions & 18 deletions buildSrc/src/main/kotlin/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ object Fuel {
const val publishVersion = "1.16.0"
const val groupId = "com.github.kittinunf.fuel"

const val compileSdkVersion = 27
const val compileSdkVersion = 28
const val minSdkVersion = 19
}

Expand All @@ -27,33 +27,37 @@ object Json {
}

object Android {
const val version = "3.1.3"
const val version = "3.2.1"
const val appPlugin = "com.android.application"
const val libPlugin = "com.android.library"

object Support {
const val version = "27.1.1"
val annotation = "com.android.support:support-annotations:$version"
val appCompat = "com.android.support:appcompat-v7:$version"
}

object Arch {
const val version = "1.1.1"
const val extensions = "android.arch.lifecycle:extensions:$version"
const val testingCore = "android.arch.core:core-testing:$version"
}
}

object AndroidX {
val annotation = "androidx.annotation:annotation:1.0.1"
val appCompat = "androidx.appcompat:appcompat:1.0.2"

object Arch {
const val version = "2.0.0"
const val extensions = "androidx.lifecycle:lifecycle-extensions:$version"
}

object Espresso {
const val version = "3.0.0"
const val core = "com.android.support.test.espresso:espresso-core:$version"
const val intents = "com.android.support.test.espresso:espresso-intents:$version"
object Espresso {
const val version = "3.1.0"
const val core = "androidx.test.espresso:espresso-core:$version"
const val intents = "androidx.test.espresso:espresso-intents:$version"
}

// Testing dependencies
object Test {
const val rulesVersion = "1.0.0"
const val runnerVersion = "1.0.0"
val rules = "com.android.support.test:rules:$rulesVersion"
val runner = "com.android.support.test:runner:$runnerVersion"
const val rulesVersion = "1.1.0"
const val junitVersion = "1.0.0"
const val rules = "androidx.test:rules:$rulesVersion"
const val junit = "androidx.test.ext:junit:$junitVersion"
}
}

Expand Down Expand Up @@ -106,7 +110,7 @@ object RxJava {

object Android {
const val version = "2.1.0"
val dependency = "io.reactivex.rxjava2:rxandroid:$version"
const val dependency = "io.reactivex.rxjava2:rxandroid:$version"
}
}

Expand Down
4 changes: 3 additions & 1 deletion fuel-livedata/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
dependencies {
api(project(":fuel"))
implementation(Kotlin.stdlib)
implementation(Android.Arch.extensions)
implementation(AndroidX.Arch.extensions)
testImplementation(RoboElectric.dependency)
testImplementation(JUnit.dependency)
testImplementation(project(":fuel-test"))
testImplementation(Android.Arch.testingCore)
testImplementation(AndroidX.Test.junit)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.kittinunf.fuel.livedata

import android.arch.lifecycle.LiveData
import android.arch.lifecycle.MutableLiveData
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.github.kittinunf.fuel.core.Deserializable
import com.github.kittinunf.fuel.core.FuelError
import com.github.kittinunf.fuel.core.Request
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
package com.github.kittinunf.fuel.livedata

import android.arch.core.executor.testing.InstantTaskExecutorRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.github.kittinunf.fuel.Fuel
import com.github.kittinunf.fuel.core.ResponseDeserializable
import com.github.kittinunf.fuel.test.MockHttpTestCase
import com.github.kittinunf.result.Result
import org.hamcrest.CoreMatchers.instanceOf
import org.hamcrest.CoreMatchers.notNullValue
import org.hamcrest.MatcherAssert.assertThat
import org.junit.Rule
import org.junit.runner.RunWith
import org.junit.Test
import java.net.HttpURLConnection

/**
* @see [Testing documentation](http://d.android.com/tools/testing)
*/
@RunWith(AndroidJUnit4::class)
class FuelLiveDataTest : MockHttpTestCase() {

@Rule
@JvmField
val rule = InstantTaskExecutorRule()

@Test
fun liveDataTestResponse() {
mock.chain(
Expand Down
22 changes: 7 additions & 15 deletions sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {

dependencies {
implementation(Kotlin.stdlib)
implementation(Android.Support.appCompat)
implementation(AndroidX.appCompat)
implementation(KotlinX.Coroutines.android)
implementation(RxJava.Android.dependency)

Expand All @@ -19,11 +19,11 @@ dependencies {
api(project(":fuel-gson"))
api(project(":fuel-coroutines"))

androidTestImplementation(Android.Support.annotation)
androidTestImplementation(Android.Test.runner)
androidTestImplementation(Android.Test.rules)
androidTestImplementation(Android.Espresso.core)
androidTestImplementation(Android.Espresso.intents)
androidTestImplementation(AndroidX.annotation)
androidTestImplementation(AndroidX.Test.junit)
androidTestImplementation(AndroidX.Test.rules)
androidTestImplementation(AndroidX.Espresso.core)
androidTestImplementation(AndroidX.Espresso.intents)
}

configure<BaseExtension> {
Expand All @@ -35,7 +35,7 @@ configure<BaseExtension> {
targetSdkVersion(Fuel.compileSdkVersion)
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

sourceSets {
Expand All @@ -55,11 +55,3 @@ configure<BaseExtension> {
exclude("META-INF/NOTICE.txt")
}
}

configurations.all {
resolutionStrategy.eachDependency {
if (requested.group == "android.arch.lifecycle") {
useVersion("1.1.1")
}
}
}
13 changes: 4 additions & 9 deletions sample/src/main/kotlin/com/example/fuel/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@ package com.example.fuel

import android.os.Bundle
import android.os.Handler
import android.support.v7.app.AppCompatActivity
import android.util.Log
import com.example.fuel.R.id.mainAuxText
import com.example.fuel.R.id.mainClearButton
import com.example.fuel.R.id.mainGoButton
import com.example.fuel.R.id.mainGoCoroutineButton
import com.example.fuel.R.id.mainResultText
import androidx.appcompat.app.AppCompatActivity
import com.github.kittinunf.fuel.coroutines.awaitStringResponseResult
import com.github.kittinunf.fuel.Fuel
import com.github.kittinunf.fuel.core.FileDataPart
Expand Down Expand Up @@ -179,7 +174,7 @@ class MainActivity : AppCompatActivity() {
private fun httpDownload() {
val n = 100
Fuel.download("/bytes/${1024 * n}")
.destination { _, _ -> File(filesDir, "test.tmp") }
.fileDestination { _, _ -> File(filesDir, "test.tmp") }
.progress { readBytes, totalBytes ->
val progress = "$readBytes / $totalBytes"
runOnUiThread { mainAuxText.text = progress }
Expand Down Expand Up @@ -216,13 +211,13 @@ class MainActivity : AppCompatActivity() {
.authentication()
.basic(username, password)
.also { Log.d(TAG, it.cUrlString()) }
.responseString { request, _, result -> update(result) }
.responseString { _, _, result -> update(result) }

"/basic-auth/$username/$password".httpGet()
.authentication()
.basic(username, password)
.also { Log.d(TAG, it.cUrlString()) }
.responseString { request, _, result -> update(result) }
.responseString { _, _, result -> update(result) }
}

private fun httpRxSupport() {
Expand Down

0 comments on commit 9c983f6

Please sign in to comment.