mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2026-10-27 09:44:33 +00:00
Apply review feedback for Kotlin conversion
* Use fromRunnable in updateJoin to return like other methods * Relocate saveStreamState to group loadStreamState overloads Signed-off-by: Aayush Gupta <contact@aayush.io>
This commit is contained in:
1 parent
8f8b4a828e
commit
4e594b06cc
2 files changed
+15
-15
No files matched your search
@@ -237,20 +237,6 @@ class HistoryRecordManager(context: Context) {
|
||||
.subscribeOn(Schedulers.io())
|
||||
}
|
||||
|
||||
fun saveStreamState(info: StreamInfo, progressMillis: Long): Completable {
|
||||
return Completable.fromAction {
|
||||
runBlocking {
|
||||
database.withWriteTransaction {
|
||||
val streamId = streamTable.upsert(StreamEntity(info))
|
||||
val state = StreamStateEntity(streamId, progressMillis)
|
||||
if (state.isValid(info.duration)) {
|
||||
streamStateTable.upsert(state)
|
||||
}
|
||||
}
|
||||
}
|
||||
}.subscribeOn(Schedulers.io())
|
||||
}
|
||||
|
||||
fun loadStreamState(info: InfoItem): Maybe<StreamStateEntity> {
|
||||
return Maybe.fromCallable {
|
||||
streamTable.getStream(info.serviceId.toLong(), info.url)
|
||||
@@ -281,6 +267,20 @@ class HistoryRecordManager(context: Context) {
|
||||
}.subscribeOn(Schedulers.io())
|
||||
}
|
||||
|
||||
fun saveStreamState(info: StreamInfo, progressMillis: Long): Completable {
|
||||
return Completable.fromAction {
|
||||
runBlocking {
|
||||
database.withWriteTransaction {
|
||||
val streamId = streamTable.upsert(StreamEntity(info))
|
||||
val state = StreamStateEntity(streamId, progressMillis)
|
||||
if (state.isValid(info.duration)) {
|
||||
streamStateTable.upsert(state)
|
||||
}
|
||||
}
|
||||
}
|
||||
}.subscribeOn(Schedulers.io())
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////////
|
||||
// Utility
|
||||
// ///////////////////////////////////////////////////////
|
||||
|
||||
@@ -80,7 +80,7 @@ class LocalPlaylistManager(private val database: AppDatabase) {
|
||||
PlaylistStreamEntity(playlistId, streamId, index)
|
||||
}
|
||||
|
||||
return Completable.fromAction {
|
||||
return Completable.fromRunnable {
|
||||
playlistStreamTable.updatePlaylistStreams(playlistId, joinEntities)
|
||||
}.subscribeOn(Schedulers.io())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user