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

Fix Compare button click #4147

Merged
merged 1 commit into from Aug 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -124,32 +124,29 @@ class ProductCompareActivity : BaseActivity() {
photoReceiverHandler = PhotoReceiverHandler(sharedPreferences) {
productComparisonAdapter.onImageReturned(it)
}
}
Copy link
Contributor Author

@naivekook naivekook Aug 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just moved out click listener setup from viewModel.products.observe block


// Set "add product" on click listener
binding.productComparisonButton.setOnClickListener {
if (!isHardwareCameraInstalled()) return@setOnClickListener

when {
checkSelfPermission(this, Manifest.permission.CAMERA) == PERMISSION_GRANTED -> {
startScanActivity()
}
shouldShowRequestPermissionRationale(this@ProductCompareActivity, Manifest.permission.CAMERA) -> {
MaterialAlertDialogBuilder(this@ProductCompareActivity)
.setTitle(R.string.action_about)
.setMessage(R.string.permission_camera)
.setPositiveButton(android.R.string.ok) { _, _ ->
requestCameraThenOpenScan.launch(Manifest.permission.CAMERA)
}
.show()
}
else -> {
requestCameraThenOpenScan.launch(Manifest.permission.CAMERA)
}
}
binding.productComparisonButton.setOnClickListener {
if (!isHardwareCameraInstalled()) return@setOnClickListener

when {
checkSelfPermission(this, Manifest.permission.CAMERA) == PERMISSION_GRANTED -> {
startScanActivity()
}
shouldShowRequestPermissionRationale(this@ProductCompareActivity, Manifest.permission.CAMERA) -> {
MaterialAlertDialogBuilder(this@ProductCompareActivity)
.setTitle(R.string.action_about)
.setMessage(R.string.permission_camera)
.setPositiveButton(android.R.string.ok) { _, _ ->
requestCameraThenOpenScan.launch(Manifest.permission.CAMERA)
}
.show()
}
else -> {
requestCameraThenOpenScan.launch(Manifest.permission.CAMERA)
}
}
}

}

override fun startScanActivity() {
Expand Down