mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-11 11:38:56 +01:00
Allow to unbind manga, closes #258. Fix some network calls leaking
This commit is contained in:
@@ -91,9 +91,7 @@ class MyAnimeListDialogFragment : DialogFragment() {
|
||||
}
|
||||
|
||||
private fun onPositiveButtonClick() {
|
||||
selectedItem?.let {
|
||||
presenter.registerManga(it)
|
||||
}
|
||||
presenter.registerManga(selectedItem)
|
||||
}
|
||||
|
||||
private fun search(query: String) {
|
||||
|
||||
@@ -56,6 +56,10 @@ class MyAnimeListFragment : BaseRxFragment<MyAnimeListPresenter>() {
|
||||
myanimelist_status.text = presenter.myAnimeList.getStatus(it.status)
|
||||
} ?: run {
|
||||
myanimelist_title.setTextAppearance(context, R.style.TextAppearance_Medium_Button)
|
||||
myanimelist_title.setText(R.string.action_edit)
|
||||
myanimelist_chapters.text = ""
|
||||
myanimelist_score.text = ""
|
||||
myanimelist_status.text = ""
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -123,20 +123,24 @@ class MyAnimeListPresenter : BasePresenter<MyAnimeListFragment>() {
|
||||
stop(GET_SEARCH_RESULTS)
|
||||
}
|
||||
|
||||
fun registerManga(sync: MangaSync) {
|
||||
sync.manga_id = manga.id
|
||||
add(myAnimeList.bind(sync)
|
||||
.flatMap { response ->
|
||||
if (response.isSuccessful) {
|
||||
db.insertMangaSync(sync).asRxObservable()
|
||||
} else {
|
||||
Observable.error(Exception("Could not bind manga"))
|
||||
fun registerManga(sync: MangaSync?) {
|
||||
if (sync != null) {
|
||||
sync.manga_id = manga.id
|
||||
add(myAnimeList.bind(sync)
|
||||
.flatMap { response ->
|
||||
if (response.isSuccessful) {
|
||||
db.insertMangaSync(sync).asRxObservable()
|
||||
} else {
|
||||
Observable.error(Exception("Could not bind manga"))
|
||||
}
|
||||
}
|
||||
}
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({ },
|
||||
{ error -> context.toast(error.message) }))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({ },
|
||||
{ error -> context.toast(error.message) }))
|
||||
} else {
|
||||
db.deleteMangaSyncForManga(manga).executeAsBlocking()
|
||||
}
|
||||
}
|
||||
|
||||
fun getAllStatus(): List<String> {
|
||||
|
||||
Reference in New Issue
Block a user