react-native-navigation的迁移库

ScrollViewDelegate.java 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package com.reactnativenavigation.views.collapsingToolbar;
  2. import android.view.MotionEvent;
  3. import android.view.View;
  4. import android.widget.ScrollView;
  5. public class ScrollViewDelegate implements View.OnTouchListener {
  6. private ScrollView scrollView;
  7. private ScrollListener listener;
  8. public ScrollViewDelegate(ScrollListener scrollListener) {
  9. listener = scrollListener;
  10. }
  11. public boolean hasScrollView() {
  12. return scrollView != null;
  13. }
  14. public ScrollView getScrollView() {
  15. return scrollView;
  16. }
  17. public void onScrollViewAdded(ScrollView scrollView) {
  18. this.scrollView = scrollView;
  19. listener.onScrollViewAdded(this.scrollView);
  20. }
  21. public void onScrollViewRemoved() {
  22. this.scrollView = null;
  23. }
  24. public boolean didInterceptTouchEvent(MotionEvent ev) {
  25. return listener.onTouch(ev);
  26. }
  27. @Override
  28. public boolean onTouch(View view, MotionEvent event) {
  29. scrollView.onTouchEvent(event);
  30. return this.listener.onTouch(event);
  31. }
  32. public void destroy() {
  33. scrollView = null;
  34. }
  35. }