Java Code Examples for android.support.v4.view.ViewCompat#hasTransientState()
The following examples show how to use
android.support.v4.view.ViewCompat#hasTransientState() .
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: ExtendableListView.java From PullToRefreshLibrary with Apache License 2.0 | 6 votes |
/** * Makes sure that the size of mScrapViews does not exceed the size of * mActiveViews. (This can happen if an adapter does not recycle its * views). */ private void pruneScrapViews() { final int maxViews = mActiveViews.length; final int viewTypeCount = mViewTypeCount; final ArrayList<View>[] scrapViews = mScrapViews; for (int i = 0; i < viewTypeCount; ++i) { final ArrayList<View> scrapPile = scrapViews[i]; int size = scrapPile.size(); final int extras = size - maxViews; size--; for (int j = 0; j < extras; j++) { removeDetachedView(scrapPile.remove(size--), false); } } if (mTransientStateViews != null) { for (int i = 0; i < mTransientStateViews.size(); i++) { final View v = mTransientStateViews.valueAt(i); if (!ViewCompat.hasTransientState(v)) { mTransientStateViews.removeAt(i); i--; } } } }
Example 2
Source File: ExtendableListView.java From UltimateAndroid with Apache License 2.0 | 6 votes |
/** * Makes sure that the size of mScrapViews does not exceed the size of mActiveViews. * (This can happen if an adapter does not recycle its views). */ private void pruneScrapViews() { final int maxViews = mActiveViews.length; final int viewTypeCount = mViewTypeCount; final ArrayList<View>[] scrapViews = mScrapViews; for (int i = 0; i < viewTypeCount; ++i) { final ArrayList<View> scrapPile = scrapViews[i]; int size = scrapPile.size(); final int extras = size - maxViews; size--; for (int j = 0; j < extras; j++) { removeDetachedView(scrapPile.remove(size--), false); } } if (mTransientStateViews != null) { for (int i = 0; i < mTransientStateViews.size(); i++) { final View v = mTransientStateViews.valueAt(i); if (!ViewCompat.hasTransientState(v)) { mTransientStateViews.removeAt(i); i--; } } } }
Example 3
Source File: ExtendableListView.java From UltimateAndroid with Apache License 2.0 | 6 votes |
/** * Makes sure that the size of mScrapViews does not exceed the size of mActiveViews. * (This can happen if an adapter does not recycle its views). */ private void pruneScrapViews() { final int maxViews = mActiveViews.length; final int viewTypeCount = mViewTypeCount; final ArrayList<View>[] scrapViews = mScrapViews; for (int i = 0; i < viewTypeCount; ++i) { final ArrayList<View> scrapPile = scrapViews[i]; int size = scrapPile.size(); final int extras = size - maxViews; size--; for (int j = 0; j < extras; j++) { removeDetachedView(scrapPile.remove(size--), false); } } if (mTransientStateViews != null) { for (int i = 0; i < mTransientStateViews.size(); i++) { final View v = mTransientStateViews.valueAt(i); if (!ViewCompat.hasTransientState(v)) { mTransientStateViews.removeAt(i); i--; } } } }
Example 4
Source File: ExtendableListView.java From PullToRefreshLibrary with Apache License 2.0 | 5 votes |
/** * 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 5
Source File: ExtendableListView.java From UltimateAndroid with Apache License 2.0 | 5 votes |
/** * 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 6
Source File: ExtendableListView.java From UltimateAndroid with Apache License 2.0 | 5 votes |
/** * 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 7
Source File: ExtendableListView.java From UltimateAndroid with Apache License 2.0 | 5 votes |
/** * 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: ExtendableListView.java From UltimateAndroid with Apache License 2.0 | 5 votes |
/** * 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 9
Source File: ExtendableListView.java From PullToRefreshLibrary with Apache License 2.0 | 4 votes |
/** * 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(); }