33
33
import android .widget .Toast ;
34
34
35
35
import com .jiang .android .rxjavaapp .actiity .MainActivity ;
36
+ import com .jiang .android .rxjavaapp .common .CommonString ;
37
+ import com .jiang .android .rxjavaapp .common .OperatorsUrl ;
36
38
import com .jiang .android .rxjavaapp .common .SPKey ;
39
+ import com .jiang .android .rxjavaapp .database .alloperators ;
37
40
import com .jiang .android .rxjavaapp .database .helper .DbUtil ;
38
41
import com .jiang .android .rxjavaapp .database .operators ;
39
42
import com .jiang .android .rxjavaapp .utils .L ;
@@ -65,14 +68,16 @@ public void call(Subscriber<? super Boolean> subscriber) {
65
68
66
69
try {
67
70
List <operators > lists = getOperatorsData ();
71
+ List <alloperators > alloperatorses = getAllOperators ();
68
72
DbUtil .getOperatorsService ().save (lists );
73
+ DbUtil .getAllOperatorsService ().save (alloperatorses );
69
74
subscriber .onNext (true );
70
75
subscriber .onCompleted ();
71
76
} catch (Exception e ) {
72
77
subscriber .onError (e );
73
78
}
74
79
}
75
- }).subscribeOn (Schedulers .computation ()).observeOn (AndroidSchedulers .mainThread ()).subscribe (new Subscriber <Boolean >() {
80
+ }).subscribeOn (Schedulers .io ()).observeOn (AndroidSchedulers .mainThread ()).subscribe (new Subscriber <Boolean >() {
76
81
@ Override
77
82
public void onCompleted () {
78
83
Toast .makeText (InitDataService .this , "数据库初始化成功" , Toast .LENGTH_SHORT ).show ();
@@ -98,38 +103,63 @@ public void onNext(Boolean operatorss) {
98
103
99
104
public List <operators > getOperatorsData () {
100
105
List <operators > lists = new ArrayList <>();
101
- lists .add (new operators (0l , "Creating" , 1l ));
102
- lists .add (new operators (1l , "Transforming" , 2l ));
103
- lists .add (new operators (2l , "Filtering" , 3l ));
104
- lists .add (new operators (3l , "Combining" , 4l ));
105
- lists .add (new operators (4l , "Error Handling" , 5l ));
106
- lists .add (new operators (5l , "Utility" , 6l ));
107
- lists .add (new operators (6l , "Conditional" , 7l ));
108
- lists .add (new operators (7l , "Mathematical" , 8l ));
109
- lists .add (new operators (8l , "Async" , 9l ));
110
- lists .add (new operators (9l , "Connect" , 10l ));
111
- lists .add (new operators (10l , "Convert" , 11l ));
112
- lists .add (new operators (11l , "Blocking" , 12l ));
113
- lists .add (new operators (12l , "String" , 13l ));
106
+ lists .add (new operators (1l , "RxJava介绍" , 1l ));
107
+ lists .add (new operators (2l , "Creating" , 2l ));
108
+ lists .add (new operators (3l , "Transforming" , 3l ));
109
+ lists .add (new operators (4l , "Filtering" , 4l ));
110
+ lists .add (new operators (5l , "Combining" , 5l ));
111
+ lists .add (new operators (6l , "Error Handling" , 6l ));
112
+ lists .add (new operators (7l , "Utility" , 7l ));
113
+ lists .add (new operators (8l , "Conditional" , 8l ));
114
+ lists .add (new operators (9l , "Mathematical" , 9l ));
115
+ lists .add (new operators (10l , "Async" , 10l ));
116
+ lists .add (new operators (11l , "Connect" , 11l ));
117
+ lists .add (new operators (12l , "Convert" , 12l ));
118
+ lists .add (new operators (13l , "Blocking" , 13l ));
119
+ lists .add (new operators (14l , "String" , 14l ));
114
120
return lists ;
115
121
}
122
+
116
123
/**
117
- *
118
- *
119
124
* Creating 创建操作 - Create/Defer/From/Just/Start/Repeat/Range
120
- Transforming 变换操作 - Buffer/Window/Map/FlatMap/GroupBy/Scan
121
- Filtering 过滤操作 - Debounce/Distinct/Filter/Sample/Skip/Take
122
- Combining 结合操作 - And/StartWith/Join/Merge/Switch/Zip
123
- Error Handling 错误处理 - Catch/Retry
124
- Utility 辅助操作 - Delay/Do/ObserveOn/SubscribeOn/Subscribe
125
- Conditional 条件和布尔操作 - All/Amb/Contains/SkipUntil/TakeUntil
126
- Mathematical 算术和聚合操作 - Average/Concat/Count/Max/Min/Sum/Reduce
127
- Async 异步操作 - Start/ToAsync/StartFuture/FromAction/FromCallable/RunAsync
128
- Connect 连接操作 - Connect/Publish/RefCount/Replay
129
- Convert 转换操作 - ToFuture/ToList/ToIterable/ToMap/toMultiMap
130
- Blocking 阻塞操作 - ForEach/First/Last/MostRecent/Next/Single/Latest
131
- String 字符串操作 - ByLine/Decode/Encode/From/Join/Split/StringConcat
125
+ * Transforming 变换操作 - Buffer/Window/Map/FlatMap/GroupBy/Scan
126
+ * Filtering 过滤操作 - Debounce/Distinct/Filter/Sample/Skip/Take
127
+ * Combining 结合操作 - And/StartWith/Join/Merge/Switch/Zip
128
+ * Error Handling 错误处理 - Catch/Retry
129
+ * Utility 辅助操作 - Delay/Do/ObserveOn/SubscribeOn/Subscribe
130
+ * Conditional 条件和布尔操作 - All/Amb/Contains/SkipUntil/TakeUntil
131
+ * Mathematical 算术和聚合操作 - Average/Concat/Count/Max/Min/Sum/Reduce
132
+ * Async 异步操作 - Start/ToAsync/StartFuture/FromAction/FromCallable/RunAsync
133
+ * Connect 连接操作 - Connect/Publish/RefCount/Replay
134
+ * Convert 转换操作 - ToFuture/ToList/ToIterable/ToMap/toMultiMap
135
+ * Blocking 阻塞操作 - ForEach/First/Last/MostRecent/Next/Single/Latest
136
+ * String 字符串操作 - ByLine/Decode/Encode/From/Join/Split/StringConcat
137
+ */
138
+
139
+ public List <alloperators > getAllOperators () {
140
+
141
+ List <alloperators > alloperatorses = new ArrayList <>();
142
+ getIntroduceList (alloperatorses );
143
+ return alloperatorses ;
144
+ }
145
+
146
+ private void getIntroduceList (List <alloperators > alloperatorses ) {
147
+ alloperatorses .add (new alloperators (1l , "ReactiveX" , "什么是Rx,Rx的理念和优势" , CommonString .SPLASH_INDEX_URL , OperatorsUrl .INTRODUCE , 1l ));
148
+ alloperatorses .add (new alloperators (2l , "Observables" , "简要介绍Observable的观察者模型" , CommonString .OBSERVABLES , OperatorsUrl .OBSERVABLES , 1l ));
149
+ alloperatorses .add (new alloperators (3l , "Single" , "一种特殊的只发射单个值的Observable" , CommonString .SPLASH_INDEX_URL , OperatorsUrl .SINGLE , 1l ));
150
+ alloperatorses .add (new alloperators (4l , "Subject" , "Observable和Observer的复合体,也是二者的桥梁" , CommonString .SUBJECT , OperatorsUrl .SUBJECT , 1l ));
151
+ alloperatorses .add (new alloperators (5l , "Scheduler" , "介绍了各种异步任务调度和默认调度器" , CommonString .SPLASH_INDEX_URL , OperatorsUrl .SCHEDULE , 1l ));
152
+
153
+ }
154
+
155
+
156
+ /**
132
157
*
133
158
*
159
+ * ReactiveX - 什么是Rx,Rx的理念和优势
160
+ Observables - 简要介绍Observable的观察者模型
161
+ Single - 一种特殊的只发射单个值的Observable
162
+ Subject - Observable和Observer的复合体,也是二者的桥梁
134
163
*/
164
+
135
165
}
0 commit comments