From ddbaff13dc498d36c47a5f3b0b0fa4517cb87d5b Mon Sep 17 00:00:00 2001 From: ligi Date: Sat, 2 Sep 2017 18:36:15 +0200 Subject: [PATCH] Deal with null and better naming --- .../org/ligi/passandroid/ui/TouchImageActivity.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/android/src/main/java/org/ligi/passandroid/ui/TouchImageActivity.kt b/android/src/main/java/org/ligi/passandroid/ui/TouchImageActivity.kt index 473d3ef1..511e0c5c 100644 --- a/android/src/main/java/org/ligi/passandroid/ui/TouchImageActivity.kt +++ b/android/src/main/java/org/ligi/passandroid/ui/TouchImageActivity.kt @@ -15,13 +15,19 @@ class TouchImageActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - val webView = TouchImageView(this) + val touchImageView = TouchImageView(this) - setContentView(webView) + setContentView(touchImageView) - webView.setImageBitmap(passStore.currentPass!!.getBitmap(passStore, intent.getStringExtra("IMAGE"))) + val bitmap = passStore.currentPass?.getBitmap(passStore, intent.getStringExtra("IMAGE")) - supportActionBar?.setDisplayHomeAsUpEnabled(true) + if (bitmap == null) { + finish() + } else { + touchImageView.setImageBitmap(bitmap) + + supportActionBar?.setDisplayHomeAsUpEnabled(true) + } } override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {