android.support.v4.view.ViewCompat#hasTransientState ( )源码实例Demo

下面列出了android.support.v4.view.ViewCompat#hasTransientState ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: PullToRefreshLibrary   文件: ExtendableListView.java
/**
 * 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--;
			}
		}
	}
}
 
源代码2 项目: UltimateAndroid   文件: ExtendableListView.java
/**
 * 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--;
            }
        }
    }
}
 
源代码3 项目: UltimateAndroid   文件: ExtendableListView.java
/**
 * 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--;
            }
        }
    }
}
 
源代码4 项目: PullToRefreshLibrary   文件: ExtendableListView.java
/**
 * 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);
	}
}
 
源代码5 项目: UltimateAndroid   文件: ExtendableListView.java
/**
 * 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);
    }
}
 
源代码6 项目: UltimateAndroid   文件: ExtendableListView.java
/**
 * 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();
}
 
源代码7 项目: UltimateAndroid   文件: ExtendableListView.java
/**
 * 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);
    }
}
 
源代码8 项目: UltimateAndroid   文件: ExtendableListView.java
/**
 * 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();
}
 
源代码9 项目: PullToRefreshLibrary   文件: ExtendableListView.java
/**
 * 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();
}
 
 同类方法