Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Androdアプリ開発におけるネストスクロール問題と向き合うの説明用途

Swimmy
December 24, 2023
2.2k

 Androdアプリ開発におけるネストスクロール問題と向き合うの説明用途

Swimmy

December 24, 2023
Tweet

More Decks by Swimmy

Transcript

  1. AndroidView時代のコードと比較 NestedWebViewの実装(簡略化する) class NestedWebView (...) : WebView, NestedScrollingChild { private

    val mChildHelper = NestedScrollingChildHelper(this) override fun onTouchEvent(...): Boolean {...} override fun setNestedScrollingEnabled(...) {...} override fun isNestedScrollingEnabled(...): Boolean {...} override fun startNestedScroll(...): Boolean {...} override fun stopNestedScroll(...) {...} override fun hasNestedScrollingParent(...): Boolean {...} override fun dispatchNestedScroll(...): Boolean {...} override fun dispatchNestedPreScroll(...): Boolean {...} override fun dispatchNestedFling(...): Boolean {... override fun dispatchNestedPreFling(...): Boolean {...} }
  2. AndroidView時代のコードと比較 NestedScrollingChildを実装する class NestedWebView (...) : WebView, NestedScrollingChild { private

    val mChildHelper = NestedScrollingChildHelper(this) override fun onTouchEvent(...): Boolean {...} override fun setNestedScrollingEnabled(...) {...} override fun isNestedScrollingEnabled(...): Boolean {...} override fun startNestedScroll(...): Boolean {...} override fun stopNestedScroll(...) {...} override fun hasNestedScrollingParent(...): Boolean {...} override fun dispatchNestedScroll(...): Boolean {...} override fun dispatchNestedPreScroll(...): Boolean {...} override fun dispatchNestedFling(...): Boolean {... override fun dispatchNestedPreFling(...): Boolean {...} }
  3. AndroidView時代のコードと比較 NestedScrollingChildHelperを介してイベントを送る class NestedWebView (...) : WebView, NestedScrollingChild { private

    val mChildHelper = NestedScrollingChildHelper(this) override fun onTouchEvent(...): Boolean {...} override fun setNestedScrollingEnabled(...) {...} override fun isNestedScrollingEnabled(...): Boolean {...} override fun startNestedScroll(...): Boolean {...} override fun stopNestedScroll(...) {...} override fun hasNestedScrollingParent(...): Boolean {...} override fun dispatchNestedScroll(...): Boolean {...} override fun dispatchNestedPreScroll(...): Boolean {...} override fun dispatchNestedFling(...): Boolean {... override fun dispatchNestedPreFling(...): Boolean {...} }
  4. AndroidView時代のコードと比較 ACTION_DOWNでネストスクロールを開始する class NestedWebView (...) : WebView, NestedScrollingChild { private

    val mChildHelper = NestedScrollingChildHelper(this) override fun onTouchEvent(...): Boolean {...} override fun setNestedScrollingEnabled(...) {...} override fun isNestedScrollingEnabled(...): Boolean {...} override fun startNestedScroll(...): Boolean {...} override fun stopNestedScroll(...) {...} override fun hasNestedScrollingParent(...): Boolean {...} override fun dispatchNestedScroll(...): Boolean {...} override fun dispatchNestedPreScroll(...): Boolean {...} override fun dispatchNestedFling(...): Boolean {... override fun dispatchNestedPreFling(...): Boolean {...} }
  5. AndroidView時代のコードと比較 ネストスクロールを有効化 / 確認 class NestedWebView (...) : WebView, NestedScrollingChild

    { private val mChildHelper = NestedScrollingChildHelper(this) override fun onTouchEvent(...): Boolean {...} override fun setNestedScrollingEnabled(...) {...} override fun isNestedScrollingEnabled(...): Boolean {...} override fun startNestedScroll(...): Boolean {...} override fun stopNestedScroll(...) {...} override fun hasNestedScrollingParent(...): Boolean {...} override fun dispatchNestedScroll(...): Boolean {...} override fun dispatchNestedPreScroll(...): Boolean {...} override fun dispatchNestedFling(...): Boolean {... override fun dispatchNestedPreFling(...): Boolean {...} }
  6. AndroidView時代のコードと比較 NestedScrollConnectionと同様にスクロール量を送る class NestedWebView (...) : WebView, NestedScrollingChild { private

    val mChildHelper = NestedScrollingChildHelper(this) override fun onTouchEvent(...): Boolean {...} override fun setNestedScrollingEnabled(...) {...} override fun isNestedScrollingEnabled(...): Boolean {...} override fun startNestedScroll(...): Boolean {...} override fun stopNestedScroll(...) {...} override fun hasNestedScrollingParent(...): Boolean {...} override fun dispatchNestedScroll(...): Boolean {...} override fun dispatchNestedPreScroll(...): Boolean {...} override fun dispatchNestedFling(...): Boolean {... override fun dispatchNestedPreFling(...): Boolean {...} }
  7. AndroidView時代のコードと比較 ACTION_UP / ACTION_CANCELでスクロールを終了する class NestedWebView (...) : WebView, NestedScrollingChild

    { private val mChildHelper = NestedScrollingChildHelper(this) override fun onTouchEvent(...): Boolean {...} override fun setNestedScrollingEnabled(...) {...} override fun isNestedScrollingEnabled(...): Boolean {...} override fun startNestedScroll(...): Boolean {...} override fun stopNestedScroll(...) {...} override fun hasNestedScrollingParent(...): Boolean {...} override fun dispatchNestedScroll(...): Boolean {...} override fun dispatchNestedPreScroll(...): Boolean {...} override fun dispatchNestedFling(...): Boolean {... override fun dispatchNestedPreFling(...): Boolean {...} }