-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
140 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 12 additions & 13 deletions
25
app/src/main/kotlin/top/laoxin/modmanager/bean/GithubBean.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
package top.laoxin.modmanager.bean | ||
|
||
import kotlinx.serialization.Serializable | ||
import com.google.gson.annotations.SerializedName | ||
import top.lings.updater.util.AppConfig | ||
|
||
@Serializable | ||
data class GithubBean( | ||
val tag_name: String, | ||
val name: String, | ||
val body: String, | ||
val published_at: String, | ||
val assets: List<Asset> | ||
) | ||
@SerializedName("tag_name") val version: String, | ||
@SerializedName("body") val info: String, | ||
@SerializedName("assets") val assets: List<GitHubAssets> | ||
) { | ||
fun getDownloadLink(): String { | ||
val asset = assets.find { AppConfig.matchVariant(it.downloadLink) } ?: assets[0] | ||
return asset.downloadLink | ||
} | ||
} | ||
|
||
@Serializable | ||
data class Asset( | ||
val name: String, | ||
val browser_download_url: String | ||
) | ||
data class GitHubAssets(@SerializedName("browser_download_url") val downloadLink: String) |
41 changes: 0 additions & 41 deletions
41
app/src/main/kotlin/top/laoxin/modmanager/network/ModManagerGithubApiService.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package top.lings.updater | ||
|
||
import com.google.gson.GsonBuilder | ||
import retrofit2.Retrofit | ||
import retrofit2.converter.gson.GsonConverterFactory | ||
import retrofit2.http.GET | ||
import top.laoxin.modmanager.bean.GithubBean | ||
|
||
private const val BASE_URL_GITHUB = | ||
"https://api.github.com" | ||
|
||
val gsonForGithub = GsonBuilder().create() | ||
|
||
private val retrofit = Retrofit.Builder() | ||
.addConverterFactory(GsonConverterFactory.create(gsonForGithub)) | ||
.baseUrl(BASE_URL_GITHUB) | ||
.build() | ||
|
||
interface GithubApiService { | ||
@GET("repos/laoxinH/crosscore-mod-manager/releases/latest") | ||
suspend fun getLatestRelease(): GithubBean | ||
|
||
} | ||
|
||
object GithubApi { | ||
val retrofitService: GithubApiService by lazy { | ||
retrofit.create(GithubApiService::class.java) | ||
} | ||
} | ||
|
Oops, something went wrong.