mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
clean up commented code in GridLayoutManagerAccurateOffset
I'll revert this if I find a need but for now its good
This commit is contained in:
parent
5b2f98ab29
commit
f822fee5c9
1 changed files with 0 additions and 105 deletions
|
@ -7,13 +7,6 @@ import eu.kanade.tachiyomi.R
|
|||
|
||||
class GridLayoutManagerAccurateOffset(context: Context?, spanCount: Int) : GridLayoutManager(context, spanCount) {
|
||||
|
||||
// map of child adapter position to its height.
|
||||
private val childSizesMap = HashMap<Int, Int>()
|
||||
private val childSpanMap = HashMap<Int, Int>()
|
||||
private val childTypeHeightMap = HashMap<Int, HashMap<Int, Int>>()
|
||||
private val childTypeMap = HashMap<Int, Int>()
|
||||
private val childTypeEstimateMap = HashMap<Int, Int>()
|
||||
var computedRange: Int? = null
|
||||
var rView: RecyclerView? = null
|
||||
|
||||
private val toolbarHeight by lazy {
|
||||
|
@ -24,24 +17,6 @@ class GridLayoutManagerAccurateOffset(context: Context?, spanCount: Int) : GridL
|
|||
height
|
||||
}
|
||||
|
||||
// override fun onLayoutCompleted(state: RecyclerView.State) {
|
||||
// super.onLayoutCompleted(state)
|
||||
// computedRange = null
|
||||
// for (i in 0 until childCount) {
|
||||
// val child = getChildAt(i) ?: return
|
||||
// val position = getPosition(child)
|
||||
// childSizesMap[position] = child.height
|
||||
// childSpanMap[position] = spanSizeLookup.getSpanSize(getPosition(child))
|
||||
// val type = getItemViewType(child)
|
||||
// childTypeMap[position] = type
|
||||
// if (childTypeHeightMap[type] != null) {
|
||||
// childTypeHeightMap[type]!![position] = child.height
|
||||
// } else {
|
||||
// childTypeHeightMap[type] = hashMapOf(position to child.height)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
override fun onAttachedToWindow(view: RecyclerView?) {
|
||||
super.onAttachedToWindow(view)
|
||||
rView = view
|
||||
|
@ -68,86 +43,6 @@ class GridLayoutManagerAccurateOffset(context: Context?, spanCount: Int) : GridL
|
|||
super.computeVerticalScrollOffset(state)
|
||||
}
|
||||
}
|
||||
//
|
||||
// override fun computeVerticalScrollRange(state: RecyclerView.State): Int {
|
||||
// if (childCount == 0) return 0
|
||||
// computedRange?.let {
|
||||
// return it
|
||||
// }
|
||||
// rView ?: return super.computeVerticalScrollRange(state)
|
||||
// var scrolledY = 0
|
||||
// var spanC = 0
|
||||
// var maxHeight = 0
|
||||
// val childAvgHeightMap = HashMap<Int, Int>()
|
||||
// for (i in 0 until itemCount) {
|
||||
// val height: Int = getItemHeight(i, childAvgHeightMap)
|
||||
// val spanCurrentSize = childSpanMap[i] ?: spanSizeLookup.getSpanSize(i)
|
||||
// if (spanCount <= spanCurrentSize) {
|
||||
// scrolledY += height
|
||||
// scrolledY += maxHeight
|
||||
// maxHeight = 0
|
||||
// spanC = 0
|
||||
// } else if (spanCurrentSize == 1) {
|
||||
// maxHeight = max(maxHeight, height)
|
||||
// spanC++
|
||||
// if (spanC <= spanCount) {
|
||||
// scrolledY += maxHeight
|
||||
// maxHeight = 0
|
||||
// spanC = 0
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// computedRange = scrolledY
|
||||
// return scrolledY
|
||||
// }
|
||||
//
|
||||
// override fun computeVerticalScrollOffset(state: RecyclerView.State): Int {
|
||||
// if (childCount == 0) {
|
||||
// return 0
|
||||
// }
|
||||
// rView ?: return super.computeVerticalScrollOffset(state)
|
||||
// val firstChild = getChildAt(0) ?: return 0
|
||||
// val firstChildPosition = (0 until childCount)
|
||||
// .mapNotNull { getChildAt(it) }
|
||||
// .mapNotNull { pos -> getPosition(pos).takeIf { it != RecyclerView.NO_POSITION } }
|
||||
// .minOrNull() ?: 0
|
||||
// var scrolledY: Int = -firstChild.y.toInt()
|
||||
// var spanC = 0
|
||||
// var maxHeight = 0
|
||||
// val childAvgHeightMap = HashMap<Int, Int>()
|
||||
// for (i in 0 until firstChildPosition) {
|
||||
// val height: Int = getItemHeight(i, childAvgHeightMap)
|
||||
// val spanCurrentSize = childSpanMap[i] ?: spanSizeLookup.getSpanSize(i)
|
||||
// if (spanCount <= spanCurrentSize) {
|
||||
// scrolledY += height
|
||||
// scrolledY += maxHeight
|
||||
// maxHeight = 0
|
||||
// spanC = 0
|
||||
// } else if (spanCurrentSize == 1) {
|
||||
// maxHeight = max(maxHeight, height)
|
||||
// spanC++
|
||||
// if (spanC <= spanCount) {
|
||||
// scrolledY += maxHeight
|
||||
// maxHeight = 0
|
||||
// spanC = 0
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// scrolledY += maxHeight
|
||||
// return scrolledY + paddingTop
|
||||
// }
|
||||
//
|
||||
// private fun getItemHeight(pos: Int, childAvgHeightMap: HashMap<Int, Int>): Int {
|
||||
// return EstimatedItemHeight.itemOrEstimatedHeight(
|
||||
// pos,
|
||||
// rView?.adapter?.getItemViewType(pos),
|
||||
// childSizesMap,
|
||||
// childTypeMap,
|
||||
// childTypeHeightMap,
|
||||
// childTypeEstimateMap,
|
||||
// childAvgHeightMap,
|
||||
// )
|
||||
// }
|
||||
|
||||
override fun findFirstVisibleItemPosition(): Int {
|
||||
return getFirstPos(rView, toolbarHeight)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue