|
@@ -52,19 +52,19 @@ class Shikimori(private val context: Context, id: Int) : TrackService(id) {
|
|
|
}
|
|
|
|
|
|
override fun bind(track: Track): Observable<Track> {
|
|
|
- return runAsObservable({ api.findLibManga(track, getUsername()) })
|
|
|
- .flatMap { remoteTrack ->
|
|
|
- if (remoteTrack != null) {
|
|
|
- track.copyPersonalFrom(remoteTrack)
|
|
|
- track.library_id = remoteTrack.library_id
|
|
|
- runAsObservable({ update(track) })
|
|
|
- } else {
|
|
|
- // Set default fields if it's not found in the list
|
|
|
- track.score = DEFAULT_SCORE.toFloat()
|
|
|
- track.status = DEFAULT_STATUS
|
|
|
- runAsObservable({ add(track) })
|
|
|
- }
|
|
|
+ return runAsObservable({
|
|
|
+ val remoteTrack = api.findLibManga(track, getUsername())
|
|
|
+ if (remoteTrack != null) {
|
|
|
+ track.copyPersonalFrom(remoteTrack)
|
|
|
+ track.library_id = remoteTrack.library_id
|
|
|
+ update(track)
|
|
|
+ } else {
|
|
|
+ // Set default fields if it's not found in the list
|
|
|
+ track.score = DEFAULT_SCORE.toFloat()
|
|
|
+ track.status = DEFAULT_STATUS
|
|
|
+ add(track)
|
|
|
}
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
override fun search(query: String): Observable<List<TrackSearch>> {
|
|
@@ -72,14 +72,13 @@ class Shikimori(private val context: Context, id: Int) : TrackService(id) {
|
|
|
}
|
|
|
|
|
|
override fun refresh(track: Track): Observable<Track> {
|
|
|
- return runAsObservable({ api.findLibManga(track, getUsername()) })
|
|
|
- .map { remoteTrack ->
|
|
|
- if (remoteTrack != null) {
|
|
|
- track.copyPersonalFrom(remoteTrack)
|
|
|
- track.total_chapters = remoteTrack.total_chapters
|
|
|
- }
|
|
|
- track
|
|
|
+ return runAsObservable({
|
|
|
+ api.findLibManga(track, getUsername())?.let { remoteTrack ->
|
|
|
+ track.copyPersonalFrom(remoteTrack)
|
|
|
+ track.total_chapters = remoteTrack.total_chapters
|
|
|
}
|
|
|
+ track
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
override fun getLogo() = R.drawable.ic_tracker_shikimori
|