Java Code Examples for com.github.ksoichiro.android.observablescrollview.ObservableScrollView#getCurrentScrollY()
The following examples show how to use
com.github.ksoichiro.android.observablescrollview.ObservableScrollView#getCurrentScrollY() .
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: ViewPagerTabActivity.java From UltimateAndroid with Apache License 2.0 | 6 votes |
private void adjustToolbarForScrollViews(ScrollState scrollState, View view) { int toolbarHeight = mToolbarView.getHeight(); final ObservableScrollView scrollView = (ObservableScrollView) view.findViewById(R.id.scroll); if (scrollView == null) { return; } if (scrollState == ScrollState.UP) { if (toolbarHeight < scrollView.getCurrentScrollY()) { hideToolbar(); } else if (scrollView.getCurrentScrollY() < toolbarHeight) { showToolbar(); } } else if (scrollState == ScrollState.DOWN) { if (toolbarHeight < scrollView.getCurrentScrollY()) { showToolbar(); } } }
Example 2
Source File: ViewPagerTabActivity.java From UltimateAndroid with Apache License 2.0 | 6 votes |
private void propagateToolbarStateForScrollView(boolean isShown, View view, int toolbarHeight) { ObservableScrollView scrollView = (ObservableScrollView) view.findViewById(R.id.scroll); if (scrollView == null) { return; } if (isShown) { // Scroll up if (0 < scrollView.getCurrentScrollY()) { scrollView.scrollTo(0, 0); } } else { // Scroll down (to hide padding) if (scrollView.getCurrentScrollY() < toolbarHeight) { scrollView.scrollTo(0, toolbarHeight); } } }
Example 3
Source File: ViewPagerTabScrollViewActivity.java From UltimateAndroid with Apache License 2.0 | 5 votes |
@Override public void onUpOrCancelMotionEvent(ScrollState scrollState) { mBaseTranslationY = 0; Fragment fragment = getCurrentFragment(); if (fragment == null) { return; } View view = fragment.getView(); if (view == null) { return; } int toolbarHeight = mToolbarView.getHeight(); final ObservableScrollView scrollView = (ObservableScrollView) view.findViewById(R.id.scroll); if (scrollState == ScrollState.UP) { if (toolbarHeight < scrollView.getCurrentScrollY()) { hideToolbar(); } else if (scrollView.getCurrentScrollY() < toolbarHeight) { showToolbar(); } } else if (scrollState == ScrollState.DOWN) { if (toolbarHeight < scrollView.getCurrentScrollY()) { showToolbar(); } } }
Example 4
Source File: ViewPagerTabScrollViewActivity.java From UltimateAndroid with Apache License 2.0 | 5 votes |
private void propagateToolbarState(boolean isShown) { int toolbarHeight = mToolbarView.getHeight(); // Set scrollY for the fragments that are not created yet mPagerAdapter.setScrollY(isShown ? 0 : toolbarHeight); // Set scrollY for the active fragments for (int i = 0; i < mPagerAdapter.getCount(); i++) { // Skip current item if (i == mPager.getCurrentItem()) { continue; } // Skip destroyed or not created item Fragment f = mPagerAdapter.getItemAt(i); if (f == null) { continue; } ObservableScrollView scrollView = (ObservableScrollView) f.getView().findViewById(R.id.scroll); if (isShown) { // Scroll up if (0 < scrollView.getCurrentScrollY()) { scrollView.scrollTo(0, 0); } } else { // Scroll down (to hide padding) if (scrollView.getCurrentScrollY() < toolbarHeight) { scrollView.scrollTo(0, toolbarHeight); } } } }
Example 5
Source File: ViewPagerTabScrollViewActivity.java From Android-ObservableScrollView with Apache License 2.0 | 5 votes |
@Override public void onUpOrCancelMotionEvent(ScrollState scrollState) { mBaseTranslationY = 0; Fragment fragment = getCurrentFragment(); if (fragment == null) { return; } View view = fragment.getView(); if (view == null) { return; } int toolbarHeight = mToolbarView.getHeight(); final ObservableScrollView scrollView = (ObservableScrollView) view.findViewById(R.id.scroll); if (scrollView == null) { return; } int scrollY = scrollView.getCurrentScrollY(); if (scrollState == ScrollState.DOWN) { showToolbar(); } else if (scrollState == ScrollState.UP) { if (toolbarHeight <= scrollY) { hideToolbar(); } else { showToolbar(); } } else { // Even if onScrollChanged occurs without scrollY changing, toolbar should be adjusted if (toolbarIsShown() || toolbarIsHidden()) { // Toolbar is completely moved, so just keep its state // and propagate it to other pages propagateToolbarState(toolbarIsShown()); } else { // Toolbar is moving but doesn't know which to move: // you can change this to hideToolbar() showToolbar(); } } }
Example 6
Source File: ViewPagerTabScrollViewActivity.java From Android-ObservableScrollView with Apache License 2.0 | 5 votes |
private void propagateToolbarState(boolean isShown) { int toolbarHeight = mToolbarView.getHeight(); // Set scrollY for the fragments that are not created yet mPagerAdapter.setScrollY(isShown ? 0 : toolbarHeight); // Set scrollY for the active fragments for (int i = 0; i < mPagerAdapter.getCount(); i++) { // Skip current item if (i == mPager.getCurrentItem()) { continue; } // Skip destroyed or not created item Fragment f = mPagerAdapter.getItemAt(i); if (f == null) { continue; } View view = f.getView(); if (view == null) { continue; } ObservableScrollView scrollView = (ObservableScrollView) view.findViewById(R.id.scroll); if (isShown) { // Scroll up if (0 < scrollView.getCurrentScrollY()) { scrollView.scrollTo(0, 0); } } else { // Scroll down (to hide padding) if (scrollView.getCurrentScrollY() < toolbarHeight) { scrollView.scrollTo(0, toolbarHeight); } } } }