Skip to content

Commit e8c674a

Browse files
committed
see 12/06 log
1 parent 67eab93 commit e8c674a

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

utilcode/README-STATIC-BUS.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ api "com.blankj:utilcode:1.22.1"
3333
比如 module0 中存在的 `Module0Activity.java`,我们通常都是在它内部写一个 `start` 函数来启动它,现在我们给它添加 `@BusUtils.Subscribe` 注解,并给注解的 `name` 赋唯一值,要注意,函数务必要 `public static` 哦:
3434

3535
```java
36+
// java
3637
public class Module0Activity extends Activity {
3738

3839
@BusUtils.Subscribe(name = "startModule0")
@@ -44,12 +45,31 @@ public class Module0Activity extends Activity {
4445
return true;
4546
}
4647
}
48+
49+
// kotlin
50+
class Module0Activity : Activity() {
51+
52+
companion object {
53+
@BusUtils.Subscribe(name = "startModule0")
54+
fun start(context: Context, name: String, age: Int): Boolean {
55+
val starter = Intent(context, Module0Activity::class.java)
56+
starter.putExtra("name", name)
57+
starter.putExtra("age", age)
58+
context.startActivity(starter)
59+
return true
60+
}
61+
}
62+
}
4763
```
4864

4965
在其他模块通过 `BusUtils.post("startModule0", Context, String, int)` 即可访问到它,一定要注意 `name` 之后的参数顺序和个数一定要和前面声明的函数相一致,其返回值也就是前面函数的返回值:
5066

5167
```java
68+
// java
5269
boolean result = BusUtils.post("startModule0", context, "blankj", 18);
70+
71+
// kotlin
72+
val result = BusUtils.post("startModule0", context, "blankj", 18)
5373
```
5474

5575
点击编译之后会在该 application 模块中生成 `__bus__.json` 文件
@@ -65,6 +85,8 @@ boolean result = BusUtils.post("startModule0", context, "blankj", 18);
6585

6686
参看本项目的组件化即可。
6787

88+
主要文件:settings.gradle
89+
6890

6991

7092

utilcode/lib/src/main/java/com/blankj/utilcode/util/BusUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* blog : http://blankj.com
1515
* time : 2018/10/02
1616
* desc : utils about bus, and the site of
17-
* https://github.com/Blankj/AndroidUtilCode/utilcode/README-STATIC-BUS.md
17+
* https://github.com/Blankj/AndroidUtilCode/blob/master/utilcode/README-STATIC-BUS.md
1818
* will help u.
1919
* </pre>
2020
*/

0 commit comments

Comments
 (0)