android.support.v4.widget.NestedScrollView Java Examples

The following examples show how to use android.support.v4.widget.NestedScrollView. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ScrollController.java    From GpCollapsingToolbar with Apache License 2.0 6 votes vote down vote up
private void calculateDistance(View view, int scrollY, int oldScrollY) {
    if (mAppBarScrollRange == null || mNestedScrollRange == null) {
        return;
    }

    int totalScrollRange = mAppBarScrollRange + mNestedScrollRange;

    if (view instanceof AppBarLayout) {
        mAppBarScrollPosition = Math.abs(-scrollY);
    } else if (view instanceof NestedScrollView) {
        mNestedScrollPosition = view.getScrollY();
    }

    int scrollPosition = mAppBarScrollPosition + mNestedScrollPosition;
    mScrollPositionMultiplier = (double) (scrollPosition / totalScrollRange);
    if (mOnTotalScrollChangeListener != null) {
        mOnTotalScrollChangeListener.onTotalScrollChanged(view, scrollPosition, mOldScrollPosition, totalScrollRange);
    }
    mOldScrollPosition = scrollPosition;
}
 
Example #2
Source File: ScrollingActivity.java    From Android-TopScrollHelper with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scrolling);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    mNestedScrollView = (NestedScrollView) findViewById(R.id.scrollView);

    initTopScrollHelper();
}
 
Example #3
Source File: ScrollableHelper.java    From DanDanPlayForAndroid with MIT License 6 votes vote down vote up
@SuppressLint("NewApi")
public void smoothScrollBy(int velocityY, int distance, int duration) {
    View scrollableView = getScrollableView();
    if (scrollableView instanceof AbsListView) {
        AbsListView absListView = (AbsListView) scrollableView;
        if (Build.VERSION.SDK_INT >= 21) {
            absListView.fling(velocityY);
        } else {
            absListView.smoothScrollBy(distance, duration);
        }
    } else if (scrollableView instanceof ScrollView) {
        ((ScrollView) scrollableView).fling(velocityY);
    }  else if (scrollableView instanceof NestedScrollView) {
        ((NestedScrollView) scrollableView).fling(velocityY);
    } else if (scrollableView instanceof RecyclerView) {
        ((RecyclerView) scrollableView).fling(0, velocityY);
    } else if (scrollableView instanceof WebView) {
        ((WebView) scrollableView).flingScroll(0, velocityY);
    }
}
 
Example #4
Source File: ScrollTransitionFragment.java    From ClipPathLayout with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    mLayout = (NestedScrollView) inflater.inflate(R.layout.fragment_scroll_transition, null);
    mImageContainer = mLayout.findViewById(R.id.image_container);
    mBelowView = mLayout.findViewById(R.id.below_image);
    mAboveView = mLayout.findViewById(R.id.above_image);
    mLayout.setOnScrollChangeListener(this);
    mLayout.post(new Runnable() {
        @Override
        public void run() {
            if (mController == null) {
                initController();
            }
        }
    });
    return mLayout;
}
 
Example #5
Source File: Utils.java    From smooth-app-bar-layout with Apache License 2.0 6 votes vote down vote up
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
  int currentOffset = 0;
  if (!mDone) {
    if (v instanceof NestedScrollView) {
      currentOffset = v.getScrollY();
    } else if (v instanceof RecyclerView) {
      currentOffset = ((RecyclerView) v).computeVerticalScrollOffset();
    }
    if (currentOffset < mOffset) {
      vTarget.scrollBy(0, mOffset - currentOffset);
    } else {
      vSmoothAppBarLayout.syncOffset(mOffset);
      mDone = true;
    }
  }
}
 
