mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-24 13:48:55 +03:00
Improve webtoon reader scroll up
This commit is contained in:
parent
d9a2255be9
commit
4d14f56fa8
2 changed files with 20 additions and 5 deletions
|
@ -76,10 +76,10 @@ class WebtoonHolder(private val view: View, private val adapter: WebtoonAdapter)
|
|||
})
|
||||
}
|
||||
|
||||
view.progress_container.minimumHeight = view.resources.displayMetrics.heightPixels * 2
|
||||
view.progress_container.minimumHeight = webtoonReader.screenHeight
|
||||
|
||||
view.setOnTouchListener(adapter.touchListener)
|
||||
view.retry_button.setOnTouchListener { v, event ->
|
||||
view.retry_button.setOnTouchListener { _, event ->
|
||||
if (event.action == MotionEvent.ACTION_UP) {
|
||||
readerActivity.presenter.retryPage(page)
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package eu.kanade.tachiyomi.ui.reader.viewer.webtoon
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.util.DisplayMetrics
|
||||
import android.view.*
|
||||
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
|
||||
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
|
@ -64,6 +66,19 @@ class WebtoonReader : BaseReader() {
|
|||
|
||||
private var scrollDistance: Int = 0
|
||||
|
||||
val screenHeight by lazy {
|
||||
val display = activity.windowManager.defaultDisplay
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
val metrics = DisplayMetrics()
|
||||
display.getRealMetrics(metrics)
|
||||
metrics.heightPixels
|
||||
} else {
|
||||
val field = Display::class.java.getMethod("getRawHeight")
|
||||
field.invoke(display) as Int
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedState: Bundle?): View? {
|
||||
adapter = WebtoonAdapter(this)
|
||||
|
||||
|
@ -108,12 +123,12 @@ class WebtoonReader : BaseReader() {
|
|||
/**
|
||||
* Uses two ways to scroll to the last page read.
|
||||
*/
|
||||
private fun scrollToLastPageRead(last_page_read: Int) {
|
||||
private fun scrollToLastPageRead(page: Int) {
|
||||
// Scrolls to the correct page initially, but isn't reliable beyond that.
|
||||
recycler.addOnLayoutChangeListener(object: View.OnLayoutChangeListener {
|
||||
override fun onLayoutChange(p0: View?, p1: Int, p2: Int, p3: Int, p4: Int, p5: Int, p6: Int, p7: Int, p8: Int) {
|
||||
if(pages.isEmpty()) {
|
||||
setActivePage(last_page_read)
|
||||
setActivePage(page)
|
||||
} else {
|
||||
recycler.removeOnLayoutChangeListener(this)
|
||||
}
|
||||
|
@ -121,7 +136,7 @@ class WebtoonReader : BaseReader() {
|
|||
})
|
||||
|
||||
// Scrolls to the correct page after app has been in use, but can't do it the very first time.
|
||||
recycler.post { setActivePage(last_page_read) }
|
||||
recycler.post { setActivePage(page) }
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
|
|
Loading…
Reference in a new issue