Methods Summary |
---|
public void | apply()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.ViewGroup | getHostView()
return mHostView;
|
private android.view.View | getNextChildNotGone(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$ViewState | getViewStateForView(android.view.View requestedView)
return mStateMap.get(requestedView);
|
public void | performSpeedBumpAnimation(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 void | removeViewStateForView(android.view.View child)
mStateMap.remove(child);
|
public void | resetViewStates()
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 void | updateChildClip(android.view.View child, int height, int clipInset)Updates the clipping of a view
mClipRect.set(0,
clipInset,
child.getWidth(),
height);
child.setClipBounds(mClipRect);
|