[Settings] Do not set text if the fragment is not attached

Bug: 273415166
Test: loacl test
Change-Id: I5298727359191d8ce9c4526279faa4e8a3c1df43
This commit is contained in:
Zoey Chen
2023-03-17 18:14:49 +00:00
parent 5f15e00e07
commit 76bb350c73

View File

@@ -20,6 +20,7 @@ import android.app.Dialog;
import android.app.settings.SettingsEnums;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
@@ -106,6 +107,10 @@ public class SimStatusDialogFragment extends InstrumentedDialogFragment {
.sorted().toArray();
public void setText(int viewId, CharSequence text) {
if (!isAdded()) {
Log.d(TAG, "Fragment not attached yet.");
return;
}
setText(viewId, text, true);
}