Skip to content

Commit

Permalink
add ViewBinder
Browse files Browse the repository at this point in the history
  • Loading branch information
milovetingting committed Mar 4, 2020
1 parent 0cb9433 commit 53ea671
Show file tree
Hide file tree
Showing 49 changed files with 1,144 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@ Gradle自定义插件

### 11、Loader

基于接口,通过隔离层,实现解耦的网络请求、图片加载的简单Demo,主要是体验封装的流程、思想
基于接口,通过隔离层,实现解耦的网络请求、图片加载的简单Demo,主要是体验封装的流程、思想

### 12、ViewBinder

基于APT实现的类似ButterKnife的控件绑定的简单Demo。
14 changes: 14 additions & 0 deletions ViewBinder/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
113 changes: 113 additions & 0 deletions ViewBinder/.idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions ViewBinder/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions ViewBinder/.idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions ViewBinder/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions ViewBinder/.idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ViewBinder/Binder/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
8 changes: 8 additions & 0 deletions ViewBinder/Binder/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apply plugin: 'java-library'

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
}

sourceCompatibility = "7"
targetCompatibility = "7"
17 changes: 17 additions & 0 deletions ViewBinder/Binder/src/main/java/com/wangyz/binder/IBinder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.wangyz.binder;

/**
* @author wangyz
* @time 2020/3/3 8:59
* @description IBinder
*/
public interface IBinder<T> {

/**
* 绑定activity
*
* @param t
*/
void bind(T t);

}
19 changes: 19 additions & 0 deletions ViewBinder/Binder/src/main/java/com/wangyz/binder/ViewBinder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.wangyz.binder;

/**
* @author wangyz
* @time 2020/3/3 9:46
* @description ViewBinder
*/
public class ViewBinder {
public static void bind(Object activity) {
String name = activity.getClass().getName() + "_ViewBinding";
try {
Class<?> clazz = Class.forName(name);
IBinder binder = (IBinder) clazz.newInstance();
binder.bind(activity);
} catch (Exception e) {
e.printStackTrace();
}
}
}
1 change: 1 addition & 0 deletions ViewBinder/annotation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
8 changes: 8 additions & 0 deletions ViewBinder/annotation/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apply plugin: 'java-library'

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
}

sourceCompatibility = "7"
targetCompatibility = "7"
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.wangyz.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* @author wangyz
* @time 2020/3/3 8:46
* @description BindView
*/

@Target(ElementType.FIELD)
@Retention(RetentionPolicy.SOURCE)
public @interface BindView {
int value();
}
1 change: 1 addition & 0 deletions ViewBinder/annotation_compiler/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
13 changes: 13 additions & 0 deletions ViewBinder/annotation_compiler/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apply plugin: 'java-library'

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(path: ':annotation')

//注册APT功能
annotationProcessor 'com.google.auto.service:auto-service:1.0-rc4'
compileOnly 'com.google.auto.service:auto-service:1.0-rc4'
}

sourceCompatibility = "7"
targetCompatibility = "7"
Loading

0 comments on commit 53ea671

Please sign in to comment.