Skip to content

Instantly share code, notes, and snippets.


discord-gists discord-gists

View GitHub Profile
discord-gists / PanelsPreLayoutViewUpdates.kt
Last active Aug 30, 2020
a simplified code example of how Discord's Android app maintains panel states through device rotations while applying view updates before onLayout
View PanelsPreLayoutViewUpdates.kt
class OverlappingPanelsLayout: FrameLayout {
private lateinit var startPanel: View
private lateinit var centerPanel: View
private lateinit var endPanel: View
private var pendingUpdate: (() -> Unit)? = null
private fun openStartPanel() {
discord-gists / PanelsHorizontalScrollingInChildViews.kt
Last active Mar 2, 2022
a simplified code example of how Discord's Android app selectively allows child views of OverlappingPanelsLayout to handle their own horizontal scrolls
View PanelsHorizontalScrollingInChildViews.kt
class PanelsChildGestureRegionObserver : View.OnLayoutChangeListener {
override fun onLayoutChange(
view: View?,
left: Int,
top: Int,
right: Int,
bottom: Int,
oldLeft: Int,
oldTop: Int,
discord-gists / CustomPanelGestureDetection.kt
Last active Mar 2, 2022
a simplified code example for how Discord's Android app supports custom panel gesture detection
View CustomPanelGestureDetection.kt
class OverlappingPanelsLayout : FrameLayout {
private var scrollingSlopPx: Float = 0f
private var velocityTracker: VelocityTracker? = null
private var isScrollingHorizontally = false
private var xFromInterceptActionDown: Float = 0f
private var yFromInterceptActionDown: Float = 0f
... // initialize scrollingSlopPx and VelocityTracker