Modify the code logic of OnLayoutChangeListener in Caption preferences
Remove the listener and add statement to refresh the text when the caption turns on. Bug: 142632389 Test: Manual Change-Id: Ic5711309c5b8af9834e5439d825b4cb2ed55fe01
This commit is contained in:
@@ -92,6 +92,17 @@ public class CaptionAppearanceFragment extends SettingsPreferenceFragment
|
||||
|
||||
private final List<Preference> mPreferenceList = new ArrayList<>();
|
||||
|
||||
private final View.OnLayoutChangeListener mLayoutChangeListener =
|
||||
new View.OnLayoutChangeListener() {
|
||||
@Override
|
||||
public void onLayoutChange(View v, int left, int top, int right, int bottom,
|
||||
int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
||||
// Remove the listener once the callback is triggered.
|
||||
mPreviewViewport.removeOnLayoutChangeListener(this);
|
||||
refreshPreviewText();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.ACCESSIBILITY_CAPTION_PROPERTIES;
|
||||
@@ -198,9 +209,7 @@ public class CaptionAppearanceFragment extends SettingsPreferenceFragment
|
||||
mPreviewWindow = captionPreview.findViewById(R.id.preview_window);
|
||||
|
||||
mPreviewViewport = captionPreview.findViewById(R.id.preview_viewport);
|
||||
mPreviewViewport.addOnLayoutChangeListener(
|
||||
(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom)
|
||||
-> refreshPreviewText());
|
||||
mPreviewViewport.addOnLayoutChangeListener(mLayoutChangeListener);
|
||||
|
||||
final Resources res = getResources();
|
||||
final int[] presetValues = res.getIntArray(R.array.captioning_preset_selector_values);
|
||||
|
Reference in New Issue
Block a user