mirror of
https://github.com/topjohnwu/Magisk.git
synced 2026-01-18 07:37:01 -08:00
Removed events from modules / replaced with retrofit/rx
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.topjohnwu.magisk.data.network
|
||||
|
||||
import com.topjohnwu.magisk.Config
|
||||
import com.topjohnwu.magisk.model.entity.GithubRepo
|
||||
import io.reactivex.Single
|
||||
import retrofit2.http.GET
|
||||
@@ -12,7 +13,11 @@ interface GithubApiServices {
|
||||
fun fetchRepos(
|
||||
@Query("page") page: Int,
|
||||
@Query("per_page") count: Int = REPOS_PER_PAGE,
|
||||
@Query("sort") sortOrder: String = "pushed"
|
||||
@Query("sort") sortOrder: String = when (Config.get<Int>(Config.Key.REPO_ORDER)) {
|
||||
Config.Value.ORDER_DATE -> "updated"
|
||||
Config.Value.ORDER_NAME -> "full_name"
|
||||
else -> "updated"
|
||||
}
|
||||
): Single<List<GithubRepo>>
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -48,7 +48,7 @@ interface GithubRawApiServices {
|
||||
|
||||
@GET("$MAGISK_MODULES/{$MODULE}/master/{$FILE}")
|
||||
@Streaming
|
||||
fun fetchFile(id: String, file: String): Single<ResponseBody>
|
||||
fun fetchFile(@Path(MODULE) id: String, @Path(FILE) file: String): Single<ResponseBody>
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.topjohnwu.magisk.data.network.GithubRawApiServices
|
||||
import com.topjohnwu.magisk.data.network.GithubServices
|
||||
import com.topjohnwu.magisk.model.entity.GithubRepo
|
||||
import com.topjohnwu.magisk.model.entity.toRepository
|
||||
import com.topjohnwu.magisk.utils.Utils
|
||||
import com.topjohnwu.magisk.utils.writeToFile
|
||||
import com.topjohnwu.magisk.utils.writeToString
|
||||
import io.reactivex.Single
|
||||
@@ -18,9 +19,16 @@ class ModuleRepository(
|
||||
) {
|
||||
|
||||
fun fetchModules() = fetchAllRepos()
|
||||
.flattenAsFlowable { it }
|
||||
.flatMapSingle { fetchProperties(it.name, it.updatedAtMillis) }
|
||||
.toList()
|
||||
.map {
|
||||
it.mapNotNull {
|
||||
runCatching {
|
||||
fetchProperties(it.name, it.updatedAtMillis).blockingGet()
|
||||
}.getOrNull()
|
||||
}
|
||||
}
|
||||
|
||||
fun fetchInstalledModules() = Single.fromCallable { Utils.loadModulesLeanback() }
|
||||
.map { it.values.toList() }
|
||||
|
||||
fun fetchInstallFile(module: String) = apiRaw
|
||||
.fetchFile(module, FILE_INSTALL_SH)
|
||||
|
||||
Reference in New Issue
Block a user