Don't filter chapters in the UI

This commit is contained in:
ByteHamster 2021-02-15 21:35:45 +01:00
parent aaeea78b37
commit c0d3a6e3be

View File

@ -42,7 +42,7 @@ public class ChaptersListAdapter extends RecyclerView.Adapter<ChaptersListAdapte
hasImages = false; hasImages = false;
if (media.getChapters() != null) { if (media.getChapters() != null) {
for (Chapter chapter : media.getChapters()) { for (Chapter chapter : media.getChapters()) {
if (!ignoreChapter(chapter) && !TextUtils.isEmpty(chapter.getImageUrl())) { if (!TextUtils.isEmpty(chapter.getImageUrl())) {
hasImages = true; hasImages = true;
} }
} }
@ -125,14 +125,7 @@ public class ChaptersListAdapter extends RecyclerView.Adapter<ChaptersListAdapte
if (media == null || media.getChapters() == null) { if (media == null || media.getChapters() == null) {
return 0; return 0;
} }
// ignore invalid chapters return media.getChapters().size();
int counter = 0;
for (Chapter chapter : media.getChapters()) {
if (!ignoreChapter(chapter)) {
counter++;
}
}
return counter;
} }
static class ChapterHolder extends RecyclerView.ViewHolder { static class ChapterHolder extends RecyclerView.ViewHolder {
@ -171,22 +164,8 @@ public class ChaptersListAdapter extends RecyclerView.Adapter<ChaptersListAdapte
notifyItemChanged(currentChapterIndex, "foo"); notifyItemChanged(currentChapterIndex, "foo");
} }
private boolean ignoreChapter(Chapter c) {
return media.getDuration() > 0 && media.getDuration() < c.getStart();
}
public Chapter getItem(int position) { public Chapter getItem(int position) {
int i = 0; return media.getChapters().get(position);
for (Chapter chapter : media.getChapters()) {
if (!ignoreChapter(chapter)) {
if (i == position) {
return chapter;
} else {
i++;
}
}
}
return null;
} }
public interface Callback { public interface Callback {