Skip to content

Commit

Permalink
feat: 增加 isRunningInBackgroundStateOb 实现
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaojinzi123 committed Jan 24, 2024
1 parent 9edc7d1 commit 6684aea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

第二版的业务架构的要求:
1. 不同的 UseCase 之间可以功能叠加
2. 第一版的方法入口在第二版需要支持统一的 Intent 入口, 然后实现类可以自定义方法来处理这个 Intent
12 changes: 12 additions & 0 deletions lib-ktx/src/main/java/com/xiaojinzi/support/ktx/Systems.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import android.os.Build
import android.os.VibrationEffect
import android.os.Vibrator
import android.provider.Settings
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.map

/**
* 是否在后台运行
Expand All @@ -21,6 +23,16 @@ val isRunningInBackground: Boolean
}
}

/**
* 是否在后台运行的 StateFlow
*/
val isRunningInBackgroundStateOb = tickerFlow(period = 1000)
.map { isRunningInBackground }
.distinctUntilChanged()
.sharedStateIn(
scope = AppScope,
)


/**
* 是否可以悬浮窗
Expand Down

0 comments on commit 6684aea

Please sign in to comment.