android.support.v4.util.SparseArrayCompat Java Examples

The following examples show how to use android.support.v4.util.SparseArrayCompat. 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: MultiStackTabGroupScene.java    From scene with Apache License 2.0 6 votes vote down vote up
@NonNull
@Override
protected SparseArrayCompat<Scene> getSceneMap() {
    SparseArrayCompat<Scene> sparseArrayCompat = new SparseArrayCompat<>();

    Bundle bundle = new Bundle();
    bundle.putInt("index", 0);

    NavigationScene navigationScene = (NavigationScene) SceneInstanceUtility.getInstanceFromClass(NavigationScene.class,
            new NavigationSceneOptions(MultiStackTabChildScene.class, getBundle(0)).toBundle());

    sparseArrayCompat.put(R.id.menu_home, navigationScene);

    navigationScene = (NavigationScene) SceneInstanceUtility.getInstanceFromClass(NavigationScene.class,
            new NavigationSceneOptions(MultiStackTabChildScene.class, getBundle(1)).toBundle());

    sparseArrayCompat.put(R.id.menu_search, navigationScene);

    navigationScene = (NavigationScene) SceneInstanceUtility.getInstanceFromClass(NavigationScene.class,
            new NavigationSceneOptions(MultiStackTabChildScene.class, getBundle(2)).toBundle());

    sparseArrayCompat.put(R.id.menu_notifications, navigationScene);
    return sparseArrayCompat;
}
 
Example #2
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 #3
Source File: AdaptiveTableLayout.java    From AdaptiveTableLayout with MIT License 6 votes vote down vote up
private void init(Context context) {
    mViewHolders = new SparseMatrix<>();
    mLayoutDirectionHelper = new LayoutDirectionHelper(mLayoutDirection);
    mHeaderColumnViewHolders = new SparseArrayCompat<>();
    mHeaderRowViewHolders = new SparseArrayCompat<>();
    mDragAndDropPoints = new DragAndDropPoints();
    mState = new AdaptiveTableState();
    mManager = new AdaptiveTableManagerRTL(mLayoutDirectionHelper);
    mLastSwitchHeaderPoint = new Point();
    mVisibleArea = new Rect();
    // init scroll and fling helpers
    mScrollerRunnable = new SmoothScrollRunnable(this);
    mScrollerDragAndDropRunnable = new DragAndDropScrollRunnable(this);
    mRecycler = new Recycler();
    mSettings = new AdaptiveTableLayoutSettings();
    mScrollHelper = new ScrollHelper(context);
    mScrollHelper.setListener(this);
    mShadowHelper = new ShadowHelper(mLayoutDirectionHelper);
}
 
Example #4
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 #5
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 #6
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()));	
	}
}
 
Example #7
Source File: ExtendableListView.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * Put a view into the ScrapViews list. These views are unordered.
 *
 * @param scrap The view to add
 */
void addScrapView(View scrap, int position) {
    if (DBG) Log.d(TAG, "addScrapView position = " + position);

    LayoutParams lp = (LayoutParams) scrap.getLayoutParams();
    if (lp == null) {
        return;
    }

    lp.position = position;

    // Don't put header or footer views or views that should be ignored
    // into the scrap heap
    int viewType = lp.viewType;
    final boolean scrapHasTransientState = ViewCompat.hasTransientState(scrap);
    if (!shouldRecycleViewType(viewType) || scrapHasTransientState) {
        if (viewType != ITEM_VIEW_TYPE_HEADER_OR_FOOTER || scrapHasTransientState) {
            if (mSkippedScrap == null) {
                mSkippedScrap = new ArrayList<View>();
            }
            mSkippedScrap.add(scrap);
        }
        if (scrapHasTransientState) {
            if (mTransientStateViews == null) {
                mTransientStateViews = new SparseArrayCompat<View>();
            }
            mTransientStateViews.put(position, scrap);
        }
        return;
    }

    if (mViewTypeCount == 1) {
        mCurrentScrap.add(scrap);
    }
    else {
        mScrapViews[viewType].add(scrap);
    }
}
 
Example #8
Source File: NavDestination.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Sets a destination ID for an action ID.
 *
 * @param actionId action ID to bind
 * @param action action to associate with this action ID
 */
