MCPcopy Create free account
hub / github.com/Snapchat/Valdi / ValdiScrollView

Class ValdiScrollView

valdi/src/java/com/snap/valdi/views/ValdiScrollView.kt:39–961  ·  view source on GitHub ↗

* A scroll view container that uses Yoga for its layout and can be either * horizontal or vertical. */

Source from the content-addressed store, hash-verified

37 * horizontal or vertical.
38 */
39@Keep
40open class ValdiScrollView(context: Context) : ValdiView(context, attributeSet(context)),
41 ValdiScrollableView, CustomChildViewAppender, Runnable, DragGestureRecognizerListener {
42
43 companion object {
44 fun attributeSet(context: Context): AttributeSet? {
45 return if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
46 try {
47 val parser = context.resources.getXml(com.snapchat.client.R.xml.valdi_scroll_view_kitkat)
48 parser.next()
49 parser.nextTag()
50 asAttributeSet(parser)
51 } catch (e: Exception) {
52 null
53 }
54 } else {
55 null
56 }
57 }
58
59 val flingDecelerationRate = 0.998
60 val flingDecelerationCoefficient = 1000 * Math.log(flingDecelerationRate)
61 val flingDecelerationCorrection = 1 / -flingDecelerationCoefficient
62
63 // Android's native fading edge works well up to ~40px. Beyond this, use custom implementation.
64 const val NATIVE_FADE_THRESHOLD = 40
65 }
66
67 // TODO(796) - deprecate, only used in android on legacy tray integration
68 interface ScrollChangeListener {
69 fun onScrollChange(newOffset: Int, oldOffset: Int)
70 }
71
72 var onScrollChangeListener: ScrollChangeListener? = null
73
74 var scrollEnabled: Boolean = true
75 var pagingEnabled: Boolean = false
76
77 var scrollPerfLoggerBridge: IScrollPerfLoggerBridge? = null
78 set(value) {
79 if (field != value) {
80 pauseScrollPerfLogger()
81 field = value
82 }
83 }
84
85 val contentView = ValdiView(context)
86
87 val coordinateResolver = CoordinateResolver(context)
88
89 var contentWidth: Int = 0
90 private set
91 var contentHeight: Int = 0
92 private set
93
94 var contentOffsetX: Int = 0
95 private set
96 var contentOffsetY: Int = 0

Callers

nothing calls this directly

Calls 9

ValdiViewClass · 0.85
EdgeEffectWrapperClass · 0.85
logMethod · 0.65
CoordinateResolverClass · 0.50
RectInterface · 0.50
finishMethod · 0.45
addGestureRecognizerMethod · 0.45

Tested by

no test coverage detected