1
1
# IntentInject
2
- A easy API to transmit bundle at activity and fragment
2
+ A easy API of transmit bundle in activity and fragment
3
3
4
- ###引用:
4
+ [ 中文文档] ( https://github.com/yubaokang/IntentInject/blob/master/README-ZH.md )
5
+
6
+ ### dependencies:
5
7
6
8
#### top-level build.gradle
7
9
``` java
@@ -21,26 +23,26 @@ dependencies {
21
23
}
22
24
```
23
25
24
- ###如何使用 --类似于ButterKnife :
26
+ ### how to use -- just like ButterKnife :
25
27
26
- #### 在Activity使用 :
28
+ #### in Activity :
27
29
``` java
28
30
public class MainActivity extends AppCompatActivity {
29
31
@Extra
30
- String name;// 这种情况 "name"就是默认的key
32
+ String name;// "name"is the default key
31
33
@Extra
32
34
int age;
33
35
34
36
@Extra (" price" )
35
37
float price;
36
38
@Extra (" dou" )
37
39
double dou;
38
- @Extra (" test" )// Test 需要实现序列化 Parcelable或者Serializable都可以
40
+ @Extra (" test" )// Test need to implements Parcelable or Serializable
39
41
Test test;
40
42
41
43
@ExtraArrayString (" datas" )
42
44
ArrayList<String > datas;
43
- @ExtraArrayParcelable (" tests" )// Test 需要实现序列化 Parcelable或者Serializable都可以
45
+ @ExtraArrayParcelable (" tests" )
44
46
ArrayList<Test > tests;
45
47
@ExtraArrayInt (" ints" )
46
48
ArrayList<Integer > ints;
@@ -49,27 +51,27 @@ public class MainActivity extends AppCompatActivity {
49
51
protected void onCreate (Bundle savedInstanceState ) {
50
52
super . onCreate(savedInstanceState);
51
53
setContentView(R . layout. activity_main);
52
- IntentInject . inject(this );// 添加这行代码
54
+ IntentInject . inject(this );// add this line code
53
55
Toast . makeText(this , " name:" + name, Toast . LENGTH_LONG ). show();
54
56
}
55
57
}
56
58
```
57
59
58
- 记住一定要执行编译,否者无法生成MainActivity_Builder类
60
+ Remember building the project to generate MainActivity_Builder class
59
61
60
62
``` java
61
63
public class SplashActivity extends AppCompatActivity {
62
64
@Override
63
65
protected void onCreate (Bundle savedInstanceState ) {
64
66
super . onCreate(savedInstanceState);
65
67
setContentView(R . layout. activity_splash);
66
- // 传值并且跳转到
68
+ // transmit value and open MainActivity
67
69
MainActivity_Builder . intent(this ). name(" yubaokang" ). age(25 ). price(1.2f ). id(" idididid" ). start();
68
70
}
69
71
}
70
72
```
71
73
72
- #### 在Fragment使用,相对于在Activity中的注解,前面都加上Arg
74
+ #### in Fragment -- relative to Activity,just need to add "Arg"
73
75
``` java
74
76
public class BlankFragment1 extends Fragment {
75
77
@ArgExtra
@@ -82,13 +84,13 @@ public class BlankFragment1 extends Fragment {
82
84
@Override
83
85
public void onCreate (Bundle savedInstanceState ) {
84
86
super . onCreate(savedInstanceState);
85
- IntentInject . inject(this );// 添加这行代码
87
+ IntentInject . inject(this );// add this line code
86
88
Toast . makeText(this , " name:" + name, Toast . LENGTH_LONG ). show();
87
89
}
88
90
}
89
91
```
90
92
91
- 创建Fragment
93
+ create Fragment
92
94
``` java
93
95
BlankFragment1_Builder . builder(). name(" yubaokang" ). age(" 25" ). build();
94
96
```
0 commit comments