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
2828 */
2929class GankIoService (val client : OkHttpClient , val gson : Gson ) {
3030 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()
3737
3838 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 {
2929
3030 @GET(" {count}/{pageNum}" )
3131 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
2424 * @author nekocode ([email protected] ) 2525 */
2626data 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
3131) : WithId, Parcelable {
3232 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()) {
3737 }
3838
3939 override fun writeToParcel (parcel : Parcel , flags : Int ) {
@@ -56,4 +56,4 @@ data class MeiziPic(
5656 return arrayOfNulls(size)
5757 }
5858 }
59- }
59+ }
Original file line number Diff line number Diff line change @@ -22,6 +22,6 @@ import com.google.gson.annotations.SerializedName
2222 * @author nekocode ([email protected] ) 2323 */
2424data 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 {
2929 @Test
3030 fun getMeiziPics () {
3131 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+ }
3737 }
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