Java Code Examples for android.view.View#hasTransientState()
The following examples show how to use
android.view.View#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: ZrcAbsListView.java From ZrcListView with MIT License | 6 votes |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) 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 (!v.hasTransientState()) { mTransientStateViews.removeAt(i); i--; } } } }
Example 2
Source File: ZrcAbsListView.java From AndroidStudyDemo with GNU General Public License v2.0 | 6 votes |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) 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 (!v.hasTransientState()) { mTransientStateViews.removeAt(i); i--; } } } }
Example 3
Source File: Presenter.java From TvRecyclerView with Apache License 2.0 | 5 votes |
/** * Utility method for removing all running animations on a view. */ protected static void cancelAnimationsRecursive(View view) { if (view != null && view.hasTransientState()) { view.animate().cancel(); if (view instanceof ViewGroup) { final int count = ((ViewGroup) view).getChildCount(); for (int i = 0; view.hasTransientState() && i < count; i++) { cancelAnimationsRecursive(((ViewGroup) view).getChildAt(i)); } } } }
Example 4
Source File: AbsHListView.java From Klyph with MIT License | 5 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). */ @SuppressLint ( "NewApi" ) 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 ); // this code is never executed on android < 16 if ( !v.hasTransientState() ) { mTransientStateViews.removeAt( i ); i--; } } } }
Example 5
Source File: Presenter.java From adt-leanback-support with Apache License 2.0 | 5 votes |
/** * Utility method for removing all running animations on a view. */ protected static void cancelAnimationsRecursive(View view) { if (view.hasTransientState()) { view.animate().cancel(); if (view instanceof ViewGroup) { final int count = ((ViewGroup) view).getChildCount(); for (int i = 0; view.hasTransientState() && i < count; i++) { cancelAnimationsRecursive(((ViewGroup) view).getChildAt(i)); } } } }
Example 6
Source File: am.java From MiBandDecompiled with Apache License 2.0 | 4 votes |
public static boolean a(View view) { return view.hasTransientState(); }
Example 7
Source File: ViewCompatJB.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
public static boolean hasTransientState(View view) { return view.hasTransientState(); }
Example 8
Source File: ViewCompatJB.java From adt-leanback-support with Apache License 2.0 | 4 votes |
public static boolean hasTransientState(View view) { return view.hasTransientState(); }
Example 9
Source File: ZrcAbsListView.java From AndroidStudyDemo with GNU General Public License v2.0 | 4 votes |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) void scrapActiveViews() { final View[] activeViews = mActiveViews; final boolean hasListener = mRecyclerListener != null; 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(); int whichScrap = lp.viewType; activeViews[i] = null; final boolean scrapHasTransientState = Build.VERSION.SDK_INT >= 16 ? victim .hasTransientState() : false; if (!shouldRecycleViewType(whichScrap) || scrapHasTransientState) { if (whichScrap != ITEM_VIEW_TYPE_HEADER_OR_FOOTER && scrapHasTransientState) { removeDetachedView(victim, false); } if (scrapHasTransientState) { if (mAdapter != null && mAdapterHasStableIds) { if (mTransientStateViewsById == null) { mTransientStateViewsById = new LongSparseArray<View>(); } long id = mAdapter.getItemId(mFirstActivePosition + i); mTransientStateViewsById.put(id, victim); } else { if (mTransientStateViews == null) { mTransientStateViews = new SparseArrayCompat<View>(); } mTransientStateViews.put(mFirstActivePosition + i, victim); } } continue; } if (multipleScraps) { scrapViews = mScrapViews[whichScrap]; } victim.onStartTemporaryDetach(); lp.scrappedFromPosition = mFirstActivePosition + i; scrapViews.add(victim); if (hasListener) { mRecyclerListener.onMovedToScrapHeap(victim); } } } pruneScrapViews(); }
Example 10
Source File: AbsHListView.java From Klyph with MIT License | 4 votes |
/** * Put a view into the ScrapViews list. These views are unordered. * * @param scrap * The view to add */ @SuppressLint ( "NewApi" ) public void addScrapView( View scrap, int position ) { AbsHListView.LayoutParams lp = (AbsHListView.LayoutParams) scrap.getLayoutParams(); if ( lp == null ) { return; } lp.scrappedFromPosition = 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 = android.os.Build.VERSION.SDK_INT >= 16 ? scrap.hasTransientState() : false; 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>(); } scrap.onStartTemporaryDetach(); mTransientStateViews.put( position, scrap ); } return; } scrap.onStartTemporaryDetach(); if ( mViewTypeCount == 1 ) { mCurrentScrap.add( scrap ); } else { mScrapViews[viewType].add( scrap ); } if ( android.os.Build.VERSION.SDK_INT >= 14 ) { scrap.setAccessibilityDelegate( null ); } if ( mRecyclerListener != null ) { mRecyclerListener.onMovedToScrapHeap( scrap ); } }
Example 11
Source File: AbsHListView.java From Klyph with MIT License | 4 votes |
/** * Move all views remaining in mActiveViews to mScrapViews. */ @SuppressLint ( "NewApi" ) public void scrapActiveViews() { final View[] activeViews = mActiveViews; final boolean hasListener = mRecyclerListener != null; 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 AbsHListView.LayoutParams lp = (AbsHListView.LayoutParams) victim.getLayoutParams(); int whichScrap = lp.viewType; activeViews[i] = null; final boolean scrapHasTransientState = android.os.Build.VERSION.SDK_INT >= 16 ? victim.hasTransientState() : false; if ( !shouldRecycleViewType( whichScrap ) || scrapHasTransientState ) { // Do not move views that should be ignored if ( whichScrap != 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[whichScrap]; } victim.onStartTemporaryDetach(); lp.scrappedFromPosition = mFirstActivePosition + i; scrapViews.add( victim ); if ( android.os.Build.VERSION.SDK_INT >= 14 ) { victim.setAccessibilityDelegate( null ); } if ( hasListener ) { mRecyclerListener.onMovedToScrapHeap( victim ); } } } pruneScrapViews(); }
Example 12
Source File: ZrcAbsListView.java From AndroidStudyDemo with GNU General Public License v2.0 | 4 votes |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) void addScrapView(View scrap, int position) { final LayoutParams lp = (LayoutParams) scrap.getLayoutParams(); if (lp == null) { return; } lp.scrappedFromPosition = position; final int viewType = lp.viewType; if (!shouldRecycleViewType(viewType)) { return; } final boolean scrapHasTransientState = Build.VERSION.SDK_INT >= 16 ? scrap.hasTransientState() : false; if (scrapHasTransientState) { if (mAdapter != null && mAdapterHasStableIds) { if (mTransientStateViewsById == null) { mTransientStateViewsById = new LongSparseArray<View>(); } mTransientStateViewsById.put(lp.itemId, scrap); } else if (!mDataChanged) { if (mTransientStateViews == null) { mTransientStateViews = new SparseArrayCompat<View>(); } mTransientStateViews.put(position, scrap); } else { if (mSkippedScrap == null) { mSkippedScrap = new ArrayList<View>(); } mSkippedScrap.add(scrap); } } else { if (mViewTypeCount == 1) { mCurrentScrap.add(scrap); } else { mScrapViews[viewType].add(scrap); } if (mRecyclerListener != null) { mRecyclerListener.onMovedToScrapHeap(scrap); } } }
Example 13
Source File: ViewCompatJB.java From V.FlyoutTest with MIT License | 4 votes |
public static boolean hasTransientState(View view) { return view.hasTransientState(); }
Example 14
Source File: ViewCompatJB.java From guideshow with MIT License | 4 votes |
public static boolean hasTransientState(View view) { return view.hasTransientState(); }
Example 15
Source File: ViewUtils.java From Transitions-Everywhere with Apache License 2.0 | 4 votes |
@Override public boolean hasTransientState(@NonNull View view) { return view.hasTransientState(); }
Example 16
Source File: ZrcAbsListView.java From ZrcListView with MIT License | 4 votes |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) void addScrapView(View scrap, int position) { final LayoutParams lp = (LayoutParams) scrap.getLayoutParams(); if (lp == null) { return; } lp.scrappedFromPosition = position; final int viewType = lp.viewType; if (!shouldRecycleViewType(viewType)) { return; } final boolean scrapHasTransientState = Build.VERSION.SDK_INT >= 16 ? scrap .hasTransientState() : false; if (scrapHasTransientState) { if (mAdapter != null && mAdapterHasStableIds) { if (mTransientStateViewsById == null) { mTransientStateViewsById = new LongSparseArray<View>(); } mTransientStateViewsById.put(lp.itemId, scrap); } else if (!mDataChanged) { if (mTransientStateViews == null) { mTransientStateViews = new SparseArrayCompat<View>(); } mTransientStateViews.put(position, scrap); } else { if (mSkippedScrap == null) { mSkippedScrap = new ArrayList<View>(); } mSkippedScrap.add(scrap); } } else { if (mViewTypeCount == 1) { mCurrentScrap.add(scrap); } else { mScrapViews[viewType].add(scrap); } if (mRecyclerListener != null) { mRecyclerListener.onMovedToScrapHeap(scrap); } } }
Example 17
Source File: ZrcAbsListView.java From ZrcListView with MIT License | 4 votes |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) void scrapActiveViews() { final View[] activeViews = mActiveViews; final boolean hasListener = mRecyclerListener != null; 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(); int whichScrap = lp.viewType; activeViews[i] = null; final boolean scrapHasTransientState = Build.VERSION.SDK_INT >= 16 ? victim .hasTransientState() : false; if (!shouldRecycleViewType(whichScrap) || scrapHasTransientState) { if (whichScrap != ITEM_VIEW_TYPE_HEADER_OR_FOOTER && scrapHasTransientState) { removeDetachedView(victim, false); } if (scrapHasTransientState) { if (mAdapter != null && mAdapterHasStableIds) { if (mTransientStateViewsById == null) { mTransientStateViewsById = new LongSparseArray<View>(); } long id = mAdapter .getItemId(mFirstActivePosition + i); mTransientStateViewsById.put(id, victim); } else { if (mTransientStateViews == null) { mTransientStateViews = new SparseArrayCompat<View>(); } mTransientStateViews.put(mFirstActivePosition + i, victim); } } continue; } if (multipleScraps) { scrapViews = mScrapViews[whichScrap]; } victim.onStartTemporaryDetach(); lp.scrappedFromPosition = mFirstActivePosition + i; scrapViews.add(victim); if (hasListener) { mRecyclerListener.onMovedToScrapHeap(victim); } } } pruneScrapViews(); }
Example 18
Source File: ViewCompatJB.java From letv with Apache License 2.0 | 4 votes |
public static boolean hasTransientState(View view) { return view.hasTransientState(); }