Skip to content

Commit

Permalink
Merge pull request #35 from kittinunf/release/0.6
Browse files Browse the repository at this point in the history
0.6 - Modularize fuel
  • Loading branch information
Kittinun committed Nov 17, 2015
2 parents c8625b2 + 5cda4e5 commit 554c9fa
Show file tree
Hide file tree
Showing 53 changed files with 798 additions and 376 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ gen/

# Local configuration file (sdk path, etc)
local.properties
gradle.properties

# Eclipse project files
.classpath
Expand All @@ -24,6 +25,7 @@ local.properties
# Bintray
install.gradle
bintray.gradle
bintray_push

# Android Studio
.idea/
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Fuel

[ ![Kotlin](https://img.shields.io/badge/Kotlin-1.0.0--beta--1038-blue.svg)](http://kotlinlang.org) [ ![jcenter](https://api.bintray.com/packages/kittinunf/maven/Fuel/images/download.svg) ](https://bintray.com/kittinunf/maven/Fuel/_latestVersion) [![Build Status](https://travis-ci.org/kittinunf/Fuel.svg?branch=master)](https://travis-ci.org/kittinunf/Fuel)
[ ![Kotlin](https://img.shields.io/badge/Kotlin-1.0.0--beta--1103-blue.svg)](http://kotlinlang.org) [ ![jcenter](https://api.bintray.com/packages/kittinunf/maven/Fuel-Android/images/download.svg) ](https://bintray.com/kittinunf/maven/Fuel-Android/_latestVersion) [![Build Status](https://travis-ci.org/kittinunf/Fuel.svg?branch=master)](https://travis-ci.org/kittinunf/Fuel)

The easiest HTTP networking library in Kotlin for Android.

Expand All @@ -26,7 +26,8 @@ buildscript {
}
dependencies {
compile 'fuel:fuel:0.57'
compile 'com.github.kittinunf.fuel:fuel:0.6' //for JVM
compile 'com.github.kittinunf.fuel:fuel-android:0.6' //for Android
}
```

Expand Down Expand Up @@ -235,6 +236,14 @@ Fuel.upload("/post").source { request, url ->
File.createTempFile("temp", ".tmp");
}.responseString { request, response, either ->

}

//by default upload use Method.POST, unless it is specified as something else
Fuel.upload("/put", Method.PUT).source { request, url ->
File.createTempFile("temp", ".tmp");
}.responseString { request, response, either ->
// calls to http://example.com/api/put with PUT

}
```

Expand Down
7 changes: 5 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'

classpath 'com.github.dcendents:android-maven-plugin:1.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
classpath 'com.novoda:bintray-release:0.3.4'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
ext {
publishVersion = '0.6'
}

repositories {
jcenter()
}
Expand Down
1 change: 1 addition & 0 deletions fuel-android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
85 changes: 85 additions & 0 deletions fuel-android/build.gradle
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'
}
17 changes: 17 additions & 0 deletions fuel-android/proguard-rules.pro
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 *;
#}
5 changes: 5 additions & 0 deletions fuel-android/src/main/AndroidManifest.xml
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>
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))
}
}
}
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)
}

}

}
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);
}

}
Loading

0 comments on commit 554c9fa

Please sign in to comment.