-
Notifications
You must be signed in to change notification settings - Fork 49
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
14 changed files
with
276 additions
and
79 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
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
7 changes: 7 additions & 0 deletions
7
data/src/main/java/com/m3u/data/repository/other/OtherRepository.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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.m3u.data.repository.other | ||
|
||
import com.m3u.data.api.dto.github.Release | ||
|
||
interface OtherRepository { | ||
suspend fun getRelease(): Release? | ||
} |
30 changes: 30 additions & 0 deletions
30
data/src/main/java/com/m3u/data/repository/other/OtherRepositoryImpl.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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.m3u.data.repository.other | ||
|
||
import com.m3u.core.architecture.Publisher | ||
import com.m3u.core.architecture.logger.Logger | ||
import com.m3u.core.architecture.logger.Profiles | ||
import com.m3u.core.architecture.logger.execute | ||
import com.m3u.core.architecture.logger.install | ||
import com.m3u.core.util.collections.indexOf | ||
import com.m3u.data.api.GithubApi | ||
import com.m3u.data.api.dto.github.Release | ||
import javax.inject.Inject | ||
|
||
internal class OtherRepositoryImpl @Inject constructor( | ||
private val githubApi: GithubApi, | ||
private val publisher: Publisher, | ||
delegate: Logger | ||
) : OtherRepository { | ||
private val logger = delegate.install(Profiles.REPOS_OTHER) | ||
override suspend fun getRelease(): Release? { | ||
if (publisher.snapshot) return null | ||
val versionName = publisher.versionName | ||
val releases = logger | ||
.execute { githubApi.releases("oxyroid", "M3UAndroid") } | ||
?: emptyList() | ||
if (releases.isEmpty()) return null | ||
val i = releases.indexOf { it.name == versionName } | ||
// if (i <= 0) return null | ||
return releases.first() | ||
} | ||
} |
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
Oops, something went wrong.