Skip to content

Commit

Permalink
Assert intentUrl is never null in dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
cyb3rko committed Oct 2, 2023
1 parent 0c3a17c commit 567fcb4
Showing 1 changed file with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package com.github.gotify.messages
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.github.gotify.R
import com.github.gotify.databinding.ActivityDialogIntentUrlBinding

internal class IntentUrlDialogActivity : AppCompatActivity() {
Expand All @@ -14,14 +12,8 @@ internal class IntentUrlDialogActivity : AppCompatActivity() {
setFinishOnTouchOutside(false)
val binding = ActivityDialogIntentUrlBinding.inflate(layoutInflater)
val intentUrl = intent.getStringExtra(EXTRA_KEY_URL)
binding.cancelButton.setOnClickListener { finish() }
assert(intentUrl != null) { "intentUrl may not be empty" }

if (intentUrl == null) {
binding.urlView.text = getString(R.string.action_dialog_missing)
binding.openButton.visibility = View.GONE
setContentView(binding.root)
return
}
binding.urlView.text = intentUrl
binding.openButton.setOnClickListener {
finish()
Expand All @@ -31,6 +23,7 @@ internal class IntentUrlDialogActivity : AppCompatActivity() {
startActivity(this)
}
}
binding.cancelButton.setOnClickListener { finish() }
setContentView(binding.root)
}

Expand Down

0 comments on commit 567fcb4

Please sign in to comment.