Skip to content

Commit

Permalink
#91 카메라 오류 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
pknujsp committed Jun 7, 2023
1 parent 60a7aef commit 60c4638
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ fun CommentListResponse.Comment.toDto() = CommentDto(
isReply = false,
subordinationId = subordination,
content = content,
createdAt = ZonedDateTime.parse(createdAt, DateTimeFormatter.ISO_ZONED_DATE_TIME).format(dateTimeFormatter),
updatedAt = ZonedDateTime.parse(updatedAt, DateTimeFormatter.ISO_ZONED_DATE_TIME).format(dateTimeFormatter),
createdAt = ZonedDateTime.parse(createdAt, DateTimeFormatter.ISO_ZONED_DATE_TIME).plusHours(10L).format(dateTimeFormatter),
updatedAt = ZonedDateTime.parse(updatedAt, DateTimeFormatter.ISO_ZONED_DATE_TIME).plusHours(10L).format(dateTimeFormatter),
onClickReply = null,
onClickLike = null,
onClickDelete = null,
Expand All @@ -78,8 +78,8 @@ fun CommentListResponse.Comment.Reply.toDto() = CommentDto(
isReply = true,
subordinationId = subordination,
content = content,
createdAt = ZonedDateTime.parse(createdAt, DateTimeFormatter.ISO_ZONED_DATE_TIME).format(dateTimeFormatter),
updatedAt = ZonedDateTime.parse(updatedAt, DateTimeFormatter.ISO_ZONED_DATE_TIME).format(dateTimeFormatter),
createdAt = ZonedDateTime.parse(createdAt, DateTimeFormatter.ISO_ZONED_DATE_TIME).plusHours(10L).format(dateTimeFormatter),
updatedAt = ZonedDateTime.parse(updatedAt, DateTimeFormatter.ISO_ZONED_DATE_TIME).plusHours(10L).format(dateTimeFormatter),
onClickReply = null,
onClickLike = null,
onClickDelete = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ class CameraModule {

@Provides
fun providesAiController(cameraHelper: CameraHelper): AiController = cameraHelper

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class MedicinesDetectorFragment :

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.viewModel = fragmentViewModel

systemBarStyler.changeMode(listOf(SystemBarStyler.ChangeView(binding.logo, SystemBarStyler.SpacingType.MARGIN)),
listOf(SystemBarStyler.ChangeView(binding.detectionDescription, SystemBarStyler.SpacingType.MARGIN)))
Expand All @@ -72,13 +71,13 @@ class MedicinesDetectorFragment :
// AI처리 객체의 콜백을 현재 프래그먼트로 설정
cameraController.detectionCallback = this@MedicinesDetectorFragment
}



binding.apply {
backBtn.setOnClickListener {
findNavController().popBackStack()
}

viewModel = fragmentViewModel

viewLifecycleOwner.repeatOnStarted {
launch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,25 @@ import kotlin.coroutines.suspendCoroutine
* 카메라 제어, ai처리 담당
*/
class CameraHelper @Inject constructor(
private val context: Context) : LifecycleEventObserver, AiController, CameraController {
private val context: Context
) : LifecycleEventObserver, AiController, CameraController {

private var camera: Camera? = null

private var _preview: Preview? = null
private var preview: Preview = _preview!!
private val preview: Preview get() = _preview!!

private var _previewView: PreviewView? = null
private val previewView: PreviewView = _previewView!!
private val previewView: PreviewView get() = _previewView!!

private var _imageAnalyzer: ImageAnalysis? = null
private val imageAnalyzer: ImageAnalysis = _imageAnalyzer!!
private val imageAnalyzer: ImageAnalysis get() = _imageAnalyzer!!

private var _cameraProvider: ProcessCameraProvider? = null
private val cameraProvider = _cameraProvider!!
private val cameraProvider get() = _cameraProvider!!

private var _objectDetector: ObjectDetector? = null
private val objectDetector = _objectDetector!!
private val objectDetector get() = _objectDetector!!

private val cameraSelector = CameraSelector.Builder().requireLensFacing(CameraSelector.LENS_FACING_BACK).build()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class MedicineCommentsFragment :

is CommentActionState.COMPLETED_LIKE -> {
action.result.fold(onSuccess = {
adapter.refresh()
adapter.retry()
}, onFailure = {
toast(it.message.toString())
})
Expand All @@ -103,15 +103,15 @@ class MedicineCommentsFragment :
action.result.fold(onSuccess = {
replyHeader.isVisible = false
toast(getString(R.string.appliedComment))
adapter.refresh()
adapter.retry()
}, onFailure = {
toast(it.message.toString())
})
}

is CommentActionState.COMPLETED_APPLY_EDITED_COMMENT -> {
action.result.fold(onSuccess = {
adapter.refresh()
adapter.retry()
toast(getString(R.string.appliedEditComment))
}, onFailure = {
toast(it.message.toString())
Expand All @@ -120,7 +120,7 @@ class MedicineCommentsFragment :

is CommentActionState.COMPLETED_DELETE_COMMENT -> {
action.result.fold(onSuccess = {
adapter.refresh()
adapter.retry()
toast(getString(R.string.deletedComment))
}, onFailure = {
toast(it.message.toString())
Expand Down

0 comments on commit 60c4638

Please sign in to comment.