use of me.devsaki.hentoid.util.ContentHelper in project Hentoid by avluis.
the class ImageViewerViewModel method reparseBook.
/**
* Send the current book to the queue to be reparsed from scratch
*
* @param onError Consumer to call in case reparsing fails
*/
public void reparseBook(Consumer<Throwable> onError) {
Content theContent = content.getValue();
if (null == theContent)
return;
compositeDisposable.add(Observable.fromIterable(Stream.of(theContent).toList()).observeOn(Schedulers.io()).map(ContentHelper::reparseFromScratch).doOnNext(c -> {
if (c.right.isEmpty())
throw new EmptyResultException();
dao.addContentToQueue(c.right.get(), StatusContent.SAVED, ContentHelper.QueuePosition.TOP, ContentQueueManager.getInstance().isQueueActive(getApplication()));
}).observeOn(AndroidSchedulers.mainThread()).doOnComplete(() -> {
if (Preferences.isQueueAutostart())
ContentQueueManager.getInstance().resumeQueue(getApplication());
}).subscribe(v -> {
// Nothing; feedback is done through LiveData
}, onError::accept));
}
Aggregations