Skip to content

Commit 2f43b53

Browse files
committed
Fix: Prevent multiple AppDetail sheets stacking
1 parent 90fcab9 commit 2f43b53

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

app/src/main/java/com/appcontrolx/ui/AppListFragment.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,17 +208,17 @@ class AppListFragment : Fragment() {
208208
}
209209

210210
private fun showAppDetail(app: AppInfo) {
211-
val bottomSheet = AppDetailBottomSheet.newInstance(app)
212-
bottomSheet.onActionCompleted = {
213-
// Will refresh when sheet is dismissed
211+
// Prevent multiple sheets - dismiss existing one first
212+
val existingSheet = childFragmentManager.findFragmentByTag(AppDetailBottomSheet.TAG)
213+
if (existingSheet != null) {
214+
(existingSheet as? AppDetailBottomSheet)?.dismissAllowingStateLoss()
214215
}
215-
bottomSheet.show(childFragmentManager, AppDetailBottomSheet.TAG)
216216

217-
// Refresh list when sheet is dismissed (after any action)
218-
childFragmentManager.executePendingTransactions()
219-
bottomSheet.dialog?.setOnDismissListener {
217+
val bottomSheet = AppDetailBottomSheet.newInstance(app)
218+
bottomSheet.onActionCompleted = {
220219
refreshAppList()
221220
}
221+
bottomSheet.show(childFragmentManager, AppDetailBottomSheet.TAG)
222222
}
223223

224224
private fun setupChips() {

0 commit comments

Comments
 (0)