- avoided a few compiler warnings about null values

This commit is contained in:
Juha Heinanen
2019-04-09 10:27:05 +03:00
parent 2c92b1b6ea
commit 69daf94c37
8 changed files with 17 additions and 19 deletions

View File

@ -34,7 +34,7 @@ class AccountActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_account)
acc = Account.find(intent.extras.getString("accp"))!!
acc = Account.find(intent.getStringExtra("accp"))!!
aor = acc.aor
uaIndex = UserAgent.findAorIndex(aor)!!

View File

@ -62,7 +62,7 @@ class AccountsActivity : AppCompatActivity() {
}
}
val accp = intent.extras.getString("accp")
val accp = intent.getStringExtra("accp")
if (accp != "") {
val i = Intent(this, AccountActivity::class.java)
val b = Bundle()

View File

@ -667,7 +667,6 @@ class BaresipService: Service() {
}
private fun requestAudioFocus(streamType: Int) {
val res: Int
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) && (audioFocusRequest == null)) {
@TargetApi(26)
audioFocusRequest = AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN).run {
@ -678,16 +677,15 @@ class BaresipService: Service() {
build()
}
@TargetApi(26)
res = am.requestAudioFocus(audioFocusRequest)
if (res == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
if (am.requestAudioFocus(audioFocusRequest!!) == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
Log.d(LOG_TAG, "Audio focus granted")
} else {
Log.d(LOG_TAG, "Audio focus denied")
audioFocusRequest = null
}
} else {
res = am.requestAudioFocus(null, streamType, AudioManager.AUDIOFOCUS_GAIN)
if (res == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
if (am.requestAudioFocus(null, streamType, AudioManager.AUDIOFOCUS_GAIN) ==
AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
Log.d(LOG_TAG, "Audio focus granted")
audioFocused = true
} else {
@ -700,7 +698,7 @@ class BaresipService: Service() {
private fun abandonAudioFocus() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (audioFocusRequest != null) {
am.abandonAudioFocusRequest(audioFocusRequest)
am.abandonAudioFocusRequest(audioFocusRequest!!)
audioFocusRequest = null
}
} else {

View File

@ -26,7 +26,7 @@ class CallsActivity : AppCompatActivity() {
setContentView(R.layout.activity_calls)
val aor = intent.extras.getString("aor")
val aor = intent.getStringExtra("aor")!!
val ua = Account.findUa(aor)!!
val headerView = findViewById(R.id.account) as TextView
@ -71,7 +71,7 @@ class CallsActivity : AppCompatActivity() {
}
listView.onItemLongClickListener = AdapterView.OnItemLongClickListener { _, _, pos, _ ->
val peerUri = uaHistory[pos].peerURI
var peerName = ContactsActivity.contactName(peerUri)
val peerName = ContactsActivity.contactName(peerUri)
val dialogClickListener = DialogInterface.OnClickListener { _, which ->
when (which) {
DialogInterface.BUTTON_NEUTRAL -> {

View File

@ -35,9 +35,9 @@ class ChatActivity : AppCompatActivity() {
setContentView(R.layout.activity_chat)
aor = intent.extras.getString("aor")
peerUri = intent.extras.getString("peer")
val focus = intent.extras.getBoolean("focus")
aor = intent.getStringExtra("aor")!!
peerUri = intent.getStringExtra("peer")!!
val focus = intent.getBooleanExtra("focus", false)
val userAgent = Account.findUa(aor)
if (userAgent == null) {

View File

@ -135,13 +135,13 @@ class ChatsActivity: AppCompatActivity() {
}
}
val peer = intent.extras.getString("peer")
val peer = intent.getStringExtra("peer")
if (peer != "") {
val i = Intent(this, ChatActivity::class.java)
val b = Bundle()
b.putString("aor", aor)
b.putString("peer", peer)
b.putBoolean("focus", intent.extras.getBoolean("focus"))
b.putBoolean("focus", intent.getBooleanExtra("focus", false))
i.putExtras(b)
startActivityForResult(i, MainActivity.MESSAGE_CODE)
}

View File

@ -21,8 +21,8 @@ class ContactActivity : AppCompatActivity() {
nameView = findViewById(R.id.Name) as EditText
uriView = findViewById(R.id.Uri) as EditText
val uri = intent.extras.getString("uri")
new = intent.extras.getBoolean("new")
val uri = intent.getStringExtra("uri")
new = intent.getBooleanExtra("new", false)
if (new) {
setTitle("New Contact")
@ -36,7 +36,7 @@ class ContactActivity : AppCompatActivity() {
uriView.setText(uri)
}
} else {
index = intent.extras.getInt("index")
index = intent.getIntExtra("index", 0)
val name = Contact.contacts()[index].name
setTitle(name)
nameView.setText(name)

View File

@ -23,7 +23,7 @@ class ContactsActivity : AppCompatActivity() {
val listView = findViewById(R.id.contacts) as ListView
val aor = intent.extras.getString("aor")
val aor = intent.getStringExtra("aor")!!
clAdapter = ContactListAdapter(this, Contact.contacts(), aor)
listView.adapter = clAdapter
listView.isLongClickable = true