forked from FoKE-Developers/FourCutTogether
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add UseCases for external camera [FoKE-Developers#58]
- CaptureWithExternalCameraUseCase - 외부 카메라로 캡쳐 후 파일로 저장 및 저장 위치 return - GetExternalCameraPreviewUrlUseCase - 외부 카메라 프리뷰 주소 가져옴 - InitExternalCameraIPUseCase - 앱 실행 시, 외부 카메라 IP를 sharedPref. 에 저장된 값으로 설정 - SetExternalCameraIPUseCase (수정) - 외부 카메라 IP 수정 시, retrofit baseUrl도 변경
- Loading branch information
Showing
4 changed files
with
65 additions
and
5 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
domain/src/main/java/com/foke/together/domain/interactor/CaptureWithExternalCameraUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.foke.together.domain.interactor | ||
|
||
import com.foke.together.domain.output.ExternalCameraRepositoryInterface | ||
import com.foke.together.util.AppLog | ||
import javax.inject.Inject | ||
|
||
class CaptureWithExternalCameraUseCase @Inject constructor( | ||
private val externalCameraRepository: ExternalCameraRepositoryInterface | ||
) { | ||
suspend operator fun invoke(): Result<Unit> { | ||
externalCameraRepository.capture() | ||
.onSuccess { | ||
// TODO: save Bitmap to internal storage | ||
AppLog.i(TAG, "capture", "success: $it") | ||
|
||
// TODO: implement file save code here ... | ||
|
||
return Result.success(Unit) | ||
} | ||
.onFailure { | ||
// TODO: handle network error | ||
AppLog.i(TAG, "capture", "failure: $it") | ||
return Result.failure(it) | ||
} | ||
return Result.failure(Exception("Unknown error")) | ||
} | ||
|
||
companion object { | ||
private val TAG = CaptureWithExternalCameraUseCase::class.java.simpleName | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...n/src/main/java/com/foke/together/domain/interactor/GetExternalCameraPreviewUrlUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.foke.together.domain.interactor | ||
|
||
import com.foke.together.domain.output.ExternalCameraRepositoryInterface | ||
import javax.inject.Inject | ||
|
||
class GetExternalCameraPreviewUrlUseCase @Inject constructor( | ||
private val externalCameraRepository: ExternalCameraRepositoryInterface | ||
) { | ||
operator fun invoke() = externalCameraRepository.getPreviewUrl() | ||
} |
17 changes: 17 additions & 0 deletions
17
domain/src/main/java/com/foke/together/domain/interactor/InitExternalCameraIPUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.foke.together.domain.interactor | ||
|
||
import com.foke.together.domain.output.AppPreferenceInterface | ||
import com.foke.together.domain.output.ExternalCameraRepositoryInterface | ||
import kotlinx.coroutines.flow.firstOrNull | ||
import javax.inject.Inject | ||
|
||
class InitExternalCameraIPUseCase @Inject constructor( | ||
private val appPreference: AppPreferenceInterface, | ||
private val externalCameraRepository: ExternalCameraRepositoryInterface | ||
) { | ||
suspend operator fun invoke() { | ||
appPreference.getExternalCameraIP().firstOrNull()?.let { externalCameraIP -> | ||
externalCameraRepository.setCameraSourceUrl(externalCameraIP.address) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters