瀏覽代碼

EuiccChannelManagerService: move applyCompletionTransform() to companion object

Peter Cai 1 年之前
父節點
當前提交
1a3fd621d9
共有 1 個文件被更改,包括 12 次插入12 次删除
  1. 12 12
      app-common/src/main/java/im/angry/openeuicc/service/EuiccChannelManagerService.kt

+ 12 - 12
app-common/src/main/java/im/angry/openeuicc/service/EuiccChannelManagerService.kt

@@ -68,6 +68,18 @@ class EuiccChannelManagerService : LifecycleService(), OpenEuiccContextMarker {
          */
         suspend fun Flow<ForegroundTaskState>.waitDone(): Throwable? =
             (this.last() as ForegroundTaskState.Done).error
+
+        /**
+         * Apply transform to a ForegroundTaskState flow so that it completes when a Done is seen.
+         *
+         * This must be applied each time a flow is returned for subscription purposes. If applied
+         * beforehand, we lose the ability to subscribe multiple times.
+         */
+        private fun Flow<ForegroundTaskState>.applyCompletionTransform() =
+            transformWhile {
+                emit(it)
+                it !is ForegroundTaskState.Done
+            }
     }
 
     inner class LocalBinder : Binder() {
@@ -197,18 +209,6 @@ class EuiccChannelManagerService : LifecycleService(), OpenEuiccContextMarker {
         NotificationManagerCompat.from(this).notify(TASK_FAILURE_ID, notification)
     }
 
-    /**
-     * Apply transform to a ForegroundTaskState flow so that it completes when a Done is seen.
-     *
-     * This must be applied each time a flow is returned for subscription purposes. If applied
-     * beforehand, we lose the ability to subscribe multiple times.
-     */
-    private fun Flow<ForegroundTaskState>.applyCompletionTransform() =
-        transformWhile {
-            emit(it)
-            it !is ForegroundTaskState.Done
-        }
-
     /**
      * Recover the subscriber to a foreground task that is recently launched.
      *