Skip to content

Commit

Permalink
修复float装备精度问题
Browse files Browse the repository at this point in the history
  • Loading branch information
GordonGgx committed Sep 4, 2017
1 parent 393c79c commit 86de5c8
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion annotations/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'java'
apply plugin: 'com.github.dcendents.android-maven'
group='com.github.guanguoxiang'
project.archivesBaseName="Annotations"
project.archivesBaseName="annotations"

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
Expand Down
2 changes: 1 addition & 1 deletion annotations/src/main/java/com/ggx/annotation/FloatKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
public @interface FloatKey {

String name() default "";
float value() default 0;
float value() default 0f;

}
9 changes: 6 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ dependencies {
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
compile project(':sharepreference')
compile project(':annotations')
annotationProcessor project(':compiler')
// compile project(':sharepreference')
// compile project(':annotations')
// annotationProcessor project(':compiler')
compile 'com.github.guanguoxiang.EasySp:annotations:1.1'
compile 'com.github.guanguoxiang.EasySp:sharepreference:1.1'
annotationProcessor 'com.github.guanguoxiang.EasySp:compiler:1.1'
testCompile 'junit:junit:4.12'
}
12 changes: 12 additions & 0 deletions app/src/main/java/com/ggx/easysp/Cat.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ggx.easysp;

import com.ggx.annotation.BooleanKey;
import com.ggx.annotation.FloatKey;
import com.ggx.annotation.IntKey;
import com.ggx.annotation.SharePreference;
import com.ggx.annotation.StringKey;
Expand All @@ -21,6 +22,9 @@ public class Cat {
@BooleanKey
private boolean healthy;

@FloatKey
private float weight;

public String getName() {
return name;
}
Expand All @@ -44,4 +48,12 @@ public int getAge() {
public void setAge(int age) {
this.age = age;
}

public float getWeight() {
return weight;
}

public void setWeight(float weight) {
this.weight = weight;
}
}
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ buildscript {
allprojects {
repositories {
jcenter()
maven { url 'https://jitpack.io' }
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'java'
apply plugin: 'com.github.dcendents.android-maven'
group='com.github.guanguoxiang'
project.archivesBaseName="Compiler"
project.archivesBaseName="compiler"
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.auto.service:auto-service:1.0-rc2'
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/main/java/com/ggx/BindCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ private MethodSpec getReadMethod(TypeElement typeElement,RoundEnvironment roundE
spKey=name;
}
if(element.getModifiers().contains(Modifier.PRIVATE)){
readMethod.addStatement("obj.set$N(manager.getFloat($S,$L))",
readMethod.addStatement("obj.set$N(manager.getFloat($S,$Lf))",
captureName(simpleName),spKey,value);
}else {
readMethod.addStatement("obj.$N=manager.getFloat($S,$L)",
readMethod.addStatement("obj.$N=manager.getFloat($S,$Lf)",
simpleName,spKey,value);
}
}
Expand Down
2 changes: 1 addition & 1 deletion sharepreference/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
group='com.github.guanguoxiang'
project.archivesBaseName="SharePreference"
project.archivesBaseName="sharepreference"
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
Expand Down

0 comments on commit 86de5c8

Please sign in to comment.