Skip to content

Commit 6aba493

Browse files
author
Karl
committed
删除无用代码
1 parent f124777 commit 6aba493

File tree

7 files changed

+33
-86
lines changed

7 files changed

+33
-86
lines changed

app/src/main/java/com/xiasuhuei321/gank_kotlin/MainActivity.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.os.Bundle
44
import android.support.v7.app.AppCompatActivity
55
import android.view.Window
66
import android.view.WindowManager
7+
import com.xiasuhuei321.gank_kotlin.datasource.DataSource
78
import com.xiasuhuei321.gank_kotlin.extension.shortToast
89
import kotlinx.android.synthetic.main.activity_main.*
910

@@ -14,7 +15,6 @@ class MainActivity : AppCompatActivity() {
1415
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
1516
WindowManager.LayoutParams.FLAG_FULLSCREEN)
1617
setContentView(R.layout.activity_main)
17-
1818
weatherIv.setOnClickListener {
1919
shortToast("weather icon be clicked")
2020
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,32 @@
11
package com.xiasuhuei321.gank_kotlin.datasource
22

3+
import com.xiasuhuei321.gank_kotlin.datasource.bean.PostType
4+
import com.xiasuhuei321.gank_kotlin.datasource.local.LocalDataImpl
5+
import com.xiasuhuei321.gank_kotlin.datasource.remote.RemoteDataImpl
6+
import com.xiasuhuei321.gank_kotlin.extension.LogUtil
7+
import com.xiasuhuei321.gank_kotlin.extension.io_main
8+
39
/**
4-
* Created by Karl on 2017/9/11 0011.
5-
*
10+
* Created by xiasuhuei321 on 2017/8/11.
11+
* author:luo
12+
613
*/
14+
object DataSource {
15+
val TAG: String = "DataSource"
16+
// val server = RemoteDataImpl()
17+
val local = LocalDataImpl()
18+
19+
fun getRemoteData(){
20+
RemoteDataImpl.INSTANCE
21+
.getRemoteData(PostType.ANDROID,10,1)
22+
.io_main()
23+
.subscribe({
24+
jsonResult-> LogUtil.d(jsonResult.toString())
25+
},{
26+
e-> e.printStackTrace()
27+
})
28+
29+
}
730

8-
interface DataSource{
931

10-
}
32+
}

app/src/main/java/com/xiasuhuei321/gank_kotlin/datasource/DataSourceManager.kt

-56
This file was deleted.

app/src/main/java/com/xiasuhuei321/gank_kotlin/datasource/net/ApiStore.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ interface ApiStore {
2222
@Path("count") count: String,
2323
@Path("pageIndex") pageIndex: String): Observable<TechBean>
2424

25-
@GET(API.DATA+"/{type}/{count}/{pageIndex}")
25+
@GET("data/{type}/{count}/{pageIndex}")
2626
fun getCategoricalData(
2727
@Path("type") type:String,
2828
@Path("count") count: String,

app/src/main/java/com/xiasuhuei321/gank_kotlin/datasource/remote/RemoteDataImpl.kt

+5-14
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,22 @@ import io.reactivex.Observable
1414
* author:luo
1515
1616
*/
17-
class RemoteDataImpl : RemoteDataSource {
17+
class RemoteDataImpl private constructor(): RemoteDataSource {
1818

1919
private var apiStore: ApiStore? = null
2020

2121
init {
22-
if (apiStore==null) ReHelper.getInstance().create(ApiStore::class.java)
22+
if (apiStore==null) apiStore = ReHelper.getInstance().create(ApiStore::class.java)
2323
}
2424

2525
companion object {
26-
val INSTANCE: RemoteDataImpl by lazy { this.INSTANCE }
26+
val INSTANCE:RemoteDataImpl by lazy { this.INSTANCE }
2727
}
2828

2929
override fun getRemoteData(type: String, count: Int, pageIndex: Int): Observable<JsonResult<List<GankData>>> {
30-
return apiStore!!.getCategoricalData(type,count.toString(),pageIndex.toString()).io_main()
30+
return apiStore!!.getCategoricalData(type,count.toString(),pageIndex.toString())
3131
}
3232

33-
override fun getRemoteTechBeanStaredList(type: String, count: Int, pageIndex: Int): Observable<TechBean> {
34-
// val retrofit = Retrofit.Builder()
35-
// .baseUrl("http://gank.io/api/")
36-
// .addConverterFactory(GsonConverterFactory.create())
37-
// .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
38-
// .build()
39-
val newCount = count.toString()
40-
val newPageIndex = pageIndex.toString()
41-
return apiStore!!.getData(type, newCount, newPageIndex)
42-
}
33+
4334

4435
}

app/src/main/java/com/xiasuhuei321/gank_kotlin/datasource/remote/RemoteDataSource.kt

-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import io.reactivex.Observable
1313
*/
1414
interface RemoteDataSource {
1515

16-
fun getRemoteTechBeanStaredList(type: String, count: Int, pageIndex: Int): Observable<TechBean>
17-
1816
//获取分类数据
1917
fun getRemoteData(type:String, count: Int,pageIndex: Int):Observable<JsonResult<List<GankData>>>
2018

app/src/main/java/com/xiasuhuei321/gank_kotlin/extension/RxExtension.kt

-8
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,3 @@ import java.util.function.Function
1818
fun <T> Observable<T>.io_main():Observable<T>{
1919
return subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
2020
}
21-
//
22-
//fun <T>Observable<T>.handleResult():ObservableTransformer<JsonResult<T>,T>{
23-
// return ObservableTransformer<JsonResult<T>,T>{
24-
// apply {
25-
//
26-
// }
27-
// }
28-
//}

0 commit comments

Comments
 (0)