Example #6
Source File: TopicDetailFragment.java    From JReadHub with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void initDataAndEvent() {
    mToolbar.setNavigationOnClickListener(v -> pop());
    mToolbar.setOnMenuItemClickListener(this);

    mTimelineAdapter = new TopicTimelineAdapter(getContext());
    mRecyclerTimeline.setAdapter(mTimelineAdapter);
    mRecyclerTimeline.setLayoutManager(new LinearLayoutManager(getContext()));
    mRecyclerTimeline.setNestedScrollingEnabled(false);

    mScrollView.setOnScrollChangeListener((NestedScrollView.OnScrollChangeListener) (v, scrollX, scrollY, oldScrollX, oldScrollY) -> {
        if (scrollY > mTxtTopicTime.getBottom()) {
            mToolbarHeader.setVisibility(View.VISIBLE);
            mToolbar.setTitle("");
        } else {
            mToolbarHeader.setVisibility(View.GONE);
            mToolbar.setTitle(getText(R.string.menu_topic_detail));
        }
    });
}
 
Example #7
Source File: RefreshContentWrapper.java    From CollapsingRefresh with Apache License 2.0 6 votes vote down vote up
void attach(NestedScrollView scrollView) {
    //获得原始监听器,用作转发
    Field[] declaredFields = NestedScrollView.class.getDeclaredFields();
    if (declaredFields != null) {
        for (Field field : declaredFields) {
            if (NestedScrollView.OnScrollChangeListener.class.equals(field.getType())) {
                try {
                    field.setAccessible(true);
                    Object listener = field.get(scrollView);
                    if (listener != null && !scrollView.equals(listener)) {
                        mScrollChangeListener = (NestedScrollView.OnScrollChangeListener) listener;
                    }
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    scrollView.setOnScrollChangeListener(this);
}
 
Example #8
Source File: FavoritesFragment.java    From WanAndroid with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_timeline_page, container, false);
    initViews(view);

    //滑动到底部加载下一页
    nestedScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
        @Override
        public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
            if (scrollY == (v.getChildAt(0).getMeasuredHeight() - v.getMeasuredHeight())) {
                loadMore();
            }
        }
    });
    refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            currentPage = INDEX;
            presenter.getFavoriteArticles(INDEX, true, true);

        }
    });

    return view;
}
 
Example #9
Source File: VCanPullUtil.java    From PullRefreshView with Apache License 2.0 6 votes vote down vote up
public static VPullable getPullAble(View view) {
    if (view == null) {
        return null;
    }
    view.setOverScrollMode(View.OVER_SCROLL_NEVER);
    if (view instanceof VPullable) {
        return (VPullable) view;
    } else if (view instanceof AbsListView) {
        return new AbsListViewCanPull((AbsListView) view);
    } else if (view instanceof ScrollView || view instanceof NestedScrollView) {
        return new ScrollViewCanPull((ViewGroup) view);
    } else if (view instanceof WebView) {
        return new WebViewCanPull((WebView) view);
    } else if (view instanceof RecyclerView) {
        return new RecyclerViewCanPull((RecyclerView) view);
    }
    return null;
}
 
Example #10
Source File: BaseBehavior.java    From smooth-app-bar-layout with Apache License 2.0 6 votes vote down vote up
private void initScrollTarget(final CoordinatorLayout coordinatorLayout, final AppBarLayout child) {
  Utils.log("initScrollTarget | %b", vScrollTarget != null);
  if (vScrollTarget != null) {
    long tag = getViewTag(vScrollTarget, true);
    if (!mScrollTargets.contains(tag)) {
      mScrollTargets.add(tag);
      OnScrollListener listener = new OnScrollListener() {

        @Override
        public void onScrollChanged(View view, int x, int y, int dx, int dy, boolean accuracy) {
          if (view == vScrollTarget) {
            BaseBehavior.this.onScrollChanged(coordinatorLayout, child, view, y, dy, accuracy);
          }
        }
      };
      if (vScrollTarget instanceof NestedScrollView) {
        ObservableNestedScrollView.newInstance((NestedScrollView) vScrollTarget, mOverrideOnScrollListener, listener);
      } else if (vScrollTarget instanceof RecyclerView) {
        ObservableRecyclerView.newInstance((RecyclerView) vScrollTarget, listener);
      }
    }
  }
}
 
Example #11
Source File: ScrollingAppBarLayoutBehavior.java    From react-native-bottom-sheet-behavior with MIT License 6 votes vote down vote up
/**
 * Look into the CoordiantorLayout for the {@link RNBottomSheetBehavior}
 * @param coordinatorLayout with app:layout_behavior= {@link RNBottomSheetBehavior}
 */
