Prevent crash from toolbar subtitle in call view.

This commit is contained in:
Nicholas Tinsley 2023-09-19 15:17:35 -04:00 committed by Alex Hart
parent dd62d92ffb
commit 69c1c856d9

View file

@ -600,7 +600,15 @@ public class WebRtcCallView extends ConstraintLayout {
public void setStatus(@Nullable String status) {
ThreadUtil.assertMainThread();
this.status.setText(status);
collapsedToolbar.setSubtitle(status);
try {
// Toolbar's subtitle view sometimes already has a parent somehow,
// so we clear it out first so that it removes the view from its parent.
// In addition, we catch the ISE to prevent a crash.
collapsedToolbar.setSubtitle(null);
collapsedToolbar.setSubtitle(status);
} catch (IllegalStateException e) {
Log.w(TAG, "IllegalStateException trying to set status on collapsed Toolbar.");
}
}
private void setStatus(@StringRes int statusRes) {