Commit c37a1c6 1 parent 29adcd3 commit c37a1c6 Copy full SHA for c37a1c6
File tree 2 files changed +46
-2
lines changed
app/src/main/java/com/shizhefei/test/controllers/mvchelpers
mvchelper_tasks/src/main/java/com/shizhefei/task/datasource
2 files changed +46
-2
lines changed Original file line number Diff line number Diff line change 22
22
import com .handmark .pulltorefresh .library .PullToRefreshListView ;
23
23
import com .shizhefei .mvc .MVCHelper ;
24
24
import com .shizhefei .mvc .MVCPullrefshHelper ;
25
- // import com.shizhefei.task.datasource.DataSources;
25
+ import com .shizhefei .task .datasource .DataSources ;
26
26
import com .shizhefei .test .models .datasource .BooksDataSource ;
27
27
import com .shizhefei .test .models .enties .Book ;
28
28
import com .shizhefei .test .models .task .InitTokenTask ;
@@ -50,7 +50,7 @@ protected void onCreate(Bundle savedInstanceState) {
50
50
51
51
mvcHelper = new MVCPullrefshHelper <>(refreshListView );
52
52
// 设置数据源
53
- // mvcHelper.setDataSource(DataSources.concatWith(new InitTokenTask(), new BooksDataSource()));
53
+ mvcHelper .setDataSource (DataSources .concatWith (new InitTokenTask (), new BooksDataSource ()));
54
54
// 设置适配器
55
55
mvcHelper .setAdapter (new BooksAdapter (this ));
56
56
// 加载数据
Original file line number Diff line number Diff line change
1
+ package com .shizhefei .task .datasource ;
2
+
3
+ import com .shizhefei .mvc .IAsyncDataSource ;
4
+ import com .shizhefei .mvc .IDataSource ;
5
+ import com .shizhefei .task .IAsyncTask ;
6
+
7
+ /**
8
+ * Created by luckyjayce on 2017/4/17.
9
+ */
10
+
11
+ public class DataSources {
12
+
13
+ /**
14
+ * 先执行task,再执行dataSource,该函数会返回新的dataSource
15
+ * @param task
16
+ * @param dataSource
17
+ * @param <DATA>
18
+ * @return
19
+ */
20
+ public static <DATA > IAsyncDataSource <DATA > concatWith (IAsyncTask <Void > task , IAsyncDataSource <DATA > dataSource ) {
21
+ return new ConcatDataSource <>(task , dataSource );
22
+ }
23
+
24
+ /**
25
+ * 先执行task,再执行dataSource,该函数会返回新的dataSource
26
+ * @param task
27
+ * @param dataSource
28
+ * @param <DATA>
29
+ * @return
30
+ */
31
+ public static <DATA > IAsyncDataSource <DATA > concatWith (IAsyncTask <Void > task , IDataSource <DATA > dataSource ) {
32
+ return new ConcatDataSource <>(task , async (dataSource ));
33
+ }
34
+
35
+ /**
36
+ * 同步dataSource变为异步dataSource
37
+ * @param dataSource
38
+ * @param <DATA>
39
+ * @return
40
+ */
41
+ public static <DATA > IAsyncDataSource <DATA > async (IDataSource <DATA > dataSource ) {
42
+ return new AsyncDataSource <>(dataSource );
43
+ }
44
+ }
You can’t perform that action at this time.
0 commit comments