-
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.
[feat/#76] camera preview 추가 + dependency
- Loading branch information
Showing
6 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
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
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
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
8 changes: 8 additions & 0 deletions
8
presentation/src/main/java/com/kusitms/presentation/ui/home/attend/AttendSnackbar.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,8 @@ | ||
package com.kusitms.presentation.ui.home.attend | ||
|
||
import androidx.compose.runtime.Composable | ||
|
||
@Composable | ||
fun AttendSnackBar() { | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
presentation/src/main/java/com/kusitms/presentation/ui/home/attend/camera/CameraPreview.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,43 @@ | ||
package com.kusitms.presentation.ui.home.attend.camera | ||
|
||
import android.util.Log | ||
import android.view.ViewGroup | ||
import androidx.camera.core.CameraSelector | ||
import androidx.camera.core.Preview | ||
import androidx.camera.lifecycle.ProcessCameraProvider | ||
import androidx.camera.view.PreviewView | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.platform.LocalLifecycleOwner | ||
import androidx.compose.ui.viewinterop.AndroidView | ||
import androidx.core.content.ContextCompat | ||
|
||
@Composable | ||
fun CameraPreview() { | ||
val context = LocalContext.current | ||
val lifecycleOwner = LocalLifecycleOwner.current | ||
|
||
AndroidView(factory = { context -> | ||
PreviewView(context).apply { | ||
layoutParams = ViewGroup.LayoutParams( | ||
ViewGroup.LayoutParams.MATCH_PARENT, | ||
ViewGroup.LayoutParams.MATCH_PARENT | ||
) | ||
implementationMode = PreviewView.ImplementationMode.COMPATIBLE | ||
} | ||
}, update = { previewView -> | ||
val cameraProviderFuture = ProcessCameraProvider.getInstance(context) | ||
cameraProviderFuture.addListener({ | ||
val cameraProvider: ProcessCameraProvider = cameraProviderFuture.get() | ||
val preview = Preview.Builder().build().also { | ||
it.setSurfaceProvider(previewView.surfaceProvider) | ||
} | ||
try { | ||
cameraProvider.unbindAll() | ||
cameraProvider.bindToLifecycle(lifecycleOwner, CameraSelector.DEFAULT_BACK_CAMERA, preview) | ||
} catch (e: Exception) { | ||
Log.e("CameraPreview", "Use case binding failed", e) | ||
} | ||
}, ContextCompat.getMainExecutor(context)) | ||
}) | ||
} |
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