Updated missing index handling

This commit is contained in:
Nite 2020-09-25 10:43:33 +02:00
parent 02716c827a
commit db4f8b83d3
No known key found for this signature in database
GPG Key ID: 1D1AD59B1C6386C1
2 changed files with 5 additions and 3 deletions

View File

@ -85,8 +85,10 @@ internal class ServerRowAdapter(
text?.text = context.getString(R.string.main_offline)
description?.text = ""
} else {
text?.text = data.singleOrNull { setting -> setting.index == index }?.name ?: ""
description?.text = data.singleOrNull { setting -> setting.index == index }?.url ?: ""
val setting = data.singleOrNull { t -> t.index == index }
text?.text = setting?.name ?: ""
description?.text = setting?.url ?: ""
if (setting == null) serverMenu?.visibility = View.INVISIBLE
}
// Provide icons for the row

View File

@ -75,7 +75,7 @@ class ActiveServerProvider(
}
GlobalScope.launch(Dispatchers.IO) {
val serverId = repository.findByIndex(index)!!.id
val serverId = repository.findByIndex(index)?.id ?: 0
setActiveServerId(context, serverId)
}
}