Do not jump chapter screen when switching to new chapter
This commit is contained in:
parent
ecaba7525f
commit
441928b046
@ -71,7 +71,7 @@ public class ChaptersFragment extends AppCompatDialogFragment {
|
|||||||
}
|
}
|
||||||
Chapter chapter = adapter.getItem(pos);
|
Chapter chapter = adapter.getItem(pos);
|
||||||
controller.seekTo((int) chapter.getStart());
|
controller.seekTo((int) chapter.getStart());
|
||||||
updateChapterSelection(pos);
|
updateChapterSelection(pos, true);
|
||||||
});
|
});
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ public class ChaptersFragment extends AppCompatDialogFragment {
|
|||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
public void onEventMainThread(PlaybackPositionEvent event) {
|
public void onEventMainThread(PlaybackPositionEvent event) {
|
||||||
updateChapterSelection(getCurrentChapter(media));
|
updateChapterSelection(getCurrentChapter(media), false);
|
||||||
adapter.notifyTimeChanged(event.getPosition());
|
adapter.notifyTimeChanged(event.getPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,10 +160,10 @@ public class ChaptersFragment extends AppCompatDialogFragment {
|
|||||||
}
|
}
|
||||||
adapter.setMedia(media);
|
adapter.setMedia(media);
|
||||||
int positionOfCurrentChapter = getCurrentChapter(media);
|
int positionOfCurrentChapter = getCurrentChapter(media);
|
||||||
updateChapterSelection(positionOfCurrentChapter);
|
updateChapterSelection(positionOfCurrentChapter, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateChapterSelection(int position) {
|
private void updateChapterSelection(int position, boolean scrollTo) {
|
||||||
if (adapter == null) {
|
if (adapter == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -171,8 +171,8 @@ public class ChaptersFragment extends AppCompatDialogFragment {
|
|||||||
if (position != -1 && focusedChapter != position) {
|
if (position != -1 && focusedChapter != position) {
|
||||||
focusedChapter = position;
|
focusedChapter = position;
|
||||||
adapter.notifyChapterChanged(focusedChapter);
|
adapter.notifyChapterChanged(focusedChapter);
|
||||||
if (layoutManager.findFirstCompletelyVisibleItemPosition() >= position
|
if (scrollTo && (layoutManager.findFirstCompletelyVisibleItemPosition() >= position
|
||||||
|| layoutManager.findLastCompletelyVisibleItemPosition() <= position) {
|
|| layoutManager.findLastCompletelyVisibleItemPosition() <= position)) {
|
||||||
layoutManager.scrollToPositionWithOffset(position, 100);
|
layoutManager.scrollToPositionWithOffset(position, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user