prevent NPE

This commit is contained in:
Milos Kozak 2020-02-01 22:44:23 +01:00
parent 8972ce676d
commit 6b26ef2e88

View file

@ -100,23 +100,23 @@ class DanaRHistoryActivity : NoSplashAppCompatActivity() {
danar_history_reload.setOnClickListener { danar_history_reload.setOnClickListener {
val selected = danar_history_spinner.selectedItem as TypeList val selected = danar_history_spinner.selectedItem as TypeList
runOnUiThread { runOnUiThread {
danar_history_reload.visibility = View.GONE danar_history_reload?.visibility = View.GONE
danar_history_status.visibility = View.VISIBLE danar_history_status?.visibility = View.VISIBLE
} }
clearCardView() clearCardView()
ConfigBuilderPlugin.getPlugin().commandQueue.loadHistory(selected.type, object : Callback() { ConfigBuilderPlugin.getPlugin().commandQueue.loadHistory(selected.type, object : Callback() {
override fun run() { override fun run() {
loadDataFromDB(selected.type) loadDataFromDB(selected.type)
runOnUiThread { runOnUiThread {
danar_history_reload.visibility = View.VISIBLE danar_history_reload?.visibility = View.VISIBLE
danar_history_status.visibility = View.GONE danar_history_status?.visibility = View.GONE
} }
} }
}) })
} }
danar_history_spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { danar_history_spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(parent: AdapterView<*>?, view: View, position: Int, id: Long) { override fun onItemSelected(parent: AdapterView<*>?, view: View, position: Int, id: Long) {
val selected = danar_history_spinner.selectedItem as TypeList val selected = danar_history_spinner?.selectedItem as TypeList? ?: return
loadDataFromDB(selected.type) loadDataFromDB(selected.type)
showingType = selected.type showingType = selected.type
} }