public void putAction(@IdRes int actionId, @NonNull NavAction action) {
    if (actionId == 0) {
        throw new IllegalArgumentException("Cannot have an action with actionId 0");
    }
    if (mActions == null) {
        mActions = new SparseArrayCompat<>();
    }
    mActions.put(actionId, action);
}
 
Example #9
Source File: SparseMatrix.java    From AdaptiveTableLayout with MIT License 5 votes vote down vote up
/**
 * Get all row's items
 *
 * @param row row index
 * @return Collection with row's Objects
 */
@NonNull
Collection<TObj> getRowItems(int row) {
    Collection<TObj> result = new LinkedList<>();
    SparseArrayCompat<TObj> array = mData.get(row);
    for (int count = array.size(), i = 0; i < count; i++) {
        int key = array.keyAt(i);
        TObj columnObj = array.get(key);
        if (columnObj != null) {
            result.add(columnObj);
        }

    }
    return result;
}
 
Example #10
Source File: SparseMatrix.java    From AdaptiveTableLayout with MIT License 5 votes vote down vote up
/**
 * Get all matrix's items
 *
 * @return Collection with column's Objects
 */
@NonNull
Collection<TObj> getAll() {
    Collection<TObj> result = new LinkedList<>();
    for (int countR = mData.size(), i = 0; i < countR; i++) {
        int rowKey = mData.keyAt(i);
        SparseArrayCompat<TObj> columns = mData.get(rowKey);
        for (int countC = columns.size(), j = 0; j < countC; j++) {
            int key = columns.keyAt(j);
            result.add(columns.get(key));
        }
    }
    return result;
}
 
Example #11
Source File: SparseMatrix.java    From AdaptiveTableLayout with MIT License 5 votes vote down vote up
/**
 * Remove item in row, column position int the matrix
 *
 * @param row    item row position
 * @param column item column position
 */
void remove(int row, int column) {
    SparseArrayCompat<TObj> array = mData.get(row);
    if (array != null) {
        array.remove(column);
    }
}
 
Example #12
Source File: DataBean.java    From RecyclerStickyHeaderView with Apache License 2.0 5 votes vote down vote up
@Override
public final IViewBinder provideViewBinder(StickyHeaderViewAdapter adapter, SparseArrayCompat<? extends IViewBinder> viewBinderPool, int position) {
    if (viewBinder == null) {
        viewBinder = viewBinderPool.get(getItemLayoutId(adapter));
    }
    return viewBinder;
}
 
Example #13
Source File: ExtendableListView.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * Move all views remaining in mActiveViews to mScrapViews.
 */
void scrapActiveViews() {
    final View[] activeViews = mActiveViews;
    final boolean multipleScraps = mViewTypeCount > 1;

    ArrayList<View> scrapViews = mCurrentScrap;
    final int count = activeViews.length;
    for (int i = count - 1; i >= 0; i--) {
        final View victim = activeViews[i];
        if (victim != null) {
            final LayoutParams lp = (LayoutParams) victim.getLayoutParams();
            activeViews[i] = null;

            final boolean scrapHasTransientState = ViewCompat.hasTransientState(victim);
            int viewType = lp.viewType;

            if (!shouldRecycleViewType(viewType) || scrapHasTransientState) {
                // Do not move views that should be ignored
                if (viewType != ITEM_VIEW_TYPE_HEADER_OR_FOOTER || scrapHasTransientState) {
                    removeDetachedView(victim, false);
                }
                if (scrapHasTransientState) {
                    if (mTransientStateViews == null) {
                        mTransientStateViews = new SparseArrayCompat<View>();
                    }
                    mTransientStateViews.put(mFirstActivePosition + i, victim);
                }
                continue;
            }

            if (multipleScraps) {
                scrapViews = mScrapViews[viewType];
            }
            lp.position = mFirstActivePosition + i;
            scrapViews.add(victim);
        }
    }

    pruneScrapViews();
}
 
Example #14
Source File: SparseMatrix.java    From AdaptiveTableLayout with MIT License 5 votes vote down vote up
/**
 * Put item to the matrix in row, column position.
 *
 * @param row    item row position
 * @param column item column  position
 * @param item   Object
 */
void put(int row, int column, @NonNull TObj item) {
    SparseArrayCompat<TObj> array = mData.get(row);
    if (array == null) {
        array = new SparseArrayCompat<>();
        array.put(column, item);
        mData.put(row, array);
    } else {
        array.put(column, item);
    }
}
 
