Мелкие правки

This commit is contained in:
skysamara 2020-06-29 03:07:39 +03:00
parent e479452a3c
commit 88a61f27f0
2 changed files with 4 additions and 19 deletions

View File

@ -31,10 +31,6 @@ class MainActivity : AppCompatActivity() {
var runnable = object:Runnable{
override fun run() {
cameraSource.stop()
// val alert = builder.create()
// alert.show()
// startActivity(Intent(this@MainActivity, Photo::class.java))
taskHandler.removeCallbacksAndMessages(null)
}
}
@ -80,9 +76,11 @@ class MainActivity : AppCompatActivity() {
override fun surfaceCreated(holder: SurfaceHolder?) {
print("4")
if (ContextCompat.checkSelfPermission(this@MainActivity, android.Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED)
// && (ContextCompat.checkSelfPermission(this@MainActivity, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)) == PackageManager.PERMISSION_GRANTED))
cameraSource.start(svBarcode.holder)
else ActivityCompat.requestPermissions(this@MainActivity, arrayOf(android.Manifest.permission.CAMERA), 321)
else {
cameraSource.stop()
ActivityCompat.requestPermissions(this@MainActivity, arrayOf(android.Manifest.permission.CAMERA), 123)
}
}
})
@ -96,11 +94,6 @@ class MainActivity : AppCompatActivity() {
cameraSource.start(svBarcode.holder)
else Toast.makeText(this, "scanner", Toast.LENGTH_SHORT).show()
}
if (requestCode == 321) {
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED)
// cameraSource.start(svBarcode.holder)
else Toast.makeText(this, "scanner", Toast.LENGTH_SHORT).show()
}
}
override fun onDestroy() {

View File

@ -25,10 +25,6 @@ class Photo : AppCompatActivity() {
startActivity(intent)
}
if (ContextCompat.checkSelfPermission(
this@Photo,
android.Manifest.permission.READ_EXTERNAL_STORAGE
@ -39,7 +35,6 @@ class Photo : AppCompatActivity() {
arrayOf(android.Manifest.permission.READ_EXTERNAL_STORAGE),
123
)
// TODO: 26.06.2020 Добавить коллбэк
} else {
getPhoto()
}
@ -69,8 +64,5 @@ class Photo : AppCompatActivity() {
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED)
getPhoto()
else Toast.makeText(this, "Необходим доступ для показа фото", Toast.LENGTH_SHORT).show()
// super.onRequestPermissionsResult(requestCode, permissions, grantResults)
//
}
}