private void getBottomSheetBehavior(@NonNull CoordinatorLayout coordinatorLayout) {

    for (int i = 0; i < coordinatorLayout.getChildCount(); i++) {
        View child = coordinatorLayout.getChildAt(i);

        if (child instanceof NestedScrollView) {

            try {
                RNBottomSheetBehavior temp = RNBottomSheetBehavior.from(child);
                mBottomSheetBehaviorRef = new WeakReference<>(temp);
                break;
            }
            catch (IllegalArgumentException e){}
        }
    }
}
 
Example #12
Source File: BottomSheetBehaviorManager.java    From react-native-bottom-sheet-behavior with MIT License 6 votes vote down vote up
@Override
public void receiveCommand(BottomSheetBehaviorView view, int commandType, @Nullable ReadableArray args) {
    switch (commandType) {
      case COMMAND_SET_REQUEST_LAYOUT:
          setRequestLayout(view);
          return;
      case COMMAND_SET_BOTTOM_SHEET_STATE:
          setBottomSheetState(view, args);
          return;
      case COMMAND_ATTACH_NESTED_SCROLL_CHILD:
          int nestedScrollId = args.getInt(0);
          ViewGroup child = (ViewGroup) view.getRootView().findViewById(nestedScrollId);
          if (child != null && child instanceof NestedScrollView) {
              this.attachNestedScrollChild(view, (NestedScrollView) child);
          }
          return;

      default:
          throw new JSApplicationIllegalArgumentException("Invalid Command");
    }
}
 
Example #13
Source File: MergedAppBarLayoutBehavior.java    From react-native-bottom-sheet-behavior with MIT License 6 votes vote down vote up
/**
 * Look into the CoordiantorLayout for the {@link RNBottomSheetBehavior}
 * @param coordinatorLayout with app:layout_behavior= {@link RNBottomSheetBehavior}
 */
private void getBottomSheetBehavior(@NonNull CoordinatorLayout coordinatorLayout) {

    for (int i = 0; i < coordinatorLayout.getChildCount(); i++) {
        View child = coordinatorLayout.getChildAt(i);

        if (child instanceof NestedScrollView) {

            try {
                RNBottomSheetBehavior temp = RNBottomSheetBehavior.from(child);
                mBottomSheetBehaviorRef = new WeakReference<>(temp);
                break;
            }
            catch (IllegalArgumentException e){}
        }
    }
}
 
Example #14
Source File: Utils.java    From Expert-Android-Programming with MIT License 6 votes vote down vote up
public static boolean syncOffset(SmoothAppBarLayout smoothAppBarLayout, View target, int verticalOffset, View scroll) {
  boolean isSelected = target == scroll;
  if (scroll instanceof NestedScrollView) {
    NestedScrollView nestedScrollView = (NestedScrollView) scroll;
    if (nestedScrollView.getScrollY() < verticalOffset || (!isSelected && isScrollToTop(target))) {
      nestedScrollView.scrollTo(0, verticalOffset);
    }
    if (isSelected && (nestedScrollView.getScrollY() < verticalOffset || verticalOffset == 0)) {
      nestedScrollView.scrollTo(0, 0);
      smoothAppBarLayout.syncOffset(0);
    }
  } else if (scroll instanceof RecyclerView) {
    RecyclerView recyclerView = (RecyclerView) scroll;
    boolean isAccuracy = recyclerView.getLayoutManager().findViewByPosition(ObservableRecyclerView.HEADER_VIEW_POSITION) != null;
    if (isAccuracy && recyclerView.computeVerticalScrollOffset() < verticalOffset) {
      recyclerView.scrollBy(0, verticalOffset - recyclerView.computeVerticalScrollOffset());
    } else if (!isSelected && isScrollToTop(target)) {
      recyclerView.scrollToPosition(ObservableRecyclerView.HEADER_VIEW_POSITION);
    }
    if (isAccuracy && isSelected && (recyclerView.computeVerticalScrollOffset() < verticalOffset || verticalOffset == 0)) {
      recyclerView.scrollToPosition(ObservableRecyclerView.HEADER_VIEW_POSITION);
      smoothAppBarLayout.syncOffset(0);
    }
  }
  return true;
}
 
