kotlin
This commit is contained in:
parent
80de823bfa
commit
89a6a2d2ab
1 changed files with 38 additions and 28 deletions
|
@ -102,33 +102,41 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.omnipod_dash_pod_history_activity)
|
|
||||||
historyTypeSpinner = findViewById<Spinner>(R.id.omnipod_historytype)
|
|
||||||
statusView = findViewById<TextView>(R.id.omnipod_historystatus)
|
|
||||||
recyclerView = findViewById<RecyclerView>(R.id.omnipod_history_recyclerview)
|
|
||||||
recyclerView!!.setHasFixedSize(true)
|
|
||||||
linearLayoutManager = LinearLayoutManager(this)
|
|
||||||
recyclerView!!.layoutManager = linearLayoutManager
|
|
||||||
prepareData()
|
|
||||||
recyclerViewAdapter = RecyclerViewAdapter(filteredHistoryList)
|
|
||||||
recyclerView!!.adapter = recyclerViewAdapter
|
|
||||||
statusView!!.visibility = View.GONE
|
|
||||||
typeListFull = getTypeList(PumpHistoryEntryGroup.Companion.getTranslatedList(resourceHelper))!!
|
|
||||||
val spinnerAdapter: ArrayAdapter<TypeList> = ArrayAdapter<TypeList>(this, R.layout.spinner_centered, typeListFull!!)
|
|
||||||
historyTypeSpinner!!.setAdapter(spinnerAdapter)
|
|
||||||
historyTypeSpinner!!.setOnItemSelectedListener(object : AdapterView.OnItemSelectedListener {
|
|
||||||
override fun onItemSelected(parent: AdapterView<*>?, view: View, position: Int, id: Long) {
|
|
||||||
if (manualChange) return
|
|
||||||
val selected = historyTypeSpinner!!.getSelectedItem() as TypeList
|
|
||||||
selectedGroup = selected.entryGroup
|
|
||||||
filterHistory(selectedGroup)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onNothingSelected(parent: AdapterView<*>?) {
|
setContentView(R.layout.omnipod_dash_pod_history_activity)
|
||||||
if (manualChange) return
|
prepareData()
|
||||||
filterHistory(PumpHistoryEntryGroup.All)
|
|
||||||
|
recyclerView = findViewById<RecyclerView>(R.id.omnipod_history_recyclerview)
|
||||||
|
recyclerViewAdapter = RecyclerViewAdapter(filteredHistoryList)
|
||||||
|
linearLayoutManager = LinearLayoutManager(this)
|
||||||
|
recyclerView?.run {
|
||||||
|
setHasFixedSize(true)
|
||||||
|
layoutManager = linearLayoutManager
|
||||||
|
adapter = recyclerViewAdapter
|
||||||
|
}
|
||||||
|
|
||||||
|
statusView = findViewById<TextView>(R.id.omnipod_historystatus)
|
||||||
|
statusView?.run { visibility = View.GONE }
|
||||||
|
|
||||||
|
historyTypeSpinner = findViewById<Spinner>(R.id.omnipod_historytype)
|
||||||
|
typeListFull = getTypeList(PumpHistoryEntryGroup.Companion.getTranslatedList(resourceHelper))
|
||||||
|
val spinnerAdapter: ArrayAdapter<TypeList> = ArrayAdapter<TypeList>(this, R.layout.spinner_centered, typeListFull!!)
|
||||||
|
historyTypeSpinner?.run {
|
||||||
|
adapter = spinnerAdapter
|
||||||
|
onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
|
override fun onItemSelected(parent: AdapterView<*>?, view: View, position: Int, id: Long) {
|
||||||
|
if (manualChange) return
|
||||||
|
val selected = selectedItem as TypeList
|
||||||
|
selectedGroup = selected.entryGroup
|
||||||
|
filterHistory(selectedGroup)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onNothingSelected(parent: AdapterView<*>?) {
|
||||||
|
if (manualChange) return
|
||||||
|
filterHistory(PumpHistoryEntryGroup.All)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getTypeList(list: List<PumpHistoryEntryGroup>): List<TypeList> {
|
private fun getTypeList(list: List<PumpHistoryEntryGroup>): List<TypeList> {
|
||||||
|
@ -155,8 +163,8 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
|
||||||
var historyList: List<HistoryRecordEntity> = historyList
|
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.context).inflate(
|
||||||
R.layout.omnipod_dash_pod_history_item, //
|
R.layout.omnipod_dash_pod_history_item,
|
||||||
viewGroup, false
|
viewGroup, false
|
||||||
)
|
)
|
||||||
return HistoryViewHolder(v)
|
return HistoryViewHolder(v)
|
||||||
|
@ -173,6 +181,8 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
private fun setValue(historyEntry: HistoryRecordEntity, valueView: TextView) {
|
private fun setValue(historyEntry: HistoryRecordEntity, valueView: TextView) {
|
||||||
valueView.text = historyEntry.toString()
|
valueView.text = historyEntry.toString()
|
||||||
|
//val entryType = historyEntry.commandType
|
||||||
|
|
||||||
/* 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());
|
||||||
|
@ -236,7 +246,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
private fun setProfileValue(data: String, valueView: TextView) {
|
private fun setProfileValue(data: String, valueView: TextView) {
|
||||||
aapsLogger.debug(LTag.PUMP, "Profile json:\n$data")
|
aapsLogger.debug(LTag.PUMP, "Profile json:\n$data")
|
||||||
valueView.setText("Profile informations from history")
|
valueView.text = "Profile informations from history"
|
||||||
/*
|
/*
|
||||||
try {
|
try {
|
||||||
Profile.ProfileValue[] profileValuesArray = aapsOmnipodUtil.getGsonInstance().fromJson(data, Profile.ProfileValue[].class);
|
Profile.ProfileValue[] profileValuesArray = aapsOmnipodUtil.getGsonInstance().fromJson(data, Profile.ProfileValue[].class);
|
||||||
|
|
Loading…
Add table
Reference in a new issue