Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

val cannot be reassigned #5

Open
karencfisher opened this issue Sep 30, 2022 · 0 comments
Open

val cannot be reassigned #5

karencfisher opened this issue Sep 30, 2022 · 0 comments

Comments

@karencfisher
Copy link

karencfisher commented Sep 30, 2022

In

preview.setOnPreviewOutputUpdateListener {
            textureView.surfaceTexture = it.surfaceTexture
            updateTransform()
        }

There is now an error in the textureView,surfaceTexture being updated, that the val cannot be reassigned. That line can be replaced with:

textureView.setSurfaceTexture(it.surfaceTexture)

(https://stackoverflow.com/questions/63184908/val-cannot-be-reassigned-in-android-buildtool-30-0-1)

However, while the app compiles, nothing is shown of the preview.

The answer seems to be to replace the listener as follows.

preview.setOnPreviewOutputUpdateListener {
            val parent = textureView.parent as ViewGroup
            parent.removeView(textureView)
            textureView.setSurfaceTexture(it.surfaceTexture)
            parent.addView(textureView, 0)
            updateTransform()
        }

And it works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant