kotlin fixes

This commit is contained in:
Andrei Vereha 2021-10-24 11:06:39 +02:00
parent 269e94a8b5
commit d1b2fa207c

View file

@ -71,9 +71,9 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
} }
} }
}*/ }*/
if (recyclerViewAdapter != null) { recyclerViewAdapter?.let {
recyclerViewAdapter!!.historyList = filteredHistoryList it.historyList = filteredHistoryList
recyclerViewAdapter!!.notifyDataSetChanged() it.notifyDataSetChanged()
} }
aapsLogger.debug(LTag.PUMP, "Items on filtered list: {}", filteredHistoryList.size) aapsLogger.debug(LTag.PUMP, "Items on filtered list: {}", filteredHistoryList.size)
} }
@ -112,7 +112,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
prepareData() prepareData()
recyclerViewAdapter = RecyclerViewAdapter(filteredHistoryList) recyclerViewAdapter = RecyclerViewAdapter(filteredHistoryList)
recyclerView!!.adapter = recyclerViewAdapter recyclerView!!.adapter = recyclerViewAdapter
statusView!!.setVisibility(View.GONE) statusView!!.visibility = View.GONE
typeListFull = getTypeList(PumpHistoryEntryGroup.Companion.getTranslatedList(resourceHelper))!! typeListFull = getTypeList(PumpHistoryEntryGroup.Companion.getTranslatedList(resourceHelper))!!
val spinnerAdapter: ArrayAdapter<TypeList> = ArrayAdapter<TypeList>(this, R.layout.spinner_centered, typeListFull!!) val spinnerAdapter: ArrayAdapter<TypeList> = ArrayAdapter<TypeList>(this, R.layout.spinner_centered, typeListFull!!)
historyTypeSpinner!!.setAdapter(spinnerAdapter) historyTypeSpinner!!.setAdapter(spinnerAdapter)
@ -141,21 +141,18 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
internal class TypeList(entryGroup: PumpHistoryEntryGroup) { internal class TypeList(entryGroup: PumpHistoryEntryGroup) {
val entryGroup: PumpHistoryEntryGroup val entryGroup: PumpHistoryEntryGroup = entryGroup
val name: String val name: String = entryGroup.translated ?: "XXX TODO"
override fun toString(): String { override fun toString(): String {
return name return name
} }
init {
this.entryGroup = entryGroup
name = entryGroup.translated ?: "XXX TODO"
}
} }
inner class RecyclerViewAdapter internal constructor(historyList: List<HistoryRecordEntity>) : RecyclerView.Adapter<RecyclerViewAdapter.HistoryViewHolder>() { inner class RecyclerViewAdapter internal constructor(historyList: List<HistoryRecordEntity>) : RecyclerView.Adapter<RecyclerViewAdapter.HistoryViewHolder>() {
var historyList: List<HistoryRecordEntity> var historyList: List<HistoryRecordEntity> = historyList
override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): HistoryViewHolder { override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): HistoryViewHolder {
val v: View = LayoutInflater.from(viewGroup.getContext()).inflate( val v: View = LayoutInflater.from(viewGroup.getContext()).inflate(
@ -175,7 +172,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
} }
private fun setValue(historyEntry: HistoryRecordEntity, valueView: TextView) { 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 /* Here you define which information to show in history according to historyEntry Type
if (historyEntry.isSuccess()) { if (historyEntry.isSuccess()) {
PodHistoryEntryType entryType = PodHistoryEntryType.getByCode(historyEntry.getPodEntryTypeCode()); PodHistoryEntryType entryType = PodHistoryEntryType.getByCode(historyEntry.getPodEntryTypeCode());
@ -272,9 +269,6 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
} }
} }
init {
this.historyList = historyList
}
} }
companion object { companion object {