Skip to content

Commit

Permalink
fix: compare button click (#4147)
Browse files Browse the repository at this point in the history
  • Loading branch information
naivekook committed Aug 9, 2021
1 parent ccd5da9 commit 15d1498
Showing 1 changed file with 19 additions and 22 deletions.
Expand Up @@ -124,32 +124,29 @@ class ProductCompareActivity : BaseActivity() {
photoReceiverHandler = PhotoReceiverHandler(sharedPreferences) {
productComparisonAdapter.onImageReturned(it)
}
}

// 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

0 comments on commit 15d1498

Please sign in to comment.