mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-10 20:15:09 +01:00
Replacing sublist with take where applicable
There's so many helper methods I just cant remember them all
This commit is contained in:
parent
248f729768
commit
0cfce71266
@ -788,7 +788,7 @@ class ReaderActivity :
|
||||
pViewer.config.shiftDoublePage = (
|
||||
binding.readerNav.pageSeekbar.progress +
|
||||
(
|
||||
currentChapter?.pages?.subList(0, binding.readerNav.pageSeekbar.progress)
|
||||
currentChapter?.pages?.take(binding.readerNav.pageSeekbar.progress)
|
||||
?.count { it.fullPage || it.isolatedPage } ?: 0
|
||||
)
|
||||
) % 2 != 0
|
||||
@ -816,7 +816,7 @@ class ReaderActivity :
|
||||
(viewer as? PagerViewer)?.config?.shiftDoublePage = (
|
||||
currentChapter.requestedPage +
|
||||
(
|
||||
currentChapter.pages?.subList(0, currentChapter.requestedPage)
|
||||
currentChapter.pages?.take(currentChapter.requestedPage)
|
||||
?.count { it.fullPage || it.isolatedPage } ?: 0
|
||||
)
|
||||
) % 2 != 0
|
||||
|
@ -208,8 +208,7 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() {
|
||||
0,
|
||||
(
|
||||
if (index > -1) (
|
||||
items.subList(0, index)
|
||||
.indexOfLast { it?.fullPage == true }
|
||||
items.take(index).indexOfLast { it?.fullPage == true }
|
||||
) else -1
|
||||
)
|
||||
)
|
||||
|
@ -448,7 +448,7 @@ class BrowseController :
|
||||
val sortedList = list.filter { it.split(":").size == 2 }
|
||||
.sortedByDescending { it.split(":").last().toLong() }
|
||||
preferences.lastUsedSources()
|
||||
.set(sortedList.subList(0, min(sortedList.size, 2)).toSet())
|
||||
.set(sortedList.take(2).toSet())
|
||||
}
|
||||
router.pushController(controller.withFadeTransaction())
|
||||
}
|
||||
|
@ -49,30 +49,20 @@ class MangaShortcutManager(
|
||||
sourceManager.getOrStub(id) to splitS[1].toLong()
|
||||
}
|
||||
}
|
||||
var recents = (
|
||||
recentManga.subList(
|
||||
0,
|
||||
min(
|
||||
recentManga.size,
|
||||
shortcutManager.maxShortcutCountPerActivity
|
||||
)
|
||||
) + recentSources
|
||||
)
|
||||
.sortedByDescending { it.second }.map { it.first }
|
||||
|
||||
recents = recents.subList(
|
||||
0,
|
||||
min(
|
||||
recentManga.size,
|
||||
shortcutManager.maxShortcutCountPerActivity
|
||||
)
|
||||
)
|
||||
val recents =
|
||||
(recentManga.take(shortcutManager.maxShortcutCountPerActivity) + recentSources)
|
||||
.sortedByDescending { it.second }
|
||||
.map { it.first }
|
||||
.take(shortcutManager.maxShortcutCountPerActivity)
|
||||
|
||||
val shortcuts = recents.mapNotNull { item ->
|
||||
when (item) {
|
||||
is Manga -> {
|
||||
val request = GetRequest.Builder(context).data(item).build()
|
||||
val bitmap = (Coil.imageLoader(context).execute(request).drawable as? BitmapDrawable)?.bitmap
|
||||
val bitmap = (
|
||||
Coil.imageLoader(context)
|
||||
.execute(request).drawable as? BitmapDrawable
|
||||
)?.bitmap
|
||||
|
||||
ShortcutInfo.Builder(
|
||||
context,
|
||||
|
Loading…
Reference in New Issue
Block a user