Skip to content

Instantly share code, notes, and snippets.

@tiwiz
Created December 9, 2017 22:30
Show Gist options
  • Save tiwiz/85fdfdf37bb0d331da618252b97e8f51 to your computer and use it in GitHub Desktop.
Save tiwiz/85fdfdf37bb0d331da618252b97e8f51 to your computer and use it in GitHub Desktop.
open class ObservableWebView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : WebView(context, attrs, defStyleAttr), ScrollableViewCompat {
private lateinit var listener : OnScrollChangeObserver
override fun addOnScrollChangeListener(l: OnScrollChangeObserver) {
listener = l
}
override fun getAttachedActivity() = context as AppCompatActivity
override fun onScrollChanged(l: Int, t: Int, oldl: Int, oldt: Int) {
super.onScrollChanged(l, t, oldl, oldt)
listener.onScrollChange(this, l, t, oldl, oldt)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment