Fix Caption preview SubtitleView textSize cannot update correctly
Root caue: When received #OnLayoutChangeListener callback, the mPainText size keeps "zero" after called setTextSize() because the requestLayout() does not trigger the whole view re-measure & re-layout in not ui thread. Solution: Post #refreshPreviewText to ui thread to get correct bounds to measure & layout. Bug: 223696269 Bug: 211178478 Test: Manually test Change-Id: Idcbeba52876171e5f3641eafc77d203764c78788
This commit is contained in:
@@ -22,6 +22,8 @@ import android.content.Context;
|
|||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.accessibility.CaptioningManager;
|
import android.view.accessibility.CaptioningManager;
|
||||||
@@ -92,6 +94,7 @@ public class CaptionAppearanceFragment extends DashboardFragment
|
|||||||
|
|
||||||
private final List<Preference> mPreferenceList = new ArrayList<>();
|
private final List<Preference> mPreferenceList = new ArrayList<>();
|
||||||
|
|
||||||
|
private final Handler mHandler = new Handler(Looper.getMainLooper());
|
||||||
private final View.OnLayoutChangeListener mLayoutChangeListener =
|
private final View.OnLayoutChangeListener mLayoutChangeListener =
|
||||||
new View.OnLayoutChangeListener() {
|
new View.OnLayoutChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -99,7 +102,7 @@ public class CaptionAppearanceFragment extends DashboardFragment
|
|||||||
int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
||||||
// Remove the listener once the callback is triggered.
|
// Remove the listener once the callback is triggered.
|
||||||
mPreviewViewport.removeOnLayoutChangeListener(this);
|
mPreviewViewport.removeOnLayoutChangeListener(this);
|
||||||
refreshPreviewText();
|
mHandler.post(() ->refreshPreviewText());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user