Java Code Examples for android.support.v4.util.SparseArrayCompat#valueAt()

The following examples show how to use android.support.v4.util.SparseArrayCompat#valueAt() . 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: ParallaxViewPagerChangeListener.java    From ParallaxHeaderViewPager with MIT License 6 votes vote down vote up
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    int currentItem = mViewPager.getCurrentItem();
    if (positionOffsetPixels > 0) {
        SparseArrayCompat<ScrollTabHolder> scrollTabHolders = mAdapter.getScrollTabHolders();

        ScrollTabHolder fragmentContent;
        if (position < currentItem) {
            // Revealed the previous page
            fragmentContent = scrollTabHolders.valueAt(position);
        } else {
            // Revealed the next page
            fragmentContent = scrollTabHolders.valueAt(position + 1);
        }

        fragmentContent.adjustScroll((int) (mHeader.getHeight() + mHeader.getTranslationY()),
                mHeader.getHeight());
    }
}
 
Example 2
Source File: StickHeaderViewPager.java    From StickyHeaderViewPager with Apache License 2.0 6 votes vote down vote up
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    int currentItem = mViewPager.getCurrentItem();
    if (positionOffsetPixels > 0) {
        SparseArrayCompat<ScrollHolder> scrollTabHolders = mAdapter.getScrollTabHolders();

        ScrollHolder fragmentContent;
        if (position < currentItem) {
            fragmentContent = scrollTabHolders.valueAt(position);
        } else {
            fragmentContent = scrollTabHolders.valueAt(position + 1);
        }

        fragmentContent.adjustScroll((int) (mStickheader.getHeight() + mStickheader.getTranslationY()), mStickheader.getHeight());
    }
}
 
Example 3
Source File: MainActivity.java    From Android-ParallaxHeaderViewPager with Apache License 2.0 6 votes vote down vote up
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

	if (positionOffsetPixels > 0) {
		int currentItem = mViewPager.getCurrentItem();

		SparseArrayCompat<ScrollTabHolder> scrollTabHolders = mPagerAdapter.getScrollTabHolders();
		ScrollTabHolder currentHolder;

		if (position < currentItem) {
			currentHolder = scrollTabHolders.valueAt(position);
		} else {
			currentHolder = scrollTabHolders.valueAt(position + 1);
		}

		if (NEEDS_PROXY) {
			// TODO is not good
			currentHolder.adjustScroll(mHeader.getHeight() - mLastY);
			mHeader.postInvalidate();
		} else {
			currentHolder.adjustScroll((int) (mHeader.getHeight() + mHeader.getTranslationY()));
		}
	}
}
 
Example 4
Source File: MainActivity.java    From RefreashTabView with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageSelected(int position) {
    tabs.onPageSelected(position);
    reLocation = true;
    SparseArrayCompat<ScrollTabHolder> scrollTabHolders = adapter.getScrollTabHolders();
    ScrollTabHolder currentHolder = scrollTabHolders.valueAt(position);
    currentHolder.adjustScroll((int) (header.getHeight() + ViewHelper.getTranslationY(header)));// 修正滚出去的偏移量
}
 
Example 5
Source File: ParallaxViewPagerChangeListener.java    From ParallaxHeaderViewPager with MIT License 5 votes vote down vote up
@Override
public void onPageSelected(int position) {
    SparseArrayCompat<ScrollTabHolder> scrollTabHolders = mAdapter.getScrollTabHolders();

    if (scrollTabHolders == null || scrollTabHolders.size() != mNumFragments) {
        return;
    }

    ScrollTabHolder currentHolder = scrollTabHolders.valueAt(position);
    currentHolder.adjustScroll(
            (int) (mHeader.getHeight() + mHeader.getTranslationY()),
            mHeader.getHeight());
}
 
Example 6
Source File: StickHeaderViewPager.java    From StickyHeaderViewPager with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageSelected(int position) {
    SparseArrayCompat<ScrollHolder> scrollTabHolders = mAdapter.getScrollTabHolders();

    if (scrollTabHolders == null || scrollTabHolders.size() != mAdapter.getCount()) {
        return;
    }

    ScrollHolder currentHolder = scrollTabHolders.valueAt(position);
    currentHolder.adjustScroll((int) (mStickheader.getHeight() + mStickheader.getTranslationY()), mStickheader.getHeight());
}
 
Example 7
Source File: MainActivity.java    From Android-ParallaxHeaderViewPager with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageSelected(int position) {
	SparseArrayCompat<ScrollTabHolder> scrollTabHolders = mPagerAdapter.getScrollTabHolders();
	ScrollTabHolder currentHolder = scrollTabHolders.valueAt(position);
	if(NEEDS_PROXY){
		//TODO is not good 
		currentHolder.adjustScroll(mHeader.getHeight()-mLastY);
		mHeader.postInvalidate();
	}else{
		currentHolder.adjustScroll((int) (mHeader.getHeight() +mHeader.getTranslationY()));	
	}
}