From 0cc98dfff19c9b5711ea6be0cc5f0e1251772853 Mon Sep 17 00:00:00 2001 From: Antonina Date: Sat, 28 May 2016 18:39:00 +0200 Subject: [PATCH 1/4] Improved code example --- docs/TypeConverters.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/TypeConverters.md b/docs/TypeConverters.md index f095f47..c4b5f30 100644 --- a/docs/TypeConverters.md +++ b/docs/TypeConverters.md @@ -102,7 +102,7 @@ public enum TestEnum { public class EnumConverter extends StringBasedTypeConverter { @Override public TestEnum getFromString(String s) { - TestEnum.valueOf(s); + return TestEnum.valueOf(s); } public String convertToString(TestEnum object) { From 4073f0be608e3c74dc643364bb569bd8312fb35b Mon Sep 17 00:00:00 2001 From: Antonina Date: Sat, 28 May 2016 19:06:06 +0200 Subject: [PATCH 2/4] Improved README.md --- README.md | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b4ea9e1..5c1ade3 100644 --- a/README.md +++ b/README.md @@ -15,26 +15,46 @@ Don't believe it could improve upon Jackson Databind's or GSON's performance tha ##Download -Note that Gradle is the only supported build configuration for LoganSquare. To add the library to your app's build.gradle file. +Note that Gradle is the only supported build configuration for LoganSquare. It also needs an [apt plugin](https://bitbucket.org/hvisser/android-apt) plugin dependency, which allows us to do compile-time annotation processing. + +Add apt plugin as a classpath dependency in project's build.gradle file. ```groovy +// Top-level build file where you can add configuration options common to all sub-projects/modules. + buildscript { repositories { jcenter() } dependencies { + classpath 'com.android.tools.build:gradle:2.1.0' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' } } + +allprojects { + repositories { + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} +``` + +Apply apt plugin and add the dependencies to the app's module. + +```groovy apply plugin: 'com.neenbedankt.android-apt' dependencies { apt 'com.bluelinelabs:logansquare-compiler:1.3.6' compile 'com.bluelinelabs:logansquare:1.3.6' } - ``` -For the curious, the buildscript and apply plugin lines add the [apt plugin](https://bitbucket.org/hvisser/android-apt), which is what allows us to do compile-time annotation processing. The first dependency is what tells Gradle to process your JSON annotations, and the second dependency is our tiny 19kb runtime library that interfaces with the generated code for you. + +The first dependency is what tells Gradle to process your JSON annotations, and the second dependency is our tiny 19kb runtime library that interfaces with the generated code for you. ##Usage From c70cb1c49720206b7ee869c7e2d135317fc391b6 Mon Sep 17 00:00:00 2001 From: Antonina Date: Sat, 28 May 2016 19:06:33 +0200 Subject: [PATCH 3/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5c1ade3..183f8eb 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ task clean(type: Delete) { } ``` -Apply apt plugin and add the dependencies to the app's module. +Apply apt plugin and add the dependencies to your app's module. ```groovy apply plugin: 'com.neenbedankt.android-apt' From 6ac11ee711d02d26190cc7aac9d0cf87c7eeb465 Mon Sep 17 00:00:00 2001 From: Antonina Tkachuk Date: Sat, 28 May 2016 19:25:44 +0200 Subject: [PATCH 4/4] Libraries version increases. Minor refactoring. --- BenchmarkDemo/app/build.gradle | 16 +++------------- .../logansquare/demo/widget/BarChart.java | 3 ++- .../app/src/main/res/layout/activity_main.xml | 19 +++++++------------ BenchmarkDemo/build.gradle | 6 ++---- .../gradle/wrapper/gradle-wrapper.properties | 4 ++-- 5 files changed, 16 insertions(+), 32 deletions(-) diff --git a/BenchmarkDemo/app/build.gradle b/BenchmarkDemo/app/build.gradle index 8166b2b..f08e37a 100644 --- a/BenchmarkDemo/app/build.gradle +++ b/BenchmarkDemo/app/build.gradle @@ -1,13 +1,3 @@ -buildscript { - repositories { - jcenter() - } - dependencies { - classpath 'com.android.tools.build:gradle:1.3.0' - classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' - } -} - apply plugin: 'com.android.application' apply plugin: 'com.neenbedankt.android-apt' @@ -36,7 +26,7 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:23.1.1' + compile 'com.android.support:appcompat-v7:23.4.0' // LoganSquare annotation processor apt 'com.bluelinelabs:logansquare-compiler:1.3.6' @@ -48,8 +38,8 @@ dependencies { compile 'com.fasterxml.jackson.core:jackson-annotations:2.5.1' // GSON library for comparison - compile 'com.google.code.gson:gson:2.3.1' + compile 'com.google.code.gson:gson:2.4' - // Moshi library for camparison + // Moshi library for comparison compile 'com.squareup.moshi:moshi:1.0.0' } diff --git a/BenchmarkDemo/app/src/main/java/com/bluelinelabs/logansquare/demo/widget/BarChart.java b/BenchmarkDemo/app/src/main/java/com/bluelinelabs/logansquare/demo/widget/BarChart.java index 27d3184..8cc8026 100644 --- a/BenchmarkDemo/app/src/main/java/com/bluelinelabs/logansquare/demo/widget/BarChart.java +++ b/BenchmarkDemo/app/src/main/java/com/bluelinelabs/logansquare/demo/widget/BarChart.java @@ -12,6 +12,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Locale; /** Hacked together barchart view for this demo. Please do not take this as an example of a good way to do things. */ public class BarChart extends View { @@ -181,7 +182,7 @@ public String getTitle() { float medianTime = timings.get(timings.size() / 2); float maxTime = timings.get(timings.size() - 1); - return String.format("%s (median: %.2fms, min: %.2fms, max: %.2fms", title, medianTime, minTime, maxTime); + return String.format(Locale.getDefault(), "%s (median: %.2fms, min: %.2fms, max: %.2fms", title, medianTime, minTime, maxTime); } else { return title; } diff --git a/BenchmarkDemo/app/src/main/res/layout/activity_main.xml b/BenchmarkDemo/app/src/main/res/layout/activity_main.xml index 14f2776..951a10c 100644 --- a/BenchmarkDemo/app/src/main/res/layout/activity_main.xml +++ b/BenchmarkDemo/app/src/main/res/layout/activity_main.xml @@ -1,5 +1,4 @@ - + android:text="@string/value_prop" /> + android:layout_weight="1" + android:text="@string/parse_benchmark" />