Fix popup window overdraw

This commit is contained in:
darken
2022-01-25 12:06:09 +01:00
parent d5d2ae784c
commit 2de2369600
@@ -42,16 +42,17 @@ class PopUpWindow @Inject constructor(
findViewById<View>(R.id.close_action).setOnClickListener { close() } findViewById<View>(R.id.close_action).setOnClickListener { close() }
} }
private val deviceContainer = popUpView.findViewById<FrameLayout>(R.id.popup_content) private val deviceContainer = popUpView.findViewById<FrameLayout>(R.id.popup_content)
fun show(device: PodDevice) = try { fun show(device: PodDevice) = try {
log(TAG) { "open()" } log(TAG) { "open()" }
if (popUpView.windowToken == null && popUpView.parent == null) { if (popUpView.windowToken != null || popUpView.parent != null) {
log(TAG) { "View already added." }
close()
}
val podView = podViewFactory.createContentView(deviceContainer, device) val podView = podViewFactory.createContentView(deviceContainer, device)
deviceContainer.removeAllViews()
deviceContainer.addView(podView) deviceContainer.addView(podView)
windowManager.addView(popUpView, layoutParams) windowManager.addView(popUpView, layoutParams)
} else {
log(TAG) { "View already added." }
}
} catch (e: Exception) { } catch (e: Exception) {
log(TAG, ERROR) { "open() failed: ${e.asLog()}" } log(TAG, ERROR) { "open() failed: ${e.asLog()}" }
} }
@@ -59,9 +60,8 @@ class PopUpWindow @Inject constructor(
fun close() = try { fun close() = try {
log(TAG) { "close()" } log(TAG) { "close()" }
if (popUpView.parent != null) { if (popUpView.parent != null) {
// (popUpView.parent as ViewGroup).removeAllViews()
// popUpView.invalidate()
windowManager.removeView(popUpView) windowManager.removeView(popUpView)
deviceContainer.removeAllViews()
} else { } else {
log(TAG) { "View was not added" } log(TAG) { "View was not added" }
} }