Example #15
Source File: AdaptiveTableLayout.java    From AdaptiveTableLayout with MIT License 5 votes vote down vote up
/**
 * Method switch view holders in map (map with headers view holders).
 *
 * @param map       header view holder's map
 * @param fromIndex index from view holder
 * @param toIndex   index to view holder
 * @param type      type of items (column header or row header)
 */
@SuppressWarnings("unused")
private void switchHeaders(SparseArrayCompat<ViewHolder> map, int fromIndex, int toIndex, int type) {
    ViewHolder fromVh = map.get(fromIndex);

    if (fromVh != null) {
        map.remove(fromIndex);
        if (type == ViewHolderType.COLUMN_HEADER) {
            fromVh.setColumnIndex(toIndex);
        } else if (type == ViewHolderType.ROW_HEADER) {
            fromVh.setRowIndex(toIndex);
        }
    }

    ViewHolder toVh = map.get(toIndex);
    if (toVh != null) {
        map.remove(toIndex);
        if (type == ViewHolderType.COLUMN_HEADER) {
            toVh.setColumnIndex(fromIndex);
        } else if (type == ViewHolderType.ROW_HEADER) {
            toVh.setRowIndex(fromIndex);
        }
    }

    if (fromVh != null) {
        map.put(toIndex, fromVh);
    }

    if (toVh != null) {
        map.put(fromIndex, toVh);
    }
}
 
Example #16
Source File: ExtendableListView.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * Move all views remaining in mActiveViews to mScrapViews.
 */
void scrapActiveViews() {
    final View[] activeViews = mActiveViews;
    final boolean multipleScraps = mViewTypeCount > 1;

    ArrayList<View> scrapViews = mCurrentScrap;
    final int count = activeViews.length;
    for (int i = count - 1; i >= 0; i--) {
        final View victim = activeViews[i];
        if (victim != null) {
            final LayoutParams lp = (LayoutParams) victim.getLayoutParams();
            activeViews[i] = null;

            final boolean scrapHasTransientState = ViewCompat.hasTransientState(victim);
            int viewType = lp.viewType;

            if (!shouldRecycleViewType(viewType) || scrapHasTransientState) {
                // Do not move views that should be ignored
                if (viewType != ITEM_VIEW_TYPE_HEADER_OR_FOOTER || scrapHasTransientState) {
                    removeDetachedView(victim, false);
                }
                if (scrapHasTransientState) {
                    if (mTransientStateViews == null) {
                        mTransientStateViews = new SparseArrayCompat<View>();
                    }
                    mTransientStateViews.put(mFirstActivePosition + i, victim);
                }
                continue;
            }

            if (multipleScraps) {
                scrapViews = mScrapViews[viewType];
            }
            lp.position = mFirstActivePosition + i;
            scrapViews.add(victim);
        }
    }

    pruneScrapViews();
}
 
Example #17
Source File: ExtendableListView.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * Put a view into the ScrapViews list. These views are unordered.
 *
 * @param scrap The view to add
 */
void addScrapView(View scrap, int position) {
    if (DBG) Log.d(TAG, "addScrapView position = " + position);

    LayoutParams lp = (LayoutParams) scrap.getLayoutParams();
    if (lp == null) {
        return;
    }

    lp.position = position;

    // Don't put header or footer views or views that should be ignored
    // into the scrap heap
    int viewType = lp.viewType;
    final boolean scrapHasTransientState = ViewCompat.hasTransientState(scrap);
    if (!shouldRecycleViewType(viewType) || scrapHasTransientState) {
        if (viewType != ITEM_VIEW_TYPE_HEADER_OR_FOOTER || scrapHasTransientState) {
            if (mSkippedScrap == null) {
                mSkippedScrap = new ArrayList<View>();
            }
            mSkippedScrap.add(scrap);
        }
        if (scrapHasTransientState) {
            if (mTransientStateViews == null) {
                mTransientStateViews = new SparseArrayCompat<View>();
            }
            mTransientStateViews.put(position, scrap);
        }
        return;
    }

    if (mViewTypeCount == 1) {
        mCurrentScrap.add(scrap);
    }
    else {
        mScrapViews[viewType].add(scrap);
    }
}
 
