FileDocCategorySizeDatePackage
StackScrollState.javaAPI DocAndroid 5.1 API10416Thu Mar 12 22:22:42 GMT 2015com.android.systemui.statusbar.stack

StackScrollState

public class StackScrollState extends Object
A state of a {@link com.android.systemui.statusbar.stack.NotificationStackScrollLayout} which can be applied to a viewGroup.

Fields Summary
private static final String
CHILD_NOT_FOUND_TAG
private final android.view.ViewGroup
mHostView
private Map
mStateMap
private final android.graphics.Rect
mClipRect
private final int
mClearAllTopPadding
Constructors Summary
public StackScrollState(android.view.ViewGroup hostView)


       
        mHostView = hostView;
        mStateMap = new HashMap<ExpandableView, ViewState>();
        mClearAllTopPadding = hostView.getContext().getResources().getDimensionPixelSize(
                R.dimen.clear_all_padding_top);
    
Methods Summary
public voidapply()
Apply the properties saved in {@link #mStateMap} to the children of the {@link #mHostView}. The properties are only applied if they effectively changed.

        int numChildren = mHostView.getChildCount();
        for (int i = 0; i < numChildren; i++) {
            ExpandableView child = (ExpandableView) mHostView.getChildAt(i);
            ViewState state = mStateMap.get(child);
            if (state == null) {
                Log.wtf(CHILD_NOT_FOUND_TAG, "No child state was found when applying this state " +
                        "to the hostView");
                continue;
            }
            if (!state.gone) {
                float alpha = child.getAlpha();
                float yTranslation = child.getTranslationY();
                float xTranslation = child.getTranslationX();
                float zTranslation = child.getTranslationZ();
                float scale = child.getScaleX();
                int height = child.getActualHeight();
                float newAlpha = state.alpha;
                float newYTranslation = state.yTranslation;
                float newZTranslation = state.zTranslation;
                float newScale = state.scale;
                int newHeight = state.height;
                boolean becomesInvisible = newAlpha == 0.0f;
                if (alpha != newAlpha && xTranslation == 0) {
                    // apply layer type
                    boolean becomesFullyVisible = newAlpha == 1.0f;
                    boolean newLayerTypeIsHardware = !becomesInvisible && !becomesFullyVisible;
                    int layerType = child.getLayerType();
                    int newLayerType = newLayerTypeIsHardware
                            ? View.LAYER_TYPE_HARDWARE
                            : View.LAYER_TYPE_NONE;
                    if (layerType != newLayerType) {
                        child.setLayerType(newLayerType, null);
                    }

                    // apply alpha
                    child.setAlpha(newAlpha);
                }

                // apply visibility
                int oldVisibility = child.getVisibility();
                int newVisibility = becomesInvisible ? View.INVISIBLE : View.VISIBLE;
                if (newVisibility != oldVisibility) {
                    child.setVisibility(newVisibility);
                }

                // apply yTranslation
                if (yTranslation != newYTranslation) {
                    child.setTranslationY(newYTranslation);
                }

                // apply zTranslation
                if (zTranslation != newZTranslation) {
                    child.setTranslationZ(newZTranslation);
                }

                // apply scale
                if (scale != newScale) {
                    child.setScaleX(newScale);
                    child.setScaleY(newScale);
                }

                // apply height
                if (height != newHeight) {
                    child.setActualHeight(newHeight, false /* notifyListeners */);
                }

                // apply dimming
                child.setDimmed(state.dimmed, false /* animate */);

                // apply dark
                child.setDark(state.dark, false /* animate */, 0 /* delay */);

                // apply hiding sensitive
                child.setHideSensitive(
                        state.hideSensitive, false /* animated */, 0 /* delay */, 0 /* duration */);

                // apply speed bump state
                child.setBelowSpeedBump(state.belowSpeedBump);

                // apply clipping
                float oldClipTopAmount = child.getClipTopAmount();
                if (oldClipTopAmount != state.clipTopAmount) {
                    child.setClipTopAmount(state.clipTopAmount);
                }
                updateChildClip(child, newHeight, state.topOverLap);

                if(child instanceof SpeedBumpView) {
                    performSpeedBumpAnimation(i, (SpeedBumpView) child, state, 0);
                } else if (child instanceof DismissView) {
                    DismissView dismissView = (DismissView) child;
                    boolean visible = state.topOverLap < mClearAllTopPadding;
                    dismissView.performVisibilityAnimation(visible && !dismissView.willBeGone());
                } else if (child instanceof EmptyShadeView) {
                    EmptyShadeView emptyShadeView = (EmptyShadeView) child;
                    boolean visible = state.topOverLap <= 0;
                    emptyShadeView.performVisibilityAnimation(
                            visible && !emptyShadeView.willBeGone());
                }
            }
        }
    
public android.view.ViewGroupgetHostView()

        return mHostView;
    
private android.view.ViewgetNextChildNotGone(int childIndex)

        int childCount = mHostView.getChildCount();
        for (int i = childIndex + 1; i < childCount; i++) {
            View child = mHostView.getChildAt(i);
            if (child.getVisibility() != View.GONE) {
                return child;
            }
        }
        return null;
    
public com.android.systemui.statusbar.stack.StackScrollState$ViewStategetViewStateForView(android.view.View requestedView)

        return mStateMap.get(requestedView);
    
public voidperformSpeedBumpAnimation(int i, com.android.systemui.statusbar.SpeedBumpView speedBump, com.android.systemui.statusbar.stack.StackScrollState$ViewState state, long delay)

        View nextChild = getNextChildNotGone(i);
        if (nextChild != null) {
            float lineEnd = state.yTranslation + state.height / 2;
            ViewState nextState = getViewStateForView(nextChild);
            boolean startIsAboveNext = nextState.yTranslation > lineEnd;
            speedBump.animateDivider(startIsAboveNext, delay, null /* onFinishedRunnable */);
        }
    
public voidremoveViewStateForView(android.view.View child)

        mStateMap.remove(child);
    
public voidresetViewStates()

        int numChildren = mHostView.getChildCount();
        for (int i = 0; i < numChildren; i++) {
            ExpandableView child = (ExpandableView) mHostView.getChildAt(i);
            ViewState viewState = mStateMap.get(child);
            if (viewState == null) {
                viewState = new ViewState();
                mStateMap.put(child, viewState);
            }
            // initialize with the default values of the view
            viewState.height = child.getIntrinsicHeight();
            viewState.gone = child.getVisibility() == View.GONE;
            viewState.alpha = 1;
            viewState.notGoneIndex = -1;
        }
    
private voidupdateChildClip(android.view.View child, int height, int clipInset)
Updates the clipping of a view

param
child the view to update
param
height the currently applied height of the view
param
clipInset how much should this view be clipped from the top

        mClipRect.set(0,
                clipInset,
                child.getWidth(),
                height);
        child.setClipBounds(mClipRect);