Merge "Don't animate TextView marquee if not visible"

This commit is contained in:
John Reck
2022-01-10 15:31:42 +00:00
committed by Android (Google) Code Review
2 changed files with 13 additions and 4 deletions

View File

@@ -15012,8 +15012,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
/**
* @return true if this view and all ancestors are visible as of the last
* {@link #onVisibilityAggregated(boolean)} call.
*
* @hide
*/
boolean isAggregatedVisible() {
public boolean isAggregatedVisible() {
return (mPrivateFlags3 & PFLAG3_AGGREGATED_VISIBLE) != 0;
}

View File

@@ -10636,8 +10636,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
return;
}
if ((mMarquee == null || mMarquee.isStopped()) && (isFocused() || isSelected())
&& getLineCount() == 1 && canMarquee()) {
if ((mMarquee == null || mMarquee.isStopped()) && isAggregatedVisible()
&& (isFocused() || isSelected()) && getLineCount() == 1 && canMarquee()) {
if (mMarqueeFadeMode == MARQUEE_FADE_SWITCH_SHOW_ELLIPSIS) {
mMarqueeFadeMode = MARQUEE_FADE_SWITCH_SHOW_FADE;
@@ -11096,6 +11096,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
}
@Override
public void onVisibilityAggregated(boolean isVisible) {
super.onVisibilityAggregated(isVisible);
startStopMarquee(isVisible);
}
/**
* Use {@link BaseInputConnection#removeComposingSpans
* BaseInputConnection.removeComposingSpans()} to remove any IME composing
@@ -13749,7 +13755,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
mChoreographer.removeFrameCallback(mTickCallback);
final TextView textView = mView.get();
if (textView != null && (textView.isFocused() || textView.isSelected())) {
if (textView != null && textView.isAggregatedVisible()
&& (textView.isFocused() || textView.isSelected())) {
long currentMs = mChoreographer.getFrameTime();
long deltaMs = currentMs - mLastAnimationMs;
mLastAnimationMs = currentMs;