From d1b2fa207cf42bbe557b139fa275cbac681be335 Mon Sep 17 00:00:00 2001 From: Andrei Vereha Date: Sun, 24 Oct 2021 11:06:39 +0200 Subject: [PATCH] kotlin fixes --- .../omnipod/dash/ui/DashPodHistoryActivity.kt | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt index 390b183f90..4c9eb3bc1f 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt @@ -71,9 +71,9 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { } } }*/ - if (recyclerViewAdapter != null) { - recyclerViewAdapter!!.historyList = filteredHistoryList - recyclerViewAdapter!!.notifyDataSetChanged() + recyclerViewAdapter?.let { + it.historyList = filteredHistoryList + it.notifyDataSetChanged() } aapsLogger.debug(LTag.PUMP, "Items on filtered list: {}", filteredHistoryList.size) } @@ -112,7 +112,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { prepareData() recyclerViewAdapter = RecyclerViewAdapter(filteredHistoryList) recyclerView!!.adapter = recyclerViewAdapter - statusView!!.setVisibility(View.GONE) + statusView!!.visibility = View.GONE typeListFull = getTypeList(PumpHistoryEntryGroup.Companion.getTranslatedList(resourceHelper))!! val spinnerAdapter: ArrayAdapter = ArrayAdapter(this, R.layout.spinner_centered, typeListFull!!) historyTypeSpinner!!.setAdapter(spinnerAdapter) @@ -141,21 +141,18 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { internal class TypeList(entryGroup: PumpHistoryEntryGroup) { - val entryGroup: PumpHistoryEntryGroup - val name: String + val entryGroup: PumpHistoryEntryGroup = entryGroup + val name: String = entryGroup.translated ?: "XXX TODO" + override fun toString(): String { return name } - init { - this.entryGroup = entryGroup - name = entryGroup.translated ?: "XXX TODO" - } } inner class RecyclerViewAdapter internal constructor(historyList: List) : RecyclerView.Adapter() { - var historyList: List + var historyList: List = historyList override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): HistoryViewHolder { val v: View = LayoutInflater.from(viewGroup.getContext()).inflate( @@ -175,7 +172,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { } private fun setValue(historyEntry: HistoryRecordEntity, valueView: TextView) { - valueView.setText(historyEntry.toString()) + valueView.text = historyEntry.toString() /* Here you define which information to show in history according to historyEntry Type if (historyEntry.isSuccess()) { PodHistoryEntryType entryType = PodHistoryEntryType.getByCode(historyEntry.getPodEntryTypeCode()); @@ -272,9 +269,6 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { } } - init { - this.historyList = historyList - } } companion object {