Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions BenchmarkDemo/app/build.gradle
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -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'
Expand All @@ -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'
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
Expand Down
19 changes: 7 additions & 12 deletions BenchmarkDemo/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">

<TextView
android:text="@string/value_prop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
/>
android:text="@string/value_prop" />

<LinearLayout
android:layout_width="match_parent"
Expand All @@ -23,21 +21,19 @@
android:id="@+id/btn_parse_tests"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:text="@string/parse_benchmark"
/>
android:layout_weight="1"
android:text="@string/parse_benchmark" />

<Button
android:id="@+id/btn_serialize_tests"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:text="@string/serialize_benchmark"
/>
android:layout_weight="1"
android:text="@string/serialize_benchmark" />
</LinearLayout>

<ScrollView
Expand All @@ -49,8 +45,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
/>
android:layout_marginRight="8dp" />

</ScrollView>

Expand Down
6 changes: 2 additions & 4 deletions BenchmarkDemo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}

Expand Down
4 changes: 2 additions & 2 deletions BenchmarkDemo/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
#Sat May 28 19:07:57 CEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 your 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

Expand Down
2 changes: 1 addition & 1 deletion docs/TypeConverters.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public enum TestEnum {
public class EnumConverter extends StringBasedTypeConverter<TestEnum> {
@Override
public TestEnum getFromString(String s) {
TestEnum.valueOf(s);
return TestEnum.valueOf(s);
}

public String convertToString(TestEnum object) {
Expand Down