-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#81 Refactor trakt Add and Remove history
- Loading branch information
Showing
36 changed files
with
560 additions
and
139 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
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
6 changes: 6 additions & 0 deletions
6
data/model/src/main/java/io/filmtime/data/model/TraktHistory.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,6 @@ | ||
package io.filmtime.data.model | ||
|
||
data class TraktHistory( | ||
val traktId: Int, | ||
val isWatched: Boolean = false, | ||
) |
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
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
24 changes: 21 additions & 3 deletions
24
data/trakt/src/main/java/io/filmtime/data/trakt/TraktHistoryRepositoryImpl.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,14 +1,32 @@ | ||
package io.filmtime.data.trakt | ||
|
||
import io.filmtime.data.api.trakt.TraktSearchRemoteSource | ||
import io.filmtime.data.api.trakt.TraktSyncRemoteSource | ||
import io.filmtime.data.model.GeneralError | ||
import io.filmtime.data.model.Result | ||
import io.filmtime.data.model.TraktHistory | ||
import javax.inject.Inject | ||
|
||
class TraktHistoryRepositoryImpl @Inject constructor( | ||
private val traktSyncRemoteSource: TraktSyncRemoteSource, | ||
private val traktSearchRemoteSource: TraktSearchRemoteSource, | ||
) : TraktHistoryRepository { | ||
override suspend fun addToHistory(id: String): Result<Unit, GeneralError> { | ||
return traktSyncRemoteSource.addToHistory(id) | ||
} | ||
|
||
override suspend fun isWatched(tmdbId: Int): Result<TraktHistory, GeneralError> = | ||
when (val traktIdResult = traktSearchRemoteSource.getByTmdbId(tmdbId)) { | ||
is Result.Failure -> traktIdResult | ||
is Result.Success -> { | ||
val traktId = traktIdResult.data | ||
traktSyncRemoteSource.getHistoryById(traktId) | ||
.mapSuccess { isWatched -> | ||
TraktHistory(traktId, isWatched) | ||
} | ||
} | ||
} | ||
|
||
override suspend fun addToHistory(traktId: Int): Result<Unit, GeneralError> = | ||
traktSyncRemoteSource.addToHistory(traktId) | ||
|
||
override suspend fun removeFromHistory(traktId: Int): Result<Unit, GeneralError> = | ||
traktSyncRemoteSource.removeFromHistory(traktId) | ||
} |
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 |
---|---|---|
|
@@ -7,4 +7,5 @@ android { | |
} | ||
|
||
dependencies { | ||
implementation(project(":data:trakt")) | ||
} |
9 changes: 9 additions & 0 deletions
9
domain/trakt/history/src/main/java/io/filmtime/domain/trakt/history/AddToHistoryUseCase.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,9 @@ | ||
package io.filmtime.domain.trakt.history | ||
|
||
import io.filmtime.data.model.GeneralError | ||
import io.filmtime.data.model.Result | ||
|
||
interface AddToHistoryUseCase { | ||
|
||
suspend operator fun invoke(traktId: Int): Result<Unit, GeneralError> | ||
} |
Oops, something went wrong.