Example #15
Source File: Utils.java    From Expert-Android-Programming with MIT License 6 votes vote down vote up
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
  int currentOffset = 0;
  if (!mDone) {
    if (v instanceof NestedScrollView) {
      currentOffset = v.getScrollY();
    } else if (v instanceof RecyclerView) {
      currentOffset = ((RecyclerView) v).computeVerticalScrollOffset();
    }
    if (currentOffset < mOffset) {
      vTarget.scrollBy(0, mOffset - currentOffset);
    } else {
      vSmoothAppBarLayout.syncOffset(mOffset);
      mDone = true;
    }
  }
}
 
Example #16
Source File: BaseBehavior.java    From Expert-Android-Programming with MIT License 6 votes vote down vote up
private void initScrollTarget(final CoordinatorLayout coordinatorLayout, final AppBarLayout child) {
  Utils.log("initScrollTarget | %b", vScrollTarget != null);
  if (vScrollTarget != null) {
    long tag = getViewTag(vScrollTarget, true);
    if (!mScrollTargets.contains(tag)) {
      mScrollTargets.add(tag);
      OnScrollListener listener = new OnScrollListener() {

        @Override
        public void onScrollChanged(View view, int x, int y, int dx, int dy, boolean accuracy) {
          if (view == vScrollTarget) {
            BaseBehavior.this.onScrollChanged(coordinatorLayout, child, view, y, dy, accuracy);
          }
        }
      };
      if (vScrollTarget instanceof NestedScrollView) {
        ObservableNestedScrollView.newInstance((NestedScrollView) vScrollTarget, mOverrideOnScrollListener, listener);
      } else if (vScrollTarget instanceof RecyclerView) {
        ObservableRecyclerView.newInstance((RecyclerView) vScrollTarget, listener);
      }
    }
  }
}
 
Example #17
Source File: ScrollAwareFABBehavior.java    From Nibo with MIT License 6 votes vote down vote up
/**
 * Look into the CoordiantorLayout for the {@link BottomSheetBehaviorGoogleMapsLike}
 * @param coordinatorLayout with app:layout_behavior= {@link BottomSheetBehaviorGoogleMapsLike}
 */
private void getBottomSheetBehavior(@NonNull CoordinatorLayout coordinatorLayout) {

    for (int i = 0; i < coordinatorLayout.getChildCount(); i++) {
        View child = coordinatorLayout.getChildAt(i);

        if (child instanceof NestedScrollView) {

            try {
                BottomSheetBehaviorGoogleMapsLike temp = BottomSheetBehaviorGoogleMapsLike.from(child);
                mBottomSheetBehaviorRef = new WeakReference<>(temp);
                break;
            }
            catch (IllegalArgumentException e){}
        }
    }
}
 
Example #18
Source File: MainActivity.java    From GpCollapsingToolbar with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ac_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    ImageView imageView = (ImageView) findViewById(R.id.image);
    mNestedScroll = (NestedScrollView) findViewById(R.id.nestedScroll);
    mAppBarLayout = (AppBarLayout) findViewById(R.id.app_bar);
    mParallaxView = (ScrollView) findViewById(R.id.parallax);
    mFab = (FloatingActionButton) findViewById(R.id.fab);
    setSupportActionBar(toolbar);

    setupToolbarAndStatusBar();
    Picasso.with(this).load("https://i.ytimg.com/vi/Un5SEJ8MyPc/maxresdefault.jpg")
            .into(imageView);
    mScrollController.onCreate(savedInstanceState);
}
 
Example #19
Source File: MovieDetailsPresenter.java    From qvod with MIT License 6 votes vote down vote up
private void initListener() {
    //finish
    getView().toolBar.setNavigationOnClickListener(view -> getView().onBackPressed());
    //
    getView().nsvTitle.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
        @Override
        public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
            scrollChangeHeader(scrollY);
        }
    });
    getView().llLoading.setOnReloadListener(v -> {
        if (JUtils.isNetWorkAvilable())
            //onClick
            initData();
    });
    getView().toolBar.setOnMenuItemClickListener(item -> {
        if (item.getItemId() == R.id.actionbar_more) {
            WebViewActivity.startAction(getView(), positionData.getAlt());
        }
        return false;
    });
}
 
