From 09187cf2d734ad2fc37e2037ac824e9431aadb19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Marti=CC=81n?= Date: Fri, 31 Oct 2014 12:49:59 +0100 Subject: [PATCH] Releasing version 1.1.3, fixed bug which made methods with primitive parameters unfindable --- CHANGELOG.md | 1 + README.md | 11 ++++++++++- SwissKnife/SwissKnife.iml | 4 +++- SwissKnife/build.gradle | 2 +- .../com/arasthel/swissknife/SwissKnife.groovy | 14 ++++++++++++-- SwissKnifeProject.iml | 2 +- gradle.properties | 4 ++-- sample/sample.iml | 2 +- 8 files changed, 31 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9373810..4b0839e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog: ### Versions: +* **1.1.3** - Fixed minor bug where methods with primitive parameters weren't found on method search. * **1.1.2** - Fixed BIG bug when SwissKnife couldn't find the method. * **1.1.1** - @OnBackground and @OnUIThread now can be used with static methods. Solved several method search problems, too. * **1.1.0** - New @SaveInstance annotation to automatically save and restore variables on configuration changes. diff --git a/README.md b/README.md index 196db15..a7a523b 100644 --- a/README.md +++ b/README.md @@ -84,10 +84,19 @@ Once your project App Module is configured to use Groovy you can add this librar ```groovy dependencies { ... - compile 'com.arasthel:swissknife:1.1.2' + compile 'com.arasthel:swissknife:1.1.3' ... } +``` + +If you want *SwissKnife* to update automatically, you could just type: +```groovy +dependencies { + ... + compile 'com.arasthel:swissknife:+' + ... +} ``` Also, [there is an IntelliJ IDEA plugin](https://github.com/Arasthel/SwissKnife/wiki/SwissKnife-IDEA-Plugin) *compatible with Android Studio* that lets you auto-generate the annotations and compatible method declarations. diff --git a/SwissKnife/SwissKnife.iml b/SwissKnife/SwissKnife.iml index 0901614..83ece12 100644 --- a/SwissKnife/SwissKnife.iml +++ b/SwissKnife/SwissKnife.iml @@ -1,5 +1,5 @@ - + @@ -79,7 +79,9 @@ + + diff --git a/SwissKnife/build.gradle b/SwissKnife/build.gradle index 4156b2a..338297e 100644 --- a/SwissKnife/build.gradle +++ b/SwissKnife/build.gradle @@ -10,7 +10,7 @@ android { minSdkVersion 8 targetSdkVersion 21 versionCode 1 - versionName "1.1.1" + versionName "1.1.3" } buildTypes { release { diff --git a/SwissKnife/src/main/groovy/com/arasthel/swissknife/SwissKnife.groovy b/SwissKnife/src/main/groovy/com/arasthel/swissknife/SwissKnife.groovy index 0d414fc..68ce759 100644 --- a/SwissKnife/src/main/groovy/com/arasthel/swissknife/SwissKnife.groovy +++ b/SwissKnife/src/main/groovy/com/arasthel/swissknife/SwissKnife.groovy @@ -19,7 +19,10 @@ import com.arasthel.swissknife.utils.AnnotationUtils import com.arasthel.swissknife.annotations.OnPageChanged import com.arasthel.swissknife.annotations.OnTextChanged import groovy.transform.CompileStatic +import org.codehaus.groovy.ast.ClassHelper import org.codehaus.groovy.ast.Parameter +import org.codehaus.groovy.runtime.wrappers.GroovyObjectWrapper +import org.codehaus.groovy.runtime.wrappers.Wrapper import java.lang.reflect.Method import java.lang.reflect.Modifier @@ -432,6 +435,11 @@ public class SwissKnife { boolean found = true for(int i = 0; i < m.getParameterTypes().length; i++) { Class parameter = m.getParameterTypes()[i] + + // If parameter is a primitive, we have to get its wrapper class so we can check for inheritance + if(parameter.isPrimitive()) { + parameter = getWrapperForPrimitive(parameter) + } if(!parameter.isAssignableFrom(parameters[i])) { found = false } @@ -452,6 +460,10 @@ public class SwissKnife { return method; } + private static Class getWrapperForPrimitive(Class primitive) { + return ClassHelper.getWrapper(ClassHelper.make(primitive)).getTypeClass(); + } + public static void restoreState(Object target, Bundle state) { if(state != null){ @@ -470,6 +482,4 @@ public class SwissKnife { } - - } \ No newline at end of file diff --git a/SwissKnifeProject.iml b/SwissKnifeProject.iml index a9d756f..cd9abe4 100644 --- a/SwissKnifeProject.iml +++ b/SwissKnifeProject.iml @@ -1,5 +1,5 @@ - + diff --git a/gradle.properties b/gradle.properties index d83ab9b..ac15bb1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,8 +17,8 @@ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -VERSION_NAME=1.1.2 -VERSION_CODE=8 +VERSION_NAME=1.1.3 +VERSION_CODE=9 GROUP=com.arasthel POM_DESCRIPTION=Android library for View Injection and Async processing diff --git a/sample/sample.iml b/sample/sample.iml index 98b13aa..c7080e1 100644 --- a/sample/sample.iml +++ b/sample/sample.iml @@ -1,5 +1,5 @@ - +