Do not crash if an event comes in before the media is loaded (#7067)
This commit is contained in:
parent
00d6df6261
commit
e4bac5ea71
|
@ -127,7 +127,7 @@ public class ChaptersFragment extends AppCompatDialogFragment {
|
|||
}
|
||||
|
||||
private int getCurrentChapter(Playable media) {
|
||||
if (controller == null) {
|
||||
if (controller == null || media == null) {
|
||||
return -1;
|
||||
}
|
||||
return Chapter.getAfterPosition(media.getChapters(), controller.getPosition());
|
||||
|
|
|
@ -261,6 +261,9 @@ public class CoverFragment extends Fragment {
|
|||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEventMainThread(PlaybackPositionEvent event) {
|
||||
if (media == null) {
|
||||
return;
|
||||
}
|
||||
int newChapterIndex = Chapter.getAfterPosition(media.getChapters(), event.getPosition());
|
||||
if (newChapterIndex > -1 && newChapterIndex != displayedChapterIndex) {
|
||||
refreshChapterData(newChapterIndex);
|
||||
|
|
Loading…
Reference in New Issue