Skip to content

Commit 6fc93a2

Browse files
committed
style:change code style
1 parent 795632e commit 6fc93a2

17 files changed

+812
-60
lines changed

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

-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ 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.DataSourceImpl
87
import com.xiasuhuei321.gank_kotlin.extension.shortToast
98
import kotlinx.android.synthetic.main.activity_main.*
109

1110
class MainActivity : AppCompatActivity() {
12-
val data = DataSourceImpl()
1311
override fun onCreate(savedInstanceState: Bundle?) {
1412
super.onCreate(savedInstanceState)
1513
supportRequestWindowFeature(Window.FEATURE_NO_TITLE)

app/src/main/java/com/xiasuhuei321/gank_kotlin/Test.java

-18
This file was deleted.

app/src/main/java/com/xiasuhuei321/gank_kotlin/customview/weather/WeatherShapePool.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class WeatherShapePool {
5252
}
5353
}
5454

55-
private fun initSnow(){
55+
private fun initSnow() {
5656
val space = context.getScreenWidth() / 20
5757
var currentSpace = 0f
5858
// 将其均匀的分布在屏幕x方向上
@@ -72,12 +72,12 @@ class WeatherShapePool {
7272
}
7373
}
7474

75-
fun drawSnow(canvas: Canvas){
76-
for(r in constantSnow){
75+
fun drawSnow(canvas: Canvas) {
76+
for (r in constantSnow) {
7777
r.draw(canvas)
7878
}
7979

80-
for (r in randomSnow){
80+
for (r in randomSnow) {
8181
r.draw(canvas)
8282
}
8383
}
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
package com.xiasuhuei321.gank_kotlin.datasource
22

33
import com.xiasuhuei321.gank_kotlin.datasource.bean.GankData
4+
import com.xiasuhuei321.gank_kotlin.datasource.bean.Weather
45
import io.reactivex.Observable
56

67

78
/**
89
* Created by CoderFan on 2017/9/12.
910
* desc:
1011
*/
11-
interface DataSource{
12+
interface DataSource {
1213

13-
//获取Data
14-
fun getData(type:String): Observable<List<GankData>>
14+
// 获取Data
15+
fun getData(type: String): Observable<List<GankData>>
1516

16-
//获取服务器数据,每页数据默认为10, 页码默认为1
17-
fun getRemoteData(type: String,pageIndex:Int = 1,count:Int = 10):Observable<List<GankData>>
17+
// 获取服务器数据,每页数据默认为10, 页码默认为1
18+
fun getRemoteData(type: String, pageIndex: Int = 1, count: Int = 10): Observable<List<GankData>>
1819

19-
//清除本地指定缓存
20+
// 清除本地指定缓存
2021
fun clearData(type: String)
2122

22-
//清除本地所有缓存
23+
// 清除本地所有缓存
2324
fun clearAllData()
25+
26+
// 获取天气数据
27+
fun getWeatherData(): Weather
2428
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.xiasuhuei321.gank_kotlin.datasource
22

33
import com.xiasuhuei321.gank_kotlin.datasource.bean.GankData
4+
import com.xiasuhuei321.gank_kotlin.datasource.bean.Weather
45
import com.xiasuhuei321.gank_kotlin.datasource.local.LocalDataSource
56
import com.xiasuhuei321.gank_kotlin.datasource.local.LocalDataSourceImpl
67
import com.xiasuhuei321.gank_kotlin.datasource.remote.RemoteDataSource
@@ -12,11 +13,11 @@ import io.reactivex.Observable
1213
* author:karl
1314
1415
*/
15-
object DataSourceImpl :DataSource {
16+
object DataSourceImpl : DataSource {
1617

17-
private val remote :RemoteDataSource
18+
private val remote: RemoteDataSource
1819

19-
private val local : LocalDataSource
20+
private val local: LocalDataSource
2021

2122
init {
2223
remote = RemoteDataSourceImpl()
@@ -26,11 +27,11 @@ import io.reactivex.Observable
2627
/**
2728
* 初次打开app需要进行一些初始化操作
2829
*/
29-
public fun firstInit(){
30+
public fun firstInit() {
3031

3132
}
3233

33-
override fun getData(type: String):Observable<List<GankData>>{
34+
override fun getData(type: String): Observable<List<GankData>> {
3435
TODO("获取数据,进行网络请求,加载失败再从本地读取缓存")
3536
}
3637

@@ -41,30 +42,37 @@ import io.reactivex.Observable
4142
/**
4243
* 清除本地指定缓存
4344
*/
44-
override fun clearData(type: String){
45+
override fun clearData(type: String) {
4546
TODO("清除本地指定缓存数据")
4647
}
4748

4849
/**
4950
* 清除本地所有缓存
5051
*/
51-
override fun clearAllData(){
52+
override fun clearAllData() {
5253
// TODO("清除本地所有缓存数据")
5354
}
5455

5556

5657
/**
5758
* 优先从本地获取数据
5859
*/
59-
private fun getLocalData(type: String) : Observable<List<GankData>>{
60+
private fun getLocalData(type: String): Observable<List<GankData>> {
6061
TODO("获取本地的缓存数据")
6162
}
6263

6364
/**
6465
* 刷新本地序列化存储数据
6566
*/
66-
private fun refreshLocalData(type: String){
67+
private fun refreshLocalData(type: String) {
6768
// TODO("序列化存储指定数据到本地")
6869
}
6970

71+
/**
72+
* 获取天气,如果网络有问题,就从本地获取,本地也没有那就GG
73+
*/
74+
override fun getWeatherData(): Weather {
75+
return Weather()
76+
}
77+
7078
}

app/src/main/java/com/xiasuhuei321/gank_kotlin/datasource/bean/Code.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ package com.xiasuhuei321.gank_kotlin.datasource.bean
99
/**
1010
* 请求API
1111
*/
12-
object API{
12+
object API {
1313

1414
const val BASE_PATH = "http://gank.io/api/"
1515
//搜索API
@@ -33,7 +33,7 @@ object API{
3333
/**
3434
* 请求类型
3535
*/
36-
object PostType{
36+
object PostType {
3737

3838
// 福利 | Android | iOS | 休息视频 | 拓展资源 | 前端 | all
3939

@@ -50,7 +50,7 @@ object PostType{
5050
/**
5151
* 请求响应代码
5252
*/
53-
object ResponseCode{
53+
object ResponseCode {
5454
/**
5555
* 加载成功
5656
*/

app/src/main/java/com/xiasuhuei321/gank_kotlin/datasource/bean/TechBean.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public String toString() {
165165
public boolean equals(Object obj) {
166166
if (!(obj instanceof ResultsBean))
167167
return false;
168-
if(((ResultsBean)obj).get_id().equals(this.get_id()))
168+
if (((ResultsBean) obj).get_id().equals(this.get_id()))
169169
return true;
170170
return false;
171171
}

0 commit comments

Comments
 (0)