-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from kittinunf/release/0.6
0.6 - Modularize fuel
- Loading branch information
Showing
53 changed files
with
798 additions
and
376 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'kotlin-android' | ||
|
||
apply plugin: 'com.novoda.bintray-release' | ||
|
||
repositories { | ||
jcenter() | ||
} | ||
|
||
android { | ||
compileSdkVersion 23 | ||
buildToolsVersion "23.0.1" | ||
|
||
defaultConfig { | ||
minSdkVersion 9 | ||
targetSdkVersion 23 | ||
versionCode 1 | ||
versionName parent.ext.publishVersion | ||
} | ||
|
||
sourceSets { | ||
main.java.srcDirs += 'src/main/kotlin' | ||
test.java.srcDirs += 'src/test/kotlin' | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_7 | ||
targetCompatibility JavaVersion.VERSION_1_7 | ||
} | ||
|
||
lintOptions { | ||
abortOnError false | ||
} | ||
|
||
testOptions { | ||
unitTests.returnDefaultValues = true | ||
} | ||
|
||
} | ||
|
||
dependencies { | ||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" | ||
|
||
compile project(':fuel') | ||
|
||
testCompile "junit:junit:$junit_version" | ||
testCompile "org.robolectric:robolectric:$robolectric_version" | ||
} | ||
|
||
buildscript { | ||
ext { | ||
//dependencies version | ||
kotlin_version = '1.0.0-beta-1103' | ||
|
||
//test dependencies version | ||
junit_version = '4.12' | ||
robolectric_version = '3.0' | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||
} | ||
} | ||
|
||
publish { | ||
artifactId = 'fuel-android' | ||
autoPublish = true | ||
desc = 'The easiest HTTP networking library in Kotlin/Android' | ||
groupId = 'com.github.kittinunf.fuel' | ||
licences = ['MIT'] | ||
publishVersion = parent.ext.publishVersion | ||
uploadName = 'Fuel-Android' | ||
website = 'https://github.com/kittinunf/Fuel' | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in /Users/kittinunf/Library/Android/sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<manifest package="com.github.kittinunf.fuel.android"> | ||
|
||
<!-- Libraries have no manifest --> | ||
|
||
</manifest> |
22 changes: 22 additions & 0 deletions
22
fuel-android/src/main/kotlin/com/github/kittinunf/fuel/android/extension/Requests.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.github.kittinunf.fuel.android.extension | ||
|
||
import com.github.kittinunf.fuel.core.* | ||
import org.json.JSONObject | ||
|
||
/** | ||
* Created by Kittinun Vantasin on 11/9/15. | ||
*/ | ||
|
||
//jsonObject | ||
public fun Request.responseJson(handler: (Request, Response, Either<FuelError, JSONObject>) -> Unit): Unit = | ||
response(jsonDeserializer(), handler) | ||
|
||
public fun Request.responseJson(handler: Handler<JSONObject>): Unit = response(jsonDeserializer(), handler) | ||
|
||
public fun jsonDeserializer(): Deserializable<JSONObject> { | ||
return object : Deserializable<JSONObject> { | ||
override fun deserialize(response: Response): JSONObject { | ||
return JSONObject(String(response.data)) | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
fuel-android/src/main/kotlin/com/github/kittinunf/fuel/android/util/AndroidEnvironment.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.github.kittinunf.fuel.android.util | ||
|
||
import android.os.Handler | ||
import android.os.Looper | ||
import com.github.kittinunf.fuel.core.Environment | ||
import java.util.concurrent.Executor | ||
|
||
/** | ||
* Created by Kittinun Vantasin on 11/9/15. | ||
*/ | ||
|
||
internal class AndroidEnvironment : Environment { | ||
|
||
val handler = Handler(Looper.getMainLooper()) | ||
|
||
override var callbackExecutor: Executor = object : Executor { | ||
|
||
override fun execute(command: Runnable?) { | ||
handler.post(command) | ||
} | ||
|
||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
fuel-android/src/test/kotlin/com/github/kittinunf/fuel/android/BaseTestCase.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.github.kittinunf.fuel.android | ||
|
||
import org.junit.runner.RunWith | ||
import org.robolectric.RobolectricGradleTestRunner | ||
import org.robolectric.annotation.Config | ||
import java.util.concurrent.CountDownLatch | ||
import java.util.concurrent.TimeUnit | ||
|
||
/** | ||
* Created by Kittinun Vantasin on 11/9/15. | ||
*/ | ||
|
||
@RunWith(RobolectricGradleTestRunner::class) | ||
@Config(constants = BuildConfig::class, sdk = intArrayOf(21)) | ||
abstract class BaseTestCase { | ||
|
||
val DEFAULT_TIMEOUT = 15L | ||
|
||
lateinit var lock: CountDownLatch | ||
|
||
fun await(seconds: Long = DEFAULT_TIMEOUT) { | ||
lock.await(seconds, TimeUnit.SECONDS); | ||
} | ||
|
||
} |
Oops, something went wrong.