You've already forked android-client
mirror of
https://github.com/netbirdio/android-client.git
synced 2026-05-22 17:10:49 -07:00
bug: bottom dialog fragment attached not attached to activity (#117)
* Remove onClickListener from peersBtn When HomeFragment is destroyed * Remove unused imports * Check if BottomDialogFragment is attached to Activity When setting its onShowListener
This commit is contained in:
@@ -45,6 +45,11 @@ public class BottomDialogFragment extends com.google.android.material.bottomshee
|
||||
// Apply transparent background theme to the dialog
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(requireContext(), R.style.BottomSheetDialogTheme);
|
||||
dialog.setOnShowListener(dialogInterface -> {
|
||||
// Check if the fragment is still attached to avoid IllegalStateException
|
||||
if (getActivity() == null || !isAdded()) {
|
||||
return;
|
||||
}
|
||||
|
||||
FrameLayout bottomSheet = dialog.findViewById(com.google.android.material.R.id.design_bottom_sheet);
|
||||
if (bottomSheet != null) {
|
||||
// Set the bottom sheet to be full screen
|
||||
|
||||
@@ -11,7 +11,6 @@ import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.airbnb.lottie.LottieAnimationView;
|
||||
@@ -22,7 +21,6 @@ import io.netbird.client.ServiceAccessor;
|
||||
import io.netbird.client.StateListener;
|
||||
import io.netbird.client.StateListenerRegistry;
|
||||
import io.netbird.client.databinding.FragmentHomeBinding;
|
||||
import io.netbird.client.ui.PreferenceUI;
|
||||
import io.netbird.gomobile.android.PeerInfo;
|
||||
import io.netbird.gomobile.android.PeerInfoArray;
|
||||
|
||||
@@ -126,6 +124,8 @@ public class HomeFragment extends Fragment implements StateListener {
|
||||
super.onDestroyView();
|
||||
buttonAnimation.destroy();
|
||||
stateListenerRegistry.unregisterServiceStateListener(this);
|
||||
FrameLayout openPanelCardView = binding.peersBtn;
|
||||
openPanelCardView.setOnClickListener(null);
|
||||
binding = null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user