Example #20
Source File: PhotoDetailActivity.java    From BaoKanAndroid with MIT License 6 votes vote down vote up
/**
 * 准备UI
 */
private void prepareUI() {
    mViewPager = (ViewPager) findViewById(R.id.vp_photo_detail_viewPager);
    mTopLayout = findViewById(R.id.ll_photo_detail_top_layout);
    mPageTextView = (TextView) findViewById(R.id.tv_photo_detail_page);
    mReportTextView = (TextView) findViewById(R.id.tv_photo_detail_report);
    mProgressBar = (ProgressBar) findViewById(R.id.pb_photo_detail_progressbar);
    mBottomLayout = findViewById(R.id.ll_photo_detail_bottom_layout);
    mCaptionScriollView = (NestedScrollView) findViewById(R.id.nsv_photo_detail_caption_scrollview);
    mCaptionTextView = (TextView) findViewById(R.id.tv_photo_detail_caption);
    mBackButton = (ImageButton) findViewById(R.id.ib_photo_detail_bottom_bar_back);
    mEditButton = (ImageButton) findViewById(R.id.ib_photo_detail_bottom_bar_edit);
    mCommentButton = (ImageButton) findViewById(R.id.ib_photo_detail_bottom_bar_comment);
    mCollectionButton = (ImageButton) findViewById(R.id.ib_photo_detail_bottom_bar_collection);
    mShareButton = (ImageButton) findViewById(R.id.ib_photo_detail_bottom_bar_share);
    mPlnumTextView = (TextView) findViewById(R.id.tv_photo_detail_plnum);

    // 监听点击事件
    mReportTextView.setOnClickListener(this);
    mBackButton.setOnClickListener(this);
    mEditButton.setOnClickListener(this);
    mCommentButton.setOnClickListener(this);
    mCollectionButton.setOnClickListener(this);
    mShareButton.setOnClickListener(this);

}
 
Example #21
Source File: Utils.java    From smooth-app-bar-layout with Apache License 2.0 6 votes vote down vote up
public static boolean syncOffset(SmoothAppBarLayout smoothAppBarLayout, View target, int verticalOffset, View scroll) {
  boolean isSelected = target == scroll;
  if (scroll instanceof NestedScrollView) {
    NestedScrollView nestedScrollView = (NestedScrollView) scroll;
    if (nestedScrollView.getScrollY() < verticalOffset || (!isSelected && isScrollToTop(target))) {
      nestedScrollView.scrollTo(0, verticalOffset);
    }
    if (isSelected && (nestedScrollView.getScrollY() < verticalOffset || verticalOffset == 0)) {
      nestedScrollView.scrollTo(0, 0);
      smoothAppBarLayout.syncOffset(0);
    }
  } else if (scroll instanceof RecyclerView) {
    RecyclerView recyclerView = (RecyclerView) scroll;
    boolean isAccuracy = recyclerView.getLayoutManager().findViewByPosition(ObservableRecyclerView.HEADER_VIEW_POSITION) != null;
    if (isAccuracy && recyclerView.computeVerticalScrollOffset() < verticalOffset) {
      recyclerView.scrollBy(0, verticalOffset - recyclerView.computeVerticalScrollOffset());
    } else if (!isSelected && isScrollToTop(target)) {
      recyclerView.scrollToPosition(ObservableRecyclerView.HEADER_VIEW_POSITION);
    }
    if (isAccuracy && isSelected && (recyclerView.computeVerticalScrollOffset() < verticalOffset || verticalOffset == 0)) {
      recyclerView.scrollToPosition(ObservableRecyclerView.HEADER_VIEW_POSITION);
      smoothAppBarLayout.syncOffset(0);
    }
  }
  return true;
}
 