Example #18
Source File: FragmentActivity.java    From letv with Apache License 2.0 5 votes vote down vote up
protected void onCreate(@Nullable Bundle savedInstanceState) {
    List list = null;
    this.mFragments.attachHost(null);
    super.onCreate(savedInstanceState);
    NonConfigurationInstances nc = (NonConfigurationInstances) getLastNonConfigurationInstance();
    if (nc != null) {
        this.mFragments.restoreLoaderNonConfig(nc.loaders);
    }
    if (savedInstanceState != null) {
        Parcelable p = savedInstanceState.getParcelable(FRAGMENTS_TAG);
        FragmentController fragmentController = this.mFragments;
        if (nc != null) {
            list = nc.fragments;
        }
        fragmentController.restoreAllState(p, list);
        if (savedInstanceState.containsKey(NEXT_CANDIDATE_REQUEST_INDEX_TAG)) {
            this.mNextCandidateRequestIndex = savedInstanceState.getInt(NEXT_CANDIDATE_REQUEST_INDEX_TAG);
            int[] requestCodes = savedInstanceState.getIntArray(ALLOCATED_REQUEST_INDICIES_TAG);
            String[] fragmentWhos = savedInstanceState.getStringArray(REQUEST_FRAGMENT_WHO_TAG);
            if (requestCodes == null || fragmentWhos == null || requestCodes.length != fragmentWhos.length) {
                Log.w(TAG, "Invalid requestCode mapping in savedInstanceState.");
            } else {
                this.mPendingFragmentActivityResults = new SparseArrayCompat(requestCodes.length);
                for (int i = 0; i < requestCodes.length; i++) {
                    this.mPendingFragmentActivityResults.put(requestCodes[i], fragmentWhos[i]);
                }
            }
        }
    }
    if (this.mPendingFragmentActivityResults == null) {
        this.mPendingFragmentActivityResults = new SparseArrayCompat();
        this.mNextCandidateRequestIndex = 0;
    }
    this.mFragments.dispatchCreate();
}
 
Example #19
Source File: HListView.java    From letv with Apache License 2.0 5 votes vote down vote up
@Deprecated
public long[] getCheckItemIds() {
    if (this.mAdapter != null && this.mAdapter.hasStableIds()) {
        return getCheckedItemIds();
    }
    if (this.mChoiceMode == 0 || this.mCheckStates == null || this.mAdapter == null) {
        return new long[0];
    }
    SparseArrayCompat<Boolean> states = this.mCheckStates;
    int count = states.size();
    long[] ids = new long[count];
    ListAdapter adapter = this.mAdapter;
    int i = 0;
    int checkedCount = 0;
    while (i < count) {
        int checkedCount2;
        if (((Boolean) states.valueAt(i)).booleanValue()) {
            checkedCount2 = checkedCount + 1;
            ids[checkedCount] = adapter.getItemId(states.keyAt(i));
        } else {
            checkedCount2 = checkedCount;
        }
        i++;
        checkedCount = checkedCount2;
    }
    if (checkedCount == count) {
        return ids;
    }
    long[] result = new long[checkedCount];
    System.arraycopy(ids, 0, result, 0, checkedCount);
    return result;
}
 
Example #20
Source File: AbsHListView.java    From letv with Apache License 2.0 5 votes vote down vote up
@TargetApi(11)
public void setChoiceMode(int choiceMode) {
    this.mChoiceMode = choiceMode;
    if (VERSION.SDK_INT >= 11 && this.mChoiceActionMode != null) {
        if (VERSION.SDK_INT >= 11) {
            ((ActionMode) this.mChoiceActionMode).finish();
        }
        this.mChoiceActionMode = null;
    }
    if (this.mChoiceMode != 0) {
        if (this.mCheckStates == null) {
            this.mCheckStates = new SparseArrayCompat();
        }
        if (this.mCheckedIdStates == null && this.mAdapter != null && this.mAdapter.hasStableIds()) {
            this.mCheckedIdStates = new LongSparseArray();
        }
        if (VERSION.SDK_INT >= 11 && this.mChoiceMode == 3) {
            clearChoices();
            setLongClickable(true);
        }
    }
}
 
