Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
xuning
/
livekitAndroidXuningTest
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
davidliu
2024-06-02 14:24:44 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2024-06-02 14:24:44 +0900
Commit
e19c4747fff0fa7c578d4ac6659d9f193febabfc
e19c4747
1 parent
8b634ea5
Fix ScaleZoomHelper to properly handle multiple zoom actions (#429)
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
21 行增加
和
7 行删除
livekit-android-camerax/src/main/java/io/livekit/android/camerax/ui/ScaleZoomHelper.kt
livekit-android-camerax/src/main/java/io/livekit/android/camerax/ui/ScaleZoomHelper.kt
查看文件 @
e19c474
...
...
@@ -23,6 +23,7 @@ import android.view.ScaleGestureDetector
import android.view.ScaleGestureDetector.SimpleOnScaleGestureListener
import androidx.camera.core.Camera
import androidx.camera.core.CameraControl
import com.google.common.util.concurrent.ListenableFuture
import io.livekit.android.camerax.ui.ScaleZoomHelper.Companion.createGestureDetector
import io.livekit.android.room.track.LocalVideoTrack
import io.livekit.android.util.LKLog
...
...
@@ -71,9 +72,17 @@ class ScaleZoomHelper(
}
}
/**
* Track the current target zoom, since cameraInfo.zoomState is on LiveData timers and can be out of date.
*/
private var targetZoom: Float? = null
/**
* Track the current active zoom futures; only clear targetZoom when all futures are completed.
*/
private var activeZoomFutures = mutableSetOf<ListenableFuture<Void>>()
/**
* Scales the current zoom value by [factor].
*
* This method handles clamping the resulting zoom value to within the camera's
...
...
@@ -92,15 +101,20 @@ class ScaleZoomHelper(
if (newZoom != currentZoom) {
targetZoom = newZoom
camera.cameraControl.setZoomRatio(newZoom)
.addListener(
{
synchronized(this) {
val future = camera.cameraControl.setZoomRatio(newZoom)
activeZoomFutures.add(future)
future.addListener(
{
synchronized(this) {
activeZoomFutures.remove(future)
if (activeZoomFutures.isEmpty()) {
targetZoom = null
}
},
{ it.run() },
)
}
},
{ it.run() },
)
}
}
...
...
请
注册
或
登录
后发表评论