Example #22
Source File: BottomSheetBehaviorManager.java    From react-native-bottom-sheet-behavior with MIT License 6 votes vote down vote up
/**
 * BottomSheetBehaviorView inherits a NestedScrollView in order to work
 * with the anchor point, but it breaks any ReactNestedScrollView child,
 * so we are changing the behavior of ReactNestedScrollView to disable
 * the nested scroll of the bottom sheet, and enable when the child scroll
 * reaches the top offset.
 */
private void attachNestedScrollChild(final BottomSheetBehaviorView parent, final NestedScrollView nestedScroll) {
    nestedScroll.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            int action = event.getAction();
            if (action == MotionEvent.ACTION_MOVE) {
                if (nestedScroll.computeVerticalScrollOffset() == 0) {
                    parent.startNestedScroll(ViewCompat.SCROLL_AXIS_VERTICAL);
                } else {
                    parent.stopNestedScroll();
                }
            }
            return nestedScroll.onTouchEvent(event);
        }
    });
}
 
Example #23
Source File: ObservableNestedScrollView.java    From smooth-app-bar-layout with Apache License 2.0 5 votes vote down vote up
@Override
public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
  if (mOnScrollListener != null) {
    mOnScrollListener.onScrollChanged(mNestedScrollView,
        scrollX,
        scrollY,
        scrollX - oldScrollX,
        scrollY - oldScrollY,
        true);
  }
}
 
Example #24
Source File: BaseDetailDelegate.java    From CoreModule with Apache License 2.0 5 votes vote down vote up
@Override
public void initWidget() {
    super.initWidget();
    NestedScrollView nestedScrollView = get(R.id.nested_scrollview);
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams
            .MATCH_PARENT);
    nestedScrollView.addView(View.inflate(getActivity(), getContentLayoutId(), null), params);
    nestedScrollView.invalidate();
}
 
Example #25
Source File: ScrollController.java    From GpCollapsingToolbar with Apache License 2.0 5 votes vote down vote up
private int getScrollRange(NestedScrollView view) {
    if (view == null) {
        return -1;
    }

    int scrollRange = 0;
    if (view.getChildCount() > 0) {
        View child = view.getChildAt(0);
        scrollRange = Math.max(0,
                child.getHeight() - (view.getHeight() - view.getPaddingBottom() - view.getPaddingTop()));
    }
    return scrollRange;
}
 
Example #26
Source File: ScrollController.java    From GpCollapsingToolbar with Apache License 2.0 5 votes vote down vote up
public void onResume(OnTotalScrollChangeListener listener,
                     @NonNull AppBarLayout appBar,
                     @NonNull NestedScrollView nestedScroll) {

    mOnTotalScrollChangeListener = listener;
    mAppBarScrollRange = appBar.getTotalScrollRange();
    mNestedScrollRange = getScrollRange(nestedScroll);
}
 
Example #27
Source File: ForumFragment.java    From ForPDA with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    baseInflateFragment(inflater, R.layout.fragment_forum);
    treeContainer = (NestedScrollView) findViewById(R.id.nested_scroll_view);
    return view;
}
 
Example #28
Source File: BackdropBottomSheetBehavior.java    From react-native-bottom-sheet-behavior with MIT License 5 votes vote down vote up
@Override
public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
  if (dependency instanceof NestedScrollView) {
    try {
      RNBottomSheetBehavior.from(dependency);
      return true;
    }
    catch (IllegalArgumentException e){}
  }

  return false;
}
 
Example #29
Source File: MainFragment.java    From pe-protector-moe with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onStart() {
    super.onStart();
    NestedScrollView mScrollView = getView().findViewById(R.id.nestedScrollView);
    MaterialViewPagerHelper.registerScrollView(getActivity(), mScrollView);
    onFleetChange(null);
    onResChange(null);
}
 
Example #30
Source File: MainActivity.java    From GpCollapsingToolbar with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPause() {
    super.onPause();
    mFab.setOnClickListener(null);
    mNestedScroll.setOnScrollChangeListener((NestedScrollView.OnScrollChangeListener) null);
    mAppBarLayout.removeOnOffsetChangedListener(this);
    mScrollController.onPause();
}