Java Code Examples for android.support.v4.util.ArrayMap#valueAt()

The following examples show how to use android.support.v4.util.ArrayMap#valueAt() . 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 vote down vote up
/**
 * 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: BaseExpandableAdapter.java    From ExpandableRecyclerview with Apache License 2.0 6 votes vote down vote up
/**
 * check has item is expanded by default
 */
private void checkDefaultExpand() {
    ArrayMap<Object, List<?>> childArrayMap = new ArrayMap<>();
    Iterator<Object> iterator = mDataList.iterator();
    while (iterator.hasNext()) {
        Object next = iterator.next();
        if (next instanceof ExpandableListItem) {
            ExpandableListItem expandableListItem = (ExpandableListItem) next;
            if (expandableListItem.isExpanded()) {
                List<?> childItemList = expandableListItem.getChildItemList();
                if (childItemList != null && !childItemList.isEmpty()) {
                    childArrayMap.put(next, childItemList);
                }
            }
        }
    }
    int size = childArrayMap.size();
    if (size == 0) return;
    for (int i = 0; i < size; i++) {
        Object o = childArrayMap.keyAt(i);
        List<?> objects = childArrayMap.valueAt(i);
        int indexOf = mDataList.indexOf(o);
        mDataList.addAll(indexOf + 1, objects);
    }

}
 
Example 3
Source File: Transition.java    From Transitions-Everywhere with Apache License 2.0 6 votes vote down vote up
/**
 * Match start/end values by Adapter transitionName. Adds matched values to mStartValuesList
 * and mEndValuesList and removes them from unmatchedStart and unmatchedEnd, using
 * startNames and endNames as a guide for which Views have unique transitionNames.
 */
private void matchNames(@NonNull ArrayMap<View, TransitionValues> unmatchedStart,
                        @NonNull ArrayMap<View, TransitionValues> unmatchedEnd,
                        @NonNull ArrayMap<String, View> startNames,
                        @NonNull ArrayMap<String, View> endNames) {
    int numStartNames = startNames.size();
    for (int i = 0; i < numStartNames; i++) {
        View startView = startNames.valueAt(i);
        if (startView != null && isValidTarget(startView)) {
            View endView = endNames.get(startNames.keyAt(i));
            if (endView != null && isValidTarget(endView)) {
                TransitionValues startValues = unmatchedStart.get(startView);
                TransitionValues endValues = unmatchedEnd.get(endView);
                if (startValues != null && endValues != null) {
                    mStartValuesList.add(startValues);
                    mEndValuesList.add(endValues);
                    unmatchedStart.remove(startView);
                    unmatchedEnd.remove(endView);
                }
            }
        }
    }
}
 
Example 4
Source File: Transition.java    From Transitions-Everywhere with Apache License 2.0 6 votes vote down vote up
/**
 * Pauses this transition, sending out calls to {@link
 * TransitionListener#onTransitionPause(Transition)} to all listeners
 * and pausing all running animators started by this transition.
 *
 * @hide
 */
public void pause(@NonNull View sceneRoot) {
    if (!mEnded) {
        synchronized (sRunningAnimators) {
            ArrayMap<Animator, AnimationInfo> runningAnimators = getRunningAnimators();
            int numOldAnims = runningAnimators.size();
            Object windowId = ViewUtils.getWindowId(sceneRoot);
            for (int i = numOldAnims - 1; i >= 0; i--) {
                AnimationInfo info = runningAnimators.valueAt(i);
                if (info.view != null && windowId != null && windowId.equals(info.windowId)) {
                    Animator anim = runningAnimators.keyAt(i);
                    AnimatorUtils.pause(anim);
                }
            }
        }
        if (mListeners != null && mListeners.size() > 0) {
            ArrayList<TransitionListener> tmpListeners =
                    (ArrayList<TransitionListener>) mListeners.clone();
            int numListeners = tmpListeners.size();
            for (int i = 0; i < numListeners; ++i) {
                tmpListeners.get(i).onTransitionPause(this);
            }
        }
        mPaused = true;
    }
}
 
Example 5
Source File: Transition.java    From Transitions-Everywhere with Apache License 2.0 6 votes vote down vote up
/**
 * Resumes this transition, sending out calls to {@link
 * TransitionListener#onTransitionPause(Transition)} to all listeners
 * and pausing all running animators started by this transition.
 *
 * @hide
 */
public void resume(@NonNull View sceneRoot) {
    if (mPaused) {
        if (!mEnded) {
            ArrayMap<Animator, AnimationInfo> runningAnimators = getRunningAnimators();
            int numOldAnims = runningAnimators.size();
            Object windowId = ViewUtils.getWindowId(sceneRoot);
            for (int i = numOldAnims - 1; i >= 0; i--) {
                AnimationInfo info = runningAnimators.valueAt(i);
                if (info.view != null && windowId != null && windowId.equals(info.windowId)) {
                    Animator anim = runningAnimators.keyAt(i);
                    AnimatorUtils.resume(anim);
                }
            }
            if (mListeners != null && mListeners.size() > 0) {
                ArrayList<TransitionListener> tmpListeners =
                        (ArrayList<TransitionListener>) mListeners.clone();
                int numListeners = tmpListeners.size();
                for (int i = 0; i < numListeners; ++i) {
                    tmpListeners.get(i).onTransitionResume(this);
                }
            }
        }
        mPaused = false;
    }
}
 
Example 6
Source File: Transition.java    From Transitions-Everywhere with Apache License 2.0 5 votes vote down vote up
/**
 * Force the transition to move to its end state, ending all the animators.
 */
void forceToEnd(@Nullable ViewGroup sceneRoot) {
    ArrayMap<Animator, AnimationInfo> runningAnimators = getRunningAnimators();
    int numOldAnims = runningAnimators.size();
    if (sceneRoot != null) {
        Object windowId = ViewUtils.getWindowId(sceneRoot);
        for (int i = numOldAnims - 1; i >= 0; i--) {
            AnimationInfo info = runningAnimators.valueAt(i);
            if (info.view != null && windowId != null && windowId.equals(info.windowId)) {
                Animator anim = runningAnimators.keyAt(i);
                anim.end();
            }
        }
    }
}