File tree Expand file tree Collapse file tree 6 files changed +31
-29
lines changed
main/java/cn/nekocode/gank/backend
test/java/cn/nekocode/gank/backend Expand file tree Collapse file tree 6 files changed +31
-29
lines changed Original file line number Diff line number Diff line change @@ -28,12 +28,12 @@ import retrofit2.converter.gson.GsonConverterFactory
28
28
*/
29
29
class GankIoService (val client : OkHttpClient , val gson : Gson ) {
30
30
private val retrofit: Retrofit =
31
- Retrofit .Builder ()
32
- .baseUrl(" http://gank.io/api/data/%E7%A6%8F%E5%88%A9/" )
33
- .client(client)
34
- .addConverterFactory(GsonConverterFactory .create(gson))
35
- .addCallAdapterFactory(RxJava2CallAdapterFactory .create())
36
- .build()
31
+ Retrofit .Builder ()
32
+ .baseUrl(" http://gank.io/api/data/%E7%A6%8F%E5%88%A9/" )
33
+ .client(client)
34
+ .addConverterFactory(GsonConverterFactory .create(gson))
35
+ .addCallAdapterFactory(RxJava2CallAdapterFactory .create())
36
+ .build()
37
37
38
38
val picApi: PicApi = retrofit.create(PicApi ::class .java)
39
- }
39
+ }
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ interface PicApi {
29
29
30
30
@GET(" {count}/{pageNum}" )
31
31
fun getMeiziPics (
32
- @Path(" count" ) count : Int ,
33
- @Path(" pageNum" ) pageNum : Int
34
- ):Observable <GankIoResponse <MeiziPic >>
35
- }
32
+ @Path(" count" ) count : Int ,
33
+ @Path(" pageNum" ) pageNum : Int
34
+ ): Observable <GankIoResponse <MeiziPic >>
35
+ }
Original file line number Diff line number Diff line change @@ -24,16 +24,16 @@ import com.google.gson.annotations.SerializedName
24
24
* @author nekocode ([email protected] )
25
25
*/
26
26
data class MeiziPic (
27
- @SerializedName(" _id" ) override val id : String ,
28
- @SerializedName(" type" ) val type : String ,
29
- @SerializedName(" url" ) val url : String ,
30
- @SerializedName(" who" ) val who : String
27
+ @SerializedName(" _id" ) override val id : String ,
28
+ @SerializedName(" type" ) val type : String ,
29
+ @SerializedName(" url" ) val url : String ,
30
+ @SerializedName(" who" ) val who : String
31
31
) : WithId, Parcelable {
32
32
constructor (parcel: Parcel ) : this (
33
- parcel.readString(),
34
- parcel.readString(),
35
- parcel.readString(),
36
- parcel.readString()) {
33
+ parcel.readString(),
34
+ parcel.readString(),
35
+ parcel.readString(),
36
+ parcel.readString()) {
37
37
}
38
38
39
39
override fun writeToParcel (parcel : Parcel , flags : Int ) {
@@ -56,4 +56,4 @@ data class MeiziPic(
56
56
return arrayOfNulls(size)
57
57
}
58
58
}
59
- }
59
+ }
Original file line number Diff line number Diff line change @@ -22,6 +22,6 @@ import com.google.gson.annotations.SerializedName
22
22
* @author nekocode ([email protected] )
23
23
*/
24
24
data class GankIoResponse <T >(
25
- @SerializedName(" error" ) val error : Boolean ,
26
- @SerializedName(" results" ) val results : List <T >
27
- )
25
+ @SerializedName(" error" ) val error : Boolean ,
26
+ @SerializedName(" results" ) val results : List <T >
27
+ )
Original file line number Diff line number Diff line change @@ -29,10 +29,10 @@ class GankIoServiceTest {
29
29
@Test
30
30
fun getMeiziPics () {
31
31
gankIoService.picApi.getMeiziPics(10 , 0 )
32
- .test()
33
- .assertNoErrors()
34
- .assertValue { response ->
35
- ! response.error && response.results.size == 10
36
- }
32
+ .test()
33
+ .assertNoErrors()
34
+ .assertValue { response ->
35
+ ! response.error && response.results.size == 10
36
+ }
37
37
}
38
- }
38
+ }
Original file line number Diff line number Diff line change
1
+ # Enables official code style in IDEA https://kotlinlang.org/docs/reference/coding-conventions.html
2
+ kotlin.code.style =official
You can’t perform that action at this time.
0 commit comments