Fixed NetworkOnMainThreadException
This commit is contained in:
parent
99c5e9dc39
commit
1fe33fb351
|
@ -19,6 +19,9 @@ import de.danoeh.antennapod.core.feed.FeedItem;
|
||||||
import de.danoeh.antennapod.core.storage.DBReader;
|
import de.danoeh.antennapod.core.storage.DBReader;
|
||||||
import de.danoeh.antennapod.core.util.playback.Playable;
|
import de.danoeh.antennapod.core.util.playback.Playable;
|
||||||
import de.greenrobot.event.EventBus;
|
import de.greenrobot.event.EventBus;
|
||||||
|
import io.reactivex.Completable;
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -262,18 +265,15 @@ public class PlaybackServiceTaskManager {
|
||||||
cancelChapterLoader();
|
cancelChapterLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
Runnable chapterLoader = () -> {
|
if (media.getChapters() == null) {
|
||||||
Log.d(TAG, "Chapter loader started");
|
Completable.create(emitter -> {
|
||||||
if (media.getChapters() == null) {
|
media.loadChapterMarks();
|
||||||
media.loadChapterMarks();
|
emitter.onComplete();
|
||||||
if (!Thread.currentThread().isInterrupted() && media.getChapters() != null) {
|
})
|
||||||
callback.onChapterLoaded(media);
|
.subscribeOn(Schedulers.io())
|
||||||
}
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
}
|
.subscribe(() -> callback.onChapterLoaded(media));
|
||||||
Log.d(TAG, "Chapter loader stopped");
|
}
|
||||||
};
|
|
||||||
chapterLoader = useMainThreadIfNecessary(chapterLoader);
|
|
||||||
chapterLoaderFuture = schedExecutor.submit(chapterLoader);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue