apptreematt
02/26/2016, 7:26 PMfun handleMissingList(list : ATList, completion: (downloaded : Boolean) -> Unit) {
showProgressDialog(R.string.list_downloading)
ListController.downloadList(list, username = AuthenticationController.instance?.username, force = true)
.subscribeOn(<http://Schedulers.io|Schedulers.io>())
.observeOn(AndroidSchedulers.mainThread())
.compose(bindToLifecycle<ATList>())
.subscribeWith {
onNext {
completion(true)
}
onError { error ->
alert(error.message ?: getString(R.string.unknown_error), getString(R.string.list_download_failed)) {
positiveButton(R.string.try_again) {
this@PageFragment.handleMissingList(list, completion)
}
negativeButton(R.string.cancel) {}
}.show()
completion(false)
}
onCompleted { hideProgressDialog() }
}
}