Skip to content

Instantly share code, notes, and snippets.

@Alezhka
Created September 13, 2017 10:05
Show Gist options
  • Save Alezhka/af1423ff1b3b241b7cdb17fad3bab5b9 to your computer and use it in GitHub Desktop.
Save Alezhka/af1423ff1b3b241b7cdb17fad3bab5b9 to your computer and use it in GitHub Desktop.
class PreCachingLinearLayoutManager : LinearLayoutManager {
companion object {
val DEFAULT_EXTRA_LAYOUT_SPACE = 600
}
var extraLayoutSpace = -1
private var context: Context
constructor(context: Context) : super(context) {
this.context = context
}
constructor(context: Context, extraLayoutSpace: Int) : super(context) {
this.context = context
this.extraLayoutSpace = extraLayoutSpace
}
constructor(context: Context, orientation: Int, reverseLayout: Boolean) : super(context, orientation, reverseLayout) {
this.context = context
}
override fun getExtraLayoutSpace(state: RecyclerView.State): Int {
if (extraLayoutSpace > 0) {
return extraLayoutSpace
}
return DEFAULT_EXTRA_LAYOUT_SPACE
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment