|
1 |
| -package com.xiasuhuei321.gank_kotlin.datasource.souce |
| 1 | +package com.xiasuhuei321.gank_kotlin.datasource |
2 | 2 |
|
3 |
| -import com.xiasuhuei321.gank_kotlin.datasource.code.Type |
| 3 | +import com.xiasuhuei321.gank_kotlin.datasource.bean.PostType |
4 | 4 | import com.xiasuhuei321.gank_kotlin.datasource.local.LocalDataImpl
|
5 |
| -import com.xiasuhuei321.gank_kotlin.datasource.remote.ServerDataImpl |
| 5 | +import com.xiasuhuei321.gank_kotlin.datasource.remote.RemoteDataImpl |
6 | 6 | import com.xiasuhuei321.gank_kotlin.extension.io_main
|
7 |
| -import io.reactivex.android.schedulers.AndroidSchedulers |
8 |
| -import io.reactivex.schedulers.Schedulers |
9 | 7 |
|
10 | 8 | /**
|
11 | 9 | * Created by xiasuhuei321 on 2017/8/11.
|
12 | 10 | * author:luo
|
13 | 11 |
|
14 | 12 | */
|
15 |
| -object DataSource { |
| 13 | +object DataSourceManager :DataSource { |
16 | 14 | val TAG: String = "DataSource"
|
17 |
| - val server = ServerDataImpl() |
| 15 | + val server = RemoteDataImpl() |
18 | 16 | val local = LocalDataImpl()
|
19 | 17 |
|
20 | 18 | /**
|
21 | 19 | * 从网络获取数据,保存数据
|
22 | 20 | */
|
23 | 21 | fun initData() {
|
24 |
| - server.getRemoteTechBeanStaredList(Type.WELFARE, 100, 1) |
| 22 | + server.getRemoteTechBeanStaredList(PostType.WELFARE, 100, 1) |
25 | 23 | .io_main()
|
26 | 24 | .subscribe({
|
27 | 25 |
|
28 | 26 | }, {
|
29 | 27 | e ->
|
30 | 28 | e.printStackTrace()
|
31 | 29 | })
|
32 |
| - server.getRemoteTechBeanStaredList(Type.WELFARE, 100, 1) |
33 |
| - .subscribeOn(Schedulers.newThread()) |
34 |
| - .observeOn(AndroidSchedulers.mainThread()) |
| 30 | + server.getRemoteTechBeanStaredList(PostType.WELFARE, 100, 1) |
| 31 | + .io_main() |
35 | 32 | .subscribe({
|
36 | 33 |
|
37 | 34 | }, {
|
38 | 35 | e ->
|
39 | 36 | e.printStackTrace()
|
40 | 37 | })
|
41 |
| - server.getRemoteTechBeanStaredList(Type.WELFARE, 100, 1) |
42 |
| - .subscribeOn(Schedulers.newThread()) |
43 |
| - .observeOn(AndroidSchedulers.mainThread()) |
| 38 | + server.getRemoteTechBeanStaredList(PostType.WELFARE, 100, 1) |
| 39 | + .io_main() |
44 | 40 | .subscribe({
|
45 | 41 |
|
46 | 42 | }, {
|
47 | 43 | e ->
|
48 | 44 | e.printStackTrace()
|
49 | 45 | })
|
50 |
| - server.getRemoteTechBeanStaredList(Type.WELFARE, 100, 1) |
51 |
| - .subscribeOn(Schedulers.newThread()) |
52 |
| - .observeOn(AndroidSchedulers.mainThread()) |
| 46 | + server.getRemoteTechBeanStaredList(PostType.WELFARE, 100, 1) |
| 47 | + .io_main() |
53 | 48 | .subscribe({
|
54 | 49 |
|
55 | 50 | }, {
|
|
0 commit comments