@@ -17,18 +17,16 @@ import com.foke.together.util.AppPolicy
17
17
import com.foke.together.util.AppPolicy.CAPTURE_INTERVAL
18
18
import com.foke.together.util.AppPolicy.COUNTDOWN_INTERVAL
19
19
import com.foke.together.util.SoundUtil
20
- import com.foke.together.util.TimeUtil
21
20
import dagger.hilt.android.lifecycle.HiltViewModel
22
21
import dagger.hilt.android.qualifiers.ApplicationContext
23
- import kotlinx.coroutines.delay
24
22
import kotlinx.coroutines.launch
25
23
import javax.inject.Inject
26
24
27
25
@HiltViewModel
28
26
class CameraViewModel @Inject constructor(
29
27
@ApplicationContext private val context : Context ,
30
28
getExternalCameraPreviewUrlUseCase : GetExternalCameraPreviewUrlUseCase ,
31
- // private val captureWithExternalCameraUseCase: CaptureWithExternalCameraUseCase,
29
+ private val captureWithExternalCameraUseCase : CaptureWithExternalCameraUseCase ,
32
30
private val generatePhotoFrameUseCase : GeneratePhotoFrameUseCase ,
33
31
private val sessionKeyUseCase : SessionKeyUseCase
34
32
): ViewModel() {
@@ -56,7 +54,14 @@ class CameraViewModel @Inject constructor(
56
54
viewModelScope.launch {
57
55
SoundUtil .getCameraSound(context = context )
58
56
val bitmap = graphicsLayer.toImageBitmap().asAndroidBitmap()
59
- generatePhotoFrameUseCase.saveGraphicsLayerImage(bitmap, " ${AppPolicy .CAPTURED_FOUR_CUT_IMAGE_NAME } _${_captureCount .value} " )
57
+
58
+ // TODO: 현재 External 실패 시, 스크린 캡쳐 화면을 사용하도록 구성함
59
+ val fileName = " ${AppPolicy .CAPTURED_FOUR_CUT_IMAGE_NAME } _${_captureCount .value} "
60
+ captureWithExternalCameraUseCase(fileName)
61
+ .onFailure {
62
+ generatePhotoFrameUseCase.saveGraphicsLayerImage(bitmap, fileName)
63
+ }
64
+
60
65
_progressState .floatValue = 1f
61
66
if (_captureCount .intValue < AppPolicy .CAPTURE_COUNT ) {
62
67
_captureCount .intValue + = 1
@@ -80,11 +85,11 @@ class CameraViewModel @Inject constructor(
80
85
}
81
86
}
82
87
}
88
+
83
89
fun stopCaptureTimer () = viewModelScope.launch{
84
90
if (captureTimer != null ){
85
91
mTimerState = false
86
92
captureTimer!! .cancel()
87
93
}
88
94
}
89
-
90
95
}
0 commit comments