Repackage to prepare for merge
This commit is contained in:
parent
b977cde1af
commit
7c6514d010
455 changed files with 2251 additions and 2302 deletions
|
@ -0,0 +1,46 @@
|
|||
package code.name.monkey.retromusic
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
class PeekingLinearLayoutManager : LinearLayoutManager {
|
||||
@JvmOverloads
|
||||
constructor(
|
||||
context: Context?,
|
||||
@RecyclerView.Orientation orientation: Int = RecyclerView.VERTICAL,
|
||||
reverseLayout: Boolean = false
|
||||
) : super(context, orientation, reverseLayout)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr,
|
||||
defStyleRes
|
||||
)
|
||||
|
||||
override fun generateDefaultLayoutParams() =
|
||||
scaledLayoutParams(super.generateDefaultLayoutParams())
|
||||
|
||||
override fun generateLayoutParams(lp: ViewGroup.LayoutParams?) =
|
||||
scaledLayoutParams(super.generateLayoutParams(lp))
|
||||
|
||||
override fun generateLayoutParams(c: Context?, attrs: AttributeSet?) =
|
||||
scaledLayoutParams(super.generateLayoutParams(c, attrs))
|
||||
|
||||
private fun scaledLayoutParams(layoutParams: RecyclerView.LayoutParams) =
|
||||
layoutParams.apply {
|
||||
when (orientation) {
|
||||
HORIZONTAL -> width = (horizontalSpace * ratio).toInt()
|
||||
VERTICAL -> height = (verticalSpace * ratio).toInt()
|
||||
}
|
||||
}
|
||||
|
||||
private val horizontalSpace get() = width - paddingStart - paddingEnd
|
||||
|
||||
private val verticalSpace get() = height - paddingTop - paddingBottom
|
||||
|
||||
private val ratio = 0.8f // change to 0.7f for 70%
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue