Automatic newest chapter placement on recently read to manga chapters

This commit is contained in:
Jay 2019-11-13 23:19:09 -08:00
parent 8936138da5
commit 28a4f0e237
3 changed files with 18 additions and 4 deletions

View File

@ -43,6 +43,6 @@ class RecentlyReadAdapter(controller: RecentlyReadController)
}
interface OnCoverClickListener {
fun onCoverClick(position: Int)
fun onCoverClick(position: Int, lastTouchY: Float)
}
}

View File

@ -102,9 +102,9 @@ class RecentlyReadController : NucleusController<RecentlyReadPresenter>(),
RemoveHistoryDialog(this, manga, history).showDialog(router)
}
override fun onCoverClick(position: Int) {
override fun onCoverClick(position: Int, lastTouchY: Float) {
val manga = adapter?.getItem(position)?.mch?.manga ?: return
router.pushController(MangaController(manga).withFadeTransaction())
router.pushController(MangaController(manga, lastTouchY).withFadeTransaction())
}
override fun removeHistory(manga: Manga, history: History, all: Boolean) {

View File

@ -1,5 +1,7 @@
package eu.kanade.tachiyomi.ui.recently_read
import android.os.Build
import android.view.MotionEvent
import android.view.View
import com.bumptech.glide.load.engine.DiskCacheStrategy
import eu.kanade.tachiyomi.R
@ -8,6 +10,7 @@ import eu.kanade.tachiyomi.data.glide.GlideApp
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
import kotlinx.android.synthetic.main.recently_read_item.*
import java.util.Date
import kotlin.math.max
/**
* Holder that contains recent manga item
@ -23,6 +26,7 @@ class RecentlyReadHolder(
val adapter: RecentlyReadAdapter
) : BaseFlexibleViewHolder(view, adapter) {
private var lastTouchUpY = 0f
init {
remove.setOnClickListener {
adapter.removeClickListener.onRemoveClick(adapterPosition)
@ -33,7 +37,17 @@ class RecentlyReadHolder(
}
cover.setOnClickListener {
adapter.coverClickListener.onCoverClick(adapterPosition)
adapter.coverClickListener.onCoverClick(adapterPosition, lastTouchUpY)
}
cover.setOnTouchListener { v, event ->
when (event?.action) {
MotionEvent.ACTION_UP -> {
val topH = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
v.rootWindowInsets.systemWindowInsetTop else 38
lastTouchUpY = max(topH + 175f, event.rawY - topH - 154f)
}
}
false
}
}