Add ability to explicitly remove tracking from track search dialog (closes #2532)

This commit is contained in:
arkon 2020-01-24 14:27:53 -05:00
parent a288c0f280
commit f966187ea4
2 changed files with 13 additions and 3 deletions

View file

@ -91,10 +91,14 @@ class TrackPresenter(
.subscribe({ }, .subscribe({ },
{ error -> context.toast(error.message) })) { error -> context.toast(error.message) }))
} else { } else {
db.deleteTrackForManga(manga, service).executeAsBlocking() unregisterTracking(service)
} }
} }
fun unregisterTracking(service: TrackService) {
db.deleteTrackForManga(manga, service).executeAsBlocking()
}
private fun updateRemote(track: Track, service: TrackService) { private fun updateRemote(track: Track, service: TrackService) {
service.update(track) service.update(track)
.flatMap { db.insertTrack(track).asRxObservable() } .flatMap { db.insertTrack(track).asRxObservable() }

View file

@ -54,8 +54,10 @@ class TrackSearchDialog : DialogController {
val dialog = MaterialDialog.Builder(activity!!) val dialog = MaterialDialog.Builder(activity!!)
.customView(R.layout.track_search_dialog, false) .customView(R.layout.track_search_dialog, false)
.positiveText(android.R.string.ok) .positiveText(android.R.string.ok)
.negativeText(android.R.string.cancel)
.onPositive { _, _ -> onPositiveButtonClick() } .onPositive { _, _ -> onPositiveButtonClick() }
.negativeText(android.R.string.cancel)
.neutralText(R.string.action_remove)
.onNeutral { _, _ -> onRemoveButtonClick() }
.build() .build()
if (subscriptions.isUnsubscribed) { if (subscriptions.isUnsubscribed) {
@ -137,6 +139,10 @@ class TrackSearchDialog : DialogController {
trackController.presenter.registerTracking(selectedItem, service) trackController.presenter.registerTracking(selectedItem, service)
} }
private fun onRemoveButtonClick() {
trackController.presenter.unregisterTracking(service)
}
private companion object { private companion object {
const val KEY_SERVICE = "service_id" const val KEY_SERVICE = "service_id"
} }