diff --git a/app/build.gradle b/app/build.gradle index 337eb59..5164b5b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -14,8 +14,8 @@ android { applicationId "com.shuyu.github.kotlin" minSdkVersion 21 targetSdkVersion 28 - versionCode 7 - versionName "1.0.7" + versionCode 8 + versionName "1.0.8" javaCompileOptions { annotationProcessorOptions { includeCompileClasspath = true diff --git a/app/src/main/java/com/shuyu/github/kotlin/common/config/AppConfig.kt b/app/src/main/java/com/shuyu/github/kotlin/common/config/AppConfig.kt index 60d8aca..d056328 100644 --- a/app/src/main/java/com/shuyu/github/kotlin/common/config/AppConfig.kt +++ b/app/src/main/java/com/shuyu/github/kotlin/common/config/AppConfig.kt @@ -13,6 +13,8 @@ object AppConfig { const val GRAPHIC_HOST = "https://ghchart.rshah.org/" + const val API_TOKEN = "4d65e2a5626103f92a71867d7b49fea0" + const val PAGE_SIZE = 30 const val HTTP_TIME_OUT = 20 * 1000L diff --git a/app/src/main/java/com/shuyu/github/kotlin/repository/ReposRepository.kt b/app/src/main/java/com/shuyu/github/kotlin/repository/ReposRepository.kt index 828dcce..4b71438 100644 --- a/app/src/main/java/com/shuyu/github/kotlin/repository/ReposRepository.kt +++ b/app/src/main/java/com/shuyu/github/kotlin/repository/ReposRepository.kt @@ -4,6 +4,7 @@ import android.app.Application import android.content.Context import androidx.lifecycle.MutableLiveData import com.shuyu.github.kotlin.R +import com.shuyu.github.kotlin.common.config.AppConfig import com.shuyu.github.kotlin.common.net.* import com.shuyu.github.kotlin.common.utils.HtmlUtils import com.shuyu.github.kotlin.common.utils.compareVersion @@ -90,11 +91,9 @@ class ReposRepository @Inject constructor(private val retrofit: Retrofit, privat val trendService = retrofit.create(RepoService::class.java) - .getTrendData(true, language, since) + .getTrendDataAPI(true, AppConfig.API_TOKEN, since,language) .flatMap { FlatMapResponse2Result(it) - }.map { - TrendConversion.htmlToRepo(it) }.doOnNext { reposDao.saveTrendDao(Response.success(GsonUtils.toJsonString(it)), language, since, true) }.map { diff --git a/app/src/main/java/com/shuyu/github/kotlin/service/RepoService.kt b/app/src/main/java/com/shuyu/github/kotlin/service/RepoService.kt index baad9c9..54590e7 100644 --- a/app/src/main/java/com/shuyu/github/kotlin/service/RepoService.kt +++ b/app/src/main/java/com/shuyu/github/kotlin/service/RepoService.kt @@ -21,7 +21,6 @@ interface RepoService { ): Observable>> - @GET("users/{user}/starred") fun getStarredRepos( @Header("forceNetWork") forceNetWork: Boolean, @@ -220,6 +219,15 @@ interface RepoService { @Path("languageType") languageType: String, @Query("since") since: String): Observable> + @GET("https://guoshuyu.cn/github/trend/list") + @Headers("Content-Type: text/plain;charset=utf-8") + fun getTrendDataAPI( + @Header("forceNetWork") forceNetWork: Boolean, + @Header("api-token") apiToken: String, + @Query("since") since: String, + @Query("languageType") languageType: String + ): Observable>> + @GET("repos/{owner}/{repo}/readme") @Headers("Content-Type: text/plain;charset=utf-8", "Accept: application/vnd.github.html") fun getReadmeHtml(