1
1
package com.xiasuhuei321.gank_kotlin.datasource
2
2
3
+ import android.util.Log
4
+ import com.xiasuhuei321.gank_kotlin.app
3
5
import com.xiasuhuei321.gank_kotlin.datasource.bean.GankData
6
+ import com.xiasuhuei321.gank_kotlin.datasource.bean.JsonResult
4
7
import com.xiasuhuei321.gank_kotlin.datasource.bean.Weather
5
8
import com.xiasuhuei321.gank_kotlin.datasource.local.LocalDataSource
6
9
import com.xiasuhuei321.gank_kotlin.datasource.local.LocalDataSourceImpl
7
10
import com.xiasuhuei321.gank_kotlin.datasource.remote.RemoteDataSource
8
11
import com.xiasuhuei321.gank_kotlin.datasource.remote.RemoteDataSourceImpl
12
+ import com.xiasuhuei321.gank_kotlin.extension.handleResult
13
+ import com.xiasuhuei321.gank_kotlin.extension.io_main
9
14
import io.reactivex.Observable
15
+ import io.reactivex.functions.Function
10
16
11
17
/* *
12
18
* Created by coderFan on 2017/8/11.
@@ -32,11 +38,14 @@ object DataSourceImpl : DataSource {
32
38
}
33
39
34
40
override fun getData (type : String ): Observable <List <GankData >> {
35
- TODO ( " 获取数据,进行网络请求,加载失败再从本地读取缓存 " )
41
+ return getRemoteData(type, 10 , 1 )
36
42
}
37
43
38
- override fun getRemoteData (type : String , pageIndex : Int , count : Int ): Observable <List <GankData >> {
39
- TODO (" not implemented" ) // To change body of created functions use File | Settings | File Templates.
44
+ override fun getRemoteData (type : String , count : Int , pageIndex : Int ): Observable <List <GankData >> {
45
+ return remote
46
+ .getRemoteData(type,10 ,1 )
47
+ .compose(handleResult())
48
+ .io_main()
40
49
}
41
50
42
51
/* *
0 commit comments