Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add library-retrofit-legacy-adapter. Fixes #9
- Loading branch information
Showing
11 changed files
with
313 additions
and
1 deletion.
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
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,31 @@ | ||
apply plugin: 'com.android.library' | ||
|
||
// gradle.properties holds credentials and is not checked in | ||
def gradleProperties = new File('gradle.properties') | ||
if (gradleProperties.exists()) { | ||
apply from: 'maven-push.gradle' | ||
} | ||
|
||
|
||
android { | ||
compileSdkVersion 23 | ||
buildToolsVersion "23.0.1" | ||
|
||
defaultConfig { | ||
minSdkVersion 9 | ||
targetSdkVersion 23 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile 'com.squareup.retrofit:retrofit:1.9.0' | ||
} |
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,3 @@ | ||
POM_NAME=overpasser-retrofit-legacy-adapter | ||
POM_ARTIFACT_ID=overpasser-retrofit-legacy-adapter | ||
POM_PACKAGING=aar |
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,123 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2015 Zsolt Kocsi | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
apply plugin: 'maven' | ||
apply plugin: 'signing' | ||
|
||
def isReleaseBuild() { | ||
return VERSION_NAME.contains("SNAPSHOT") == false | ||
} | ||
|
||
def getReleaseRepositoryUrl() { | ||
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL | ||
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/" | ||
} | ||
|
||
def getSnapshotRepositoryUrl() { | ||
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL | ||
: "https://oss.sonatype.org/content/repositories/snapshots/" | ||
} | ||
|
||
def getRepositoryUsername() { | ||
return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : "" | ||
} | ||
|
||
def getRepositoryPassword() { | ||
return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : "" | ||
} | ||
|
||
afterEvaluate { project -> | ||
uploadArchives { | ||
repositories { | ||
mavenDeployer { | ||
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } | ||
|
||
pom.groupId = GROUP | ||
pom.artifactId = POM_ARTIFACT_ID | ||
pom.version = VERSION_NAME | ||
|
||
repository(url: getReleaseRepositoryUrl()) { | ||
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) | ||
} | ||
|
||
snapshotRepository(url: getSnapshotRepositoryUrl()) { | ||
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) | ||
} | ||
|
||
pom.project { | ||
name POM_NAME | ||
packaging POM_PACKAGING | ||
description POM_DESCRIPTION | ||
url POM_URL | ||
|
||
scm { | ||
url POM_SCM_URL | ||
connection POM_SCM_CONNECTION | ||
developerConnection POM_SCM_DEV_CONNECTION | ||
} | ||
|
||
licenses { | ||
license { | ||
name POM_LICENCE_NAME | ||
url POM_LICENCE_URL | ||
distribution POM_LICENCE_DIST | ||
} | ||
} | ||
|
||
developers { | ||
developer { | ||
id POM_DEVELOPER_ID | ||
name POM_DEVELOPER_NAME | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
task androidSourcesJar(type: Jar) { | ||
classifier = 'sources' | ||
from android.sourceSets.main.java.sourceFiles | ||
} | ||
|
||
task androidJavadocs(type: Javadoc) { | ||
source = android.sourceSets.main.java.sourceFiles | ||
classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) | ||
} | ||
|
||
task androidJavadocsJar(type: Jar) { | ||
classifier = 'javadoc' | ||
from androidJavadocs.destinationDir | ||
} | ||
|
||
artifacts { | ||
archives androidSourcesJar | ||
archives androidJavadocsJar | ||
} | ||
|
||
signing { | ||
required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") } | ||
sign configurations.archives | ||
} | ||
} |
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 /home/zzss/Apps/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 *; | ||
#} |
11 changes: 11 additions & 0 deletions
11
library-retrofit-legacy-adapter/src/main/AndroidManifest.xml
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,11 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="hu.supercluster.library_retrofit_legacy_adapter"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true"> | ||
|
||
</application> | ||
|
||
</manifest> |
80 changes: 80 additions & 0 deletions
80
...-legacy-adapter/src/main/java/hu/supercluster/overpasser/adapter/OverpassQueryResult.java
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,80 @@ | ||
package hu.supercluster.overpasser.adapter; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class OverpassQueryResult { | ||
@SerializedName("elements") | ||
public List<Element> elements = new ArrayList<>(); | ||
|
||
public static class Element { | ||
@SerializedName("type") | ||
public String type; | ||
|
||
@SerializedName("id") | ||
public long id; | ||
|
||
@SerializedName("lat") | ||
public double lat; | ||
|
||
@SerializedName("lon") | ||
public double lon; | ||
|
||
@SerializedName("tags") | ||
public Tags tags = new Tags(); | ||
|
||
public static class Tags { | ||
@SerializedName("type") | ||
public String type; | ||
|
||
@SerializedName("amenity") | ||
public String amenity; | ||
|
||
@SerializedName("name") | ||
public String name; | ||
|
||
@SerializedName("phone") | ||
public String phone; | ||
|
||
@SerializedName("contact:email") | ||
public String contactEmail; | ||
|
||
@SerializedName("website") | ||
public String website; | ||
|
||
@SerializedName("addr:city") | ||
public String addressCity; | ||
|
||
@SerializedName("addr:postcode") | ||
public String addressPostCode; | ||
|
||
@SerializedName("addr:street") | ||
public String addressStreet; | ||
|
||
@SerializedName("addr:housenumber") | ||
public String addressHouseNumber; | ||
|
||
@SerializedName("wheelchair") | ||
public String wheelchair; | ||
|
||
@SerializedName("wheelchair:description") | ||
public String wheelchairDescription; | ||
|
||
@SerializedName("opening_hours") | ||
public String openingHours; | ||
|
||
@SerializedName("internet_access") | ||
public String internetAccess; | ||
|
||
@SerializedName("fee") | ||
public String fee; | ||
|
||
@SerializedName("operator") | ||
public String operator; | ||
|
||
} | ||
} | ||
} | ||
|
9 changes: 9 additions & 0 deletions
9
...ofit-legacy-adapter/src/main/java/hu/supercluster/overpasser/adapter/OverpassService.java
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,9 @@ | ||
package hu.supercluster.overpasser.adapter; | ||
|
||
import retrofit.http.GET; | ||
import retrofit.http.Query; | ||
|
||
public interface OverpassService { | ||
@GET("/api/interpreter") | ||
OverpassQueryResult interpreter(@Query("data") String data); | ||
} |
34 changes: 34 additions & 0 deletions
34
...acy-adapter/src/main/java/hu/supercluster/overpasser/adapter/OverpassServiceProvider.java
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,34 @@ | ||
package hu.supercluster.overpasser.adapter; | ||
|
||
import com.google.gson.FieldNamingPolicy; | ||
import com.google.gson.Gson; | ||
import com.google.gson.GsonBuilder; | ||
|
||
import retrofit.RestAdapter; | ||
import retrofit.converter.GsonConverter; | ||
|
||
public class OverpassServiceProvider { | ||
private static OverpassService service; | ||
|
||
public static OverpassService get() { | ||
if (service == null) { | ||
service = createService(); | ||
} | ||
|
||
return service; | ||
} | ||
|
||
private static OverpassService createService() { | ||
Gson gson = new GsonBuilder() | ||
.setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE) | ||
.create() | ||
; | ||
|
||
RestAdapter restAdapter = new RestAdapter.Builder() | ||
.setEndpoint("http://overpass-api.de") | ||
.setConverter(new GsonConverter(gson)) | ||
.build(); | ||
|
||
return restAdapter.create(OverpassService.class); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
library-retrofit-legacy-adapter/src/main/res/values/strings.xml
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,3 @@ | ||
<resources> | ||
<string name="app_name">library-retrofit-legacy-adapter</string> | ||
</resources> |
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 |
---|---|---|
@@ -1 +1 @@ | ||
include ':sample', ':library', ':library-retrofit-adapter', ':tests' | ||
include ':sample', ':library', ':library-retrofit-adapter', ':tests', ':library-retrofit-legacy-adapter' |