Refactor code
This commit is contained in:
parent
369411ffc6
commit
6cdaf27eda
13 changed files with 28 additions and 160 deletions
|
@ -20,7 +20,6 @@ import code.name.monkey.retromusic.Result
|
|||
import code.name.monkey.retromusic.Result.Error
|
||||
import code.name.monkey.retromusic.Result.Success
|
||||
import code.name.monkey.retromusic.adapter.HomeAdapter
|
||||
import code.name.monkey.retromusic.data.RetroDataService
|
||||
import code.name.monkey.retromusic.loaders.*
|
||||
import code.name.monkey.retromusic.model.*
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
|
@ -284,22 +283,6 @@ class RepositoryImpl @Inject constructor(private val context: Context) : Reposit
|
|||
Error(Throwable("Error loading artist"))
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun contributors(): Result<List<Contributor>> {
|
||||
return try {
|
||||
Success(RetroDataService.retoService.getContributors())
|
||||
} catch (e: Exception) {
|
||||
Error(Throwable(e))
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun translators(): Result<List<Contributor>> {
|
||||
return try {
|
||||
Success(RetroDataService.retoService.getTranslators())
|
||||
} catch (e: Exception) {
|
||||
Error(Throwable(e))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun <T : Any> safeApiCall(call: suspend () -> Result<T>, errorMessage: String): Result<T> =
|
||||
|
@ -307,4 +290,4 @@ suspend fun <T : Any> safeApiCall(call: suspend () -> Result<T>, errorMessage: S
|
|||
call.invoke()
|
||||
} catch (e: Exception) {
|
||||
Error(IOException(errorMessage, e))
|
||||
}
|
||||
}
|
|
@ -58,8 +58,4 @@ interface Repository {
|
|||
suspend fun albumInfo(artist: String, album: String): Result<LastFmAlbum>
|
||||
|
||||
suspend fun artistById(artistId: Int): Result<Artist>
|
||||
|
||||
suspend fun contributors(): Result<List<Contributor>>
|
||||
|
||||
suspend fun translators(): Result<List<Contributor>>
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue