Skip to content

Commit 064c1af

Browse files
committed
Releasing version 1.1.1
@OnBackground and @OnUIThread now work on static methods. Method search can now find private methods and looks for compatible, not exact matches. Updated gradle files to latest dependencies.
1 parent a21003a commit 064c1af

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+385
-66
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion

README.md

Lines changed: 8 additions & 1 deletion

SwissKnife/SwissKnife.iml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="com.arasthel" external.system.module.version="1.0.4" type="JAVA_MODULE" version="4">
2+
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="com.arasthel" external.system.module.version="1.1.1" type="JAVA_MODULE" version="4">
33
<component name="FacetManager">
44
<facet type="android-gradle" name="Android-Gradle">
55
<configuration>
@@ -10,9 +10,10 @@
1010
<configuration>
1111
<option name="SELECTED_BUILD_VARIANT" value="debug" />
1212
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
13-
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugJava" />
13+
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
1414
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
1515
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
16+
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" />
1617
<option name="ALLOW_USER_CONFIGURATION" value="false" />
1718
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
1819
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
@@ -38,23 +39,25 @@
3839
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />
3940
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
4041
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
42+
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
4143
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
42-
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" isTestSource="false" />
4344
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
4445
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
4546
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
4647
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
4748
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
49+
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
4850
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
49-
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" isTestSource="false" />
5051
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
52+
<sourceFolder url="file://$MODULE_DIR$/src/main/groovy" isTestSource="false" />
5153
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
5254
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
5355
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
5456
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
57+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
5558
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
56-
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" isTestSource="true" />
5759
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
60+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/groovy" isTestSource="true" />
5861
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
5962
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
6063
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
@@ -79,11 +82,11 @@
7982
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
8083
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
8184
</content>
82-
<orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" />
85+
<orderEntry type="jdk" jdkName="Android API 21 Platform (1)" jdkType="Android SDK" />
8386
<orderEntry type="sourceFolder" forTests="false" />
87+
<orderEntry type="library" exported="" name="support-annotations-21.0.0" level="project" />
88+
<orderEntry type="library" exported="" name="support-v4-21.0.0" level="project" />
8489
<orderEntry type="library" exported="" name="groovy-2.4.0-beta-3-grooid" level="project" />
85-
<orderEntry type="library" exported="" name="support-annotations-20.0.0" level="project" />
86-
<orderEntry type="library" exported="" name="support-v4-20.0.0" level="project" />
8790
</component>
8891
</module>
8992

SwissKnife/build.gradle

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,16 @@
1-
buildscript {
2-
repositories {
3-
mavenLocal()
4-
jcenter()
5-
}
6-
dependencies {
7-
classpath 'com.android.tools.build:gradle:0.12.+'
8-
classpath 'me.champeau.gradle:gradle-groovy-android-plugin:0.3.0'
9-
}
10-
}
11-
121
apply plugin: 'com.android.library'
132
apply plugin: 'me.champeau.gradle.groovy-android'
143

154
android {
16-
compileSdkVersion 19
5+
compileSdkVersion 21
176
buildToolsVersion "20.0.0"
187

198
defaultConfig {
209
applicationId "com.arasthel.swissknife"
2110
minSdkVersion 8
22-
targetSdkVersion 19
11+
targetSdkVersion 21
2312
versionCode 1
24-
versionName "1.0.1"
13+
versionName "1.1.1"
2514
}
2615
buildTypes {
2716
release {
@@ -42,9 +31,8 @@ repositories {
4231
dependencies {
4332
compile fileTree(dir: 'libs', include: ['*.jar'])
4433
compile 'org.codehaus.groovy:groovy:2.4.0-beta-3:grooid'
45-
compile 'com.android.support:support-v4:20.0.0'
34+
compile 'com.android.support:support-v4:21.0.0'
4635
}
4736

4837
// Script to upload plugin to Maven
4938
apply from: '../maven_push.gradle'
50-

SwissKnife/src/main/java/com/arasthel/swissknife/SwissKnife.groovy renamed to SwissKnife/src/main/groovy/com/arasthel/swissknife/SwissKnife.groovy

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public class SwissKnife {
3636

3737
public static void inject(Object target) {
3838
Method method = null;
39-
Method[] methods = null;
4039
try {
4140
method = SwissKnife.searchMethod(target, "injectViews", [Object.class]);
4241
} catch (NoSuchMethodException e) {
@@ -414,10 +413,40 @@ public class SwissKnife {
414413

415414
Method method = null;
416415

417-
try {
418-
method = currentObject.class.getMethod(name, parameters);
419-
} catch (NoSuchMethodException e) {
420-
return null;
416+
// We use a set so methods can't appear twice in here
417+
Set<Method> methods = new HashSet<>()
418+
if(currentObject instanceof Class) {
419+
methods.addAll(currentObject.getMethods())
420+
// Search for private methods, too
421+
methods.addAll(currentObject.getDeclaredMethods())
422+
} else {
423+
methods.addAll(currentObject.class.getMethods())
424+
// Search for private methods, too
425+
methods.addAll(currentObject.class.getDeclaredMethods())
426+
}
427+
428+
// As getMethod(...) doesn't search for a compatible but an exact match, we have to search manually
429+
for(Method m : methods) {
430+
if(m.getName() == name) {
431+
if(m.getParameterTypes().length == parameters.length) {
432+
boolean found = true
433+
for(int i = 0; i < m.getParameterTypes().length; i++) {
434+
Class parameter = m.getParameterTypes()[i]
435+
if(!parameter.isAssignableFrom(parameters[i])) {
436+
found = false
437+
}
438+
}
439+
if(found == true) {
440+
method = m
441+
break
442+
}
443+
}
444+
}
445+
}
446+
447+
// If method is private (shouldn't be), we make it accessible
448+
if(!method.isAccessible()) {
449+
method.setAccessible(true)
421450
}
422451

423452
return method;

SwissKnife/src/main/java/com/arasthel/swissknife/annotations/InjectView.groovy renamed to SwissKnife/src/main/groovy/com/arasthel/swissknife/annotations/InjectView.groovy

File renamed without changes.

SwissKnife/src/main/java/com/arasthel/swissknife/annotations/InjectViewTransformation.groovy renamed to SwissKnife/src/main/groovy/com/arasthel/swissknife/annotations/InjectViewTransformation.groovy

File renamed without changes.

SwissKnife/src/main/java/com/arasthel/swissknife/annotations/InjectViews.groovy renamed to SwissKnife/src/main/groovy/com/arasthel/swissknife/annotations/InjectViews.groovy

File renamed without changes.

SwissKnife/src/main/java/com/arasthel/swissknife/annotations/InjectViewsTransformation.groovy renamed to SwissKnife/src/main/groovy/com/arasthel/swissknife/annotations/InjectViewsTransformation.groovy

File renamed without changes.

SwissKnife/src/main/java/com/arasthel/swissknife/annotations/OnBackground.groovy renamed to SwissKnife/src/main/groovy/com/arasthel/swissknife/annotations/OnBackground.groovy

File renamed without changes.

0 commit comments

Comments
 (0)