Java Code Examples for android.support.v4.util.ArrayMap#isEmpty()
The following examples show how to use
android.support.v4.util.ArrayMap#isEmpty() .
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: SharedElementUtils.java From scene with Apache License 2.0 | 6 votes |
/** * Guarantee order: Parent -> Child * Make sure that Parent will not overwrite Child when adding Overlay */ public static List<NonNullPair<String, View>> sortSharedElementList(ArrayMap<String, View> sharedElements) { List<NonNullPair<String, View>> list = new ArrayList<>(); boolean isFirstRun = true; while (!sharedElements.isEmpty()) { final int numSharedElements = sharedElements.size(); for (int i = numSharedElements - 1; i >= 0; i--) { final View view = sharedElements.valueAt(i); final String name = sharedElements.keyAt(i); if (isFirstRun && (view == null || !view.isAttachedToWindow() || name == null)) { sharedElements.removeAt(i); } else if (!isNested(view, sharedElements)) { list.add(NonNullPair.create(name, view)); sharedElements.removeAt(i); } } isFirstRun = false; } return list; }
Example 2
Source File: BackStackRecord.java From adt-leanback-support with Apache License 2.0 | 6 votes |
/** * Remaps a name-to-View map, substituting different names for keys. * * @param inMap A list of keys found in the map, in the order in toGoInMap * @param toGoInMap A list of keys to use for the new map, in the order of inMap * @param namedViews The current mapping * @return A copy of namedViews with the keys coming from toGoInMap. */ private static ArrayMap<String, View> remapNames(ArrayList<String> inMap, ArrayList<String> toGoInMap, ArrayMap<String, View> namedViews) { if (namedViews.isEmpty()) { return namedViews; } ArrayMap<String, View> remappedViews = new ArrayMap<String, View>(); int numKeys = inMap.size(); for (int i = 0; i < numKeys; i++) { View view = namedViews.get(inMap.get(i)); if (view != null) { remappedViews.put(toGoInMap.get(i), view); } } return remappedViews; }
Example 3
Source File: BackStackRecord.java From letv with Apache License 2.0 | 5 votes |
private void setEpicenterIn(ArrayMap<String, View> namedViews, TransitionState state) { if (this.mSharedElementTargetNames != null && !namedViews.isEmpty()) { View epicenter = (View) namedViews.get(this.mSharedElementTargetNames.get(0)); if (epicenter != null) { state.enteringEpicenterView.epicenter = epicenter; } } }
Example 4
Source File: BackStackRecord.java From letv with Apache License 2.0 | 5 votes |
private static ArrayMap<String, View> remapNames(ArrayList<String> inMap, ArrayList<String> toGoInMap, ArrayMap<String, View> namedViews) { if (namedViews.isEmpty()) { return namedViews; } ArrayMap<String, View> remappedViews = new ArrayMap(); int numKeys = inMap.size(); for (int i = 0; i < numKeys; i++) { View view = (View) namedViews.get(inMap.get(i)); if (view != null) { remappedViews.put(toGoInMap.get(i), view); } } return remappedViews; }
Example 5
Source File: BackStackRecord.java From adt-leanback-support with Apache License 2.0 | 5 votes |
private void setEpicenterIn(ArrayMap<String, View> namedViews, TransitionState state) { if (mSharedElementTargetNames != null && !namedViews.isEmpty()) { // now we know the epicenter of the entering transition. View epicenter = namedViews .get(mSharedElementTargetNames.get(0)); if (epicenter != null) { state.enteringEpicenterView.epicenter = epicenter; } } }
Example 6
Source File: BackStackRecord.java From letv with Apache License 2.0 | 4 votes |
private boolean configureTransitions(int containerId, TransitionState state, boolean isBack, SparseArray<Fragment> firstOutFragments, SparseArray<Fragment> lastInFragments) { View sceneRoot = (ViewGroup) this.mManager.mContainer.onFindViewById(containerId); if (sceneRoot == null) { return false; } final Fragment inFragment = (Fragment) lastInFragments.get(containerId); Fragment outFragment = (Fragment) firstOutFragments.get(containerId); Object enterTransition = getEnterTransition(inFragment, isBack); Object sharedElementTransition = getSharedElementTransition(inFragment, outFragment, isBack); Object exitTransition = getExitTransition(outFragment, isBack); ArrayMap<String, View> namedViews = null; ArrayList<View> sharedElementTargets = new ArrayList(); if (sharedElementTransition != null) { namedViews = remapSharedElements(state, outFragment, isBack); if (namedViews.isEmpty()) { sharedElementTransition = null; namedViews = null; } else { SharedElementCallback callback = isBack ? outFragment.mEnterTransitionCallback : inFragment.mEnterTransitionCallback; if (callback != null) { callback.onSharedElementStart(new ArrayList(namedViews.keySet()), new ArrayList(namedViews.values()), null); } prepareSharedElementTransition(state, sceneRoot, sharedElementTransition, inFragment, outFragment, isBack, sharedElementTargets); } } if (enterTransition == null && sharedElementTransition == null && exitTransition == null) { return false; } ArrayList<View> exitingViews = new ArrayList(); exitTransition = captureExitingViews(exitTransition, outFragment, exitingViews, namedViews, state.nonExistentView); if (!(this.mSharedElementTargetNames == null || namedViews == null)) { View epicenterView = (View) namedViews.get(this.mSharedElementTargetNames.get(0)); if (epicenterView != null) { if (exitTransition != null) { FragmentTransitionCompat21.setEpicenter(exitTransition, epicenterView); } if (sharedElementTransition != null) { FragmentTransitionCompat21.setEpicenter(sharedElementTransition, epicenterView); } } } ViewRetriever viewRetriever = new ViewRetriever() { public View getView() { return inFragment.getView(); } }; ArrayList<View> enteringViews = new ArrayList(); ArrayMap<String, View> renamedViews = new ArrayMap(); boolean allowOverlap = true; if (inFragment != null) { allowOverlap = isBack ? inFragment.getAllowReturnTransitionOverlap() : inFragment.getAllowEnterTransitionOverlap(); } Object transition = FragmentTransitionCompat21.mergeTransitions(enterTransition, exitTransition, sharedElementTransition, allowOverlap); if (transition != null) { FragmentTransitionCompat21.addTransitionTargets(enterTransition, sharedElementTransition, sceneRoot, viewRetriever, state.nonExistentView, state.enteringEpicenterView, state.nameOverrides, enteringViews, namedViews, renamedViews, sharedElementTargets); excludeHiddenFragmentsAfterEnter(sceneRoot, state, containerId, transition); FragmentTransitionCompat21.excludeTarget(transition, state.nonExistentView, true); excludeHiddenFragments(state, containerId, transition); FragmentTransitionCompat21.beginDelayedTransition(sceneRoot, transition); FragmentTransitionCompat21.cleanupTransitions(sceneRoot, state.nonExistentView, enterTransition, enteringViews, exitTransition, exitingViews, sharedElementTransition, sharedElementTargets, transition, state.hiddenFragmentViews, renamedViews); } if (transition != null) { return true; } return false; }