Skip to content

Commit

Permalink
Resolve IllegalStateException, Fragment.requireContext
Browse files Browse the repository at this point in the history
Even if isAdded is called just before showConnectingDialog, it may be
disconnected once we get in the main thread after getting the
preferences.
  • Loading branch information
kaaholst committed Jun 20, 2024
1 parent 633440d commit 548450a
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ public void onReceive(Context context, Intent intent) {
private void showConnectingDialog() {
if (connectingDialog == null || !connectingDialog.isShowing()) {
Squeezer.getPreferences(preferences -> {
// We may no longer be attached to the parent activity. If so, do nothing.
if (isAdded()) {
return;
}

Preferences.ServerAddress serverAddress = preferences.getServerAddress();

final View view = LayoutInflater.from(mActivity).inflate(R.layout.connecting, null);
Expand Down

0 comments on commit 548450a

Please sign in to comment.