From aa46c52eee2316c66a0c5f42f4a4d42bfd5f0558 Mon Sep 17 00:00:00 2001 From: len Date: Wed, 26 Jul 2017 20:35:31 +0200 Subject: [PATCH] Crop borders for webtoons. Closes #904 --- .../ui/reader/viewer/webtoon/WebtoonHolder.kt | 1 + .../ui/reader/viewer/webtoon/WebtoonReader.kt | 24 +++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonHolder.kt index 218621777..5b814db1e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonHolder.kt @@ -63,6 +63,7 @@ class WebtoonHolder(private val view: View, private val adapter: WebtoonAdapter) setMinimumTileDpi(180) setRegionDecoderClass(webtoonReader.regionDecoderClass) setBitmapDecoderClass(webtoonReader.bitmapDecoderClass) + setCropBorders(webtoonReader.cropBorders) setVerticalScrollingParent(true) setOnTouchListener(adapter.touchListener) setOnLongClickListener { webtoonReader.onLongClick(page) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonReader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonReader.kt index 72cae4e10..d10cb41b1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonReader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonReader.kt @@ -53,6 +53,12 @@ class WebtoonReader : BaseReader() { lateinit var layoutManager: PreCachingLayoutManager private set + /** + * Whether to crop image borders. + */ + var cropBorders: Boolean = false + private set + /** * Gesture detector for image touch events. */ @@ -109,16 +115,24 @@ class WebtoonReader : BaseReader() { .doOnNext { setDecoderClass(it) } .skip(1) .distinctUntilChanged() - .subscribe { - val activePage = layoutManager.findFirstVisibleItemPosition() - recycler.adapter = adapter - setActivePage(activePage) - }) + .subscribe { refreshAdapter() }) + + subscriptions.add(readerActivity.preferences.cropBorders() + .asObservable() + .doOnNext { cropBorders = it } + .skip(1) + .distinctUntilChanged() + .subscribe { refreshAdapter() }) setPagesOnAdapter() return recycler } + fun refreshAdapter() { + val activePage = layoutManager.findFirstVisibleItemPosition() + recycler.adapter = adapter + setActivePage(activePage) + } /** * Uses two ways to scroll to the last page read.