Skip to content

Commit 4d34314

Browse files
committed
.
1 parent 2562569 commit 4d34314

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

app/src/main/java/xyz/tberghuis/floatingtimer/service/FtWindowManager.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,25 @@ import android.view.ViewGroup
66
import android.view.WindowManager
77

88
class FtWindowManager(
9-
private val service: FloatingService // context is really FloatingService
9+
private val service: FloatingService
1010
) {
1111
private val windowManager = service.getSystemService(Context.WINDOW_SERVICE) as WindowManager
1212

1313
private var callStartForegroundOnce = false
14-
14+
1515
// future.txt suspend withContext(Main)
1616
// wait till i write a test case to prove it will prevent ANR
1717
fun addView(view: View, params: ViewGroup.LayoutParams) {
1818
windowManager.addView(view, params)
19-
if(!callStartForegroundOnce){
19+
if (!callStartForegroundOnce) {
2020
callStartForegroundOnce = true
2121
// if I still get ForegroundServiceStartNotAllowedException
2222
// option are delay here, or override onWindowVisibilityChanged in AbstractComposeView
2323
// or override in View and have ComposeView child
2424
// https://developer.android.com/about/versions/15/behavior-changes-15
25-
service.startInForeground()
25+
view.post {
26+
service.startInForeground()
27+
}
2628
}
2729
}
2830

0 commit comments

Comments
 (0)