-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use and inject repositories instead of the entire db
- Loading branch information
1 parent
6864fc8
commit 9ed2d30
Showing
5 changed files
with
46 additions
and
8 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
app/src/main/java/live/mehiz/mpvkt/database/repository/PlaybackStateRepositoryImpl.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,21 @@ | ||
package live.mehiz.mpvkt.database.repository | ||
|
||
import live.mehiz.mpvkt.database.MpvKtDatabase | ||
import live.mehiz.mpvkt.database.entities.PlaybackStateEntity | ||
import live.mehiz.mpvkt.domain.playbackstate.repository.PlaybackStateRepository | ||
|
||
class PlaybackStateRepositoryImpl( | ||
private val database: MpvKtDatabase | ||
) : PlaybackStateRepository { | ||
override suspend fun upsert(playbackState: PlaybackStateEntity) { | ||
database.videoDataDao().upsert(playbackState) | ||
} | ||
|
||
override suspend fun getVideoDataByTitle(mediaTitle: String): PlaybackStateEntity? { | ||
return database.videoDataDao().getVideoDataByTitle(mediaTitle) | ||
} | ||
|
||
override suspend fun clearAllPlaybackStates() { | ||
database.videoDataDao().clearAllPlaybackStates() | ||
} | ||
} |
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
12 changes: 12 additions & 0 deletions
12
...src/main/java/live/mehiz/mpvkt/domain/playbackstate/repository/PlaybackStateRepository.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,12 @@ | ||
package live.mehiz.mpvkt.domain.playbackstate.repository | ||
|
||
import live.mehiz.mpvkt.database.entities.PlaybackStateEntity | ||
|
||
interface PlaybackStateRepository { | ||
|
||
suspend fun upsert(playbackState: PlaybackStateEntity) | ||
|
||
suspend fun getVideoDataByTitle(mediaTitle: String): PlaybackStateEntity? | ||
|
||
suspend fun clearAllPlaybackStates() | ||
} |
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