Example #21
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 #22
Source File: CircularRevealDrawable.java    From WIFIADB with Apache License 2.0 5 votes vote down vote up
public CircularRevealDrawable() {
    super();
    mPaint = new Paint();

    mResources = MyApp.getContext().getResources();
    mDefaultColor = ResourcesCompat.getColor(mResources,android.R.color.white,null);

    mColorMap = new SparseArrayCompat<>();
    mCurrentColor = EOF_COLOR;
    mNextColor = EOF_COLOR;
}
 
Example #23
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 #24
Source File: HeaderAndFooterAdapterWrapper.java    From NoListAdapter with Apache License 2.0 5 votes vote down vote up
public void addHeader(RecyclerViewBinder headerBinder) {
    if (headerBinderPool == null) {
        headerBinderPool = new SparseArrayCompat<>();
        headerBinderList = new ArrayList<>();
    }
    headerBinderPool.put(headerBinder.getItemLayoutId(this), headerBinder);
    headerBinderList.add(headerBinder);
}
 
Example #25
Source File: HeaderAndFooterAdapterWrapper.java    From NoListAdapter with Apache License 2.0 5 votes vote down vote up
public void addFooter(RecyclerViewBinder footerBinder) {
    if (footerBinderPool == null) {
        footerBinderPool = new SparseArrayCompat<>();
        footerBinderList = new ArrayList<>();
    }
    footerBinderPool.put(footerBinder.getItemLayoutId(this), footerBinder);
    footerBinderList.add(footerBinder);
}
 
Example #26
Source File: DataBean.java    From NoListAdapter with Apache License 2.0 5 votes vote down vote up
@Override
public final IViewBinder provideViewBinder(IListAdapter adapter, SparseArrayCompat<? extends IViewBinder> viewBinderPool, int position) {
    if (viewBinder == null) {
        viewBinder = viewBinderPool.get(getItemLayoutId(adapter));
    }
    return viewBinder;
}
 
Example #27
Source File: SparseArrayUtils.java    From standardlib with Apache License 2.0 5 votes vote down vote up
public static <T> List<T> asList(SparseArrayCompat<T> sparseArray) {
    if (sparseArray == null) {
        return null;
    }

    ArrayList<T> list = new ArrayList<>(sparseArray.size());
    for (int i = 0; i < sparseArray.size(); i++) {
        list.add(sparseArray.valueAt(i));
    }
    return list;
}
 
Example #28
Source File: ExtendableListView.java    From PullToRefreshLibrary with Apache License 2.0 5 votes vote down vote up
/**
 * Put a view into the ScrapViews list. These views are unordered.
 * 
 * @param scrap
 *            The view to add
 */
void addScrapView(View scrap, int position) {
	if (DBG)
		Log.d(TAG, "addScrapView position = " + position);

	LayoutParams lp = (LayoutParams) scrap.getLayoutParams();
	if (lp == null) {
		return;
	}

	lp.position = position;

	// Don't put header or footer views or views that should be ignored
	// into the scrap heap
	int viewType = lp.viewType;
	final boolean scrapHasTransientState = ViewCompat
			.hasTransientState(scrap);
	if (!shouldRecycleViewType(viewType) || scrapHasTransientState) {
		if (viewType != ITEM_VIEW_TYPE_HEADER_OR_FOOTER
				|| scrapHasTransientState) {
			if (mSkippedScrap == null) {
				mSkippedScrap = new ArrayList<View>();
			}
			mSkippedScrap.add(scrap);
		}
		if (scrapHasTransientState) {
			if (mTransientStateViews == null) {
				mTransientStateViews = new SparseArrayCompat<View>();
			}
			mTransientStateViews.put(position, scrap);
		}
		return;
	}

	if (mViewTypeCount == 1) {
		mCurrentScrap.add(scrap);
	} else {
		mScrapViews[viewType].add(scrap);
	}
}
 
Example #29
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 #30
Source File: SlidingPagerAdapter.java    From RefreashTabView with Apache License 2.0 5 votes vote down vote up
public SlidingPagerAdapter(FragmentManager fm, Context context, ViewPager pager) {
    super(fm);
    fragments = new ScrollTabHolderFragment[PageAdapterTab.values().length];
    this.context = context;
    mScrollTabHolders = new SparseArrayCompat<ScrollTabHolder>();
    init(fm);
}