@@ -56,12 +56,8 @@ class DesignerWorkspaceFragment : BaseFragment() {
5656 private var binding: FragmentDesignerWorkspaceBinding ? = null
5757 internal val viewModel by viewModels<WorkspaceViewModel >(ownerProducer = { requireActivity() })
5858
59- private var _viewInfo : ViewInfoSheet ? = null
6059 private val touchSlop by lazy { get(requireContext()).scaledTouchSlop }
6160
62- private val viewInfo: ViewInfoSheet
63- get() = this ._viewInfo ? : ViewInfoSheet ().also { _viewInfo = it }
64-
6561 internal var isInflating = false
6662 internal val workspaceView by lazy {
6763 UiViewGroup (LayoutFile (File (" " ), " " ), LinearLayout ::class .qualifiedName!! , binding!! .workspace)
@@ -87,6 +83,7 @@ class DesignerWorkspaceFragment : BaseFragment() {
8783 private val attrHandler by lazy { WorkspaceViewAttrHandler () }
8884
8985 companion object {
86+
9087 const val DRAGGING_WIDGET = " DRAGGING_WIDGET"
9188 const val DRAGGING_WIDGET_MIME = " androidide/uidesigner_widget"
9289 const val HIERARCHY_CHANGE_TRANSITION_DURATION = 100L
@@ -145,10 +142,13 @@ class DesignerWorkspaceFragment : BaseFragment() {
145142 override fun onDestroyView () {
146143 super .onDestroyView()
147144 this .binding = null
148- this ._viewInfo ?.dismiss()
149- this ._viewInfo = null
150145 this .hierarchyHandler.release()
151146 this .attrHandler.release()
147+
148+ if (! childFragmentManager.isDestroyed) {
149+ val viewInfo = childFragmentManager.findFragmentByTag(ViewInfoSheet .TAG ) as ? ViewInfoSheet ?
150+ viewInfo?.dismiss()
151+ }
152152 }
153153
154154 internal fun setupView (view : IView ) {
@@ -168,6 +168,7 @@ class DesignerWorkspaceFragment : BaseFragment() {
168168 null -> view.view.foreground = bgDesignerView(requireContext())
169169 is UiViewLayeredForeground ->
170170 log.warn(" Attempt to reset UiViewLayeredForeground on view" , view.name, fg::class .java)
171+
171172 else -> view.view.foreground = layeredForeground(requireContext(), fg)
172173 }
173174
@@ -185,6 +186,7 @@ class DesignerWorkspaceFragment : BaseFragment() {
185186
186187 val existing = childFragmentManager.findFragmentByTag(ViewInfoSheet .TAG )
187188 if (existing == null ) {
189+ val viewInfo = ViewInfoSheet ()
188190 viewInfo.show(childFragmentManager, ViewInfoSheet .TAG )
189191 }
190192 }
0 commit comments