Skip to content

Commit

Permalink
- fixed test
Browse files Browse the repository at this point in the history
- add runtest for linux
- some refactorings
  • Loading branch information
andyrozman committed May 27, 2021
1 parent 1678583 commit 3c7b5fd
Show file tree
Hide file tree
Showing 8 changed files with 271 additions and 263 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ class MedtronicFragment : DaggerFragment() {
binding.pumpStatusIcon.text = "{fa-bed}"

binding.history.setOnClickListener {
if (medtronicPumpPlugin.rileyLinkService?.verifyConfiguration() == true) {
if (medtronicPumpPlugin.rileyLinkService.verifyConfiguration() == true) {
startActivity(Intent(context, MedtronicHistoryActivity::class.java))
} else {
displayNotConfiguredDialog()
}
}

binding.refresh.setOnClickListener {
if (medtronicPumpPlugin.rileyLinkService?.verifyConfiguration() != true) {
if (medtronicPumpPlugin.rileyLinkService.verifyConfiguration() != true) {
displayNotConfiguredDialog()
} else {
binding.refresh.isEnabled = false
Expand All @@ -120,7 +120,7 @@ class MedtronicFragment : DaggerFragment() {
}

binding.stats.setOnClickListener {
if (medtronicPumpPlugin.rileyLinkService?.verifyConfiguration() == true) {
if (medtronicPumpPlugin.rileyLinkService.verifyConfiguration() == true) {
startActivity(Intent(context, RileyLinkStatusActivity::class.java))
} else {
displayNotConfiguredDialog()
Expand Down Expand Up @@ -160,7 +160,7 @@ class MedtronicFragment : DaggerFragment() {
.observeOn(aapsSchedulers.main)
.subscribe({
aapsLogger.debug(LTag.PUMP, "EventMedtronicPumpConfigurationChanged triggered")
medtronicPumpPlugin.rileyLinkService?.verifyConfiguration()
medtronicPumpPlugin.rileyLinkService.verifyConfiguration()
updateGUI()
}, fabricPrivacy::logException)
disposable += rxBus
Expand Down Expand Up @@ -192,7 +192,7 @@ class MedtronicFragment : DaggerFragment() {
@Synchronized
private fun setDeviceStatus() {
val resourceId = rileyLinkServiceData.rileyLinkServiceState.resourceId
val rileyLinkError = medtronicPumpPlugin.rileyLinkService?.error
val rileyLinkError = medtronicPumpPlugin.rileyLinkService.error
binding.rlStatus.text =
when {
rileyLinkServiceData.rileyLinkServiceState == RileyLinkServiceState.NotStarted -> resourceHelper.gs(resourceId)
Expand Down Expand Up @@ -338,7 +338,7 @@ class MedtronicFragment : DaggerFragment() {
binding.reservoir.text = resourceHelper.gs(R.string.reservoirvalue, medtronicPumpStatus.reservoirRemainingUnits, medtronicPumpStatus.reservoirFullUnits)
warnColors.setColorInverse(binding.reservoir, medtronicPumpStatus.reservoirRemainingUnits, 50.0, 20.0)

medtronicPumpPlugin.rileyLinkService?.verifyConfiguration()
medtronicPumpPlugin.rileyLinkService.verifyConfiguration()
binding.errors.text = medtronicPumpStatus.errorInfo

val showRileyLinkBatteryLevel: Boolean = rileyLinkServiceData.showBatteryLevel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ class MedtronicCommunicationManager // This empty constructor must be kept, oth
return responseData
}
val contents = response.rawContent
return if (contents != null) {
return if (contents.size > 0) {
if (contents.size >= expectedLength) {
aapsLogger.debug(LTag.PUMPCOMM, String.format(Locale.ENGLISH, "%s: Content: %s", method, ByteUtil.shortHexString(contents)))
null
Expand All @@ -463,7 +463,7 @@ class MedtronicCommunicationManager // This empty constructor must be kept, oth
responseData
}
} else {
val responseData = String.format("%s: Cannot return data. Null response.", method)
val responseData = String.format("%s: Cannot return data. Zero length response.", method)
aapsLogger.warn(LTag.PUMPCOMM, responseData)
responseData
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ class CGMSHistoryEntry : MedtronicHistoryEntry() {
get() = entryType.name

override fun generatePumpId(): Long {
return if (entryType == null)
atechDateTime * 1000L
else
entryType.code + atechDateTime * 1000L
return entryType.code + atechDateTime * 1000L
}

override fun isEntryTypeSet(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,16 @@ class RileyLinkStatusDeviceMedtronic : DaggerFragment(), RefreshableInterface {
// adapter.addItemsAndClean(RileyLinkUtil.getRileyLinkHistory());
}

internal class ViewHolder {
internal class ViewHolder constructor(view: View,
var itemTime: TextView? = null,
var itemSource: TextView? = null,
var itemDescription: TextView? = null) {

init {
itemTime = view.findViewById(R.id.rileylink_history_time)
itemSource = view.findViewById(R.id.rileylink_history_source)
itemDescription = view.findViewById(R.id.rileylink_history_description)
}

var itemTime: TextView? = null
var itemSource: TextView? = null
Expand Down Expand Up @@ -109,26 +118,43 @@ class RileyLinkStatusDeviceMedtronic : DaggerFragment(), RefreshableInterface {
return i.toLong()
}

override fun getView(i: Int, viewIn: View, viewGroup: ViewGroup): View {
var view = viewIn
override fun getView(i: Int, viewIn: View?, viewGroup: ViewGroup): View {
var rowView: View?
val viewHolder: ViewHolder
// General ListView optimization code.
// if (view == null) {
view = mInflator.inflate(R.layout.rileylink_status_device_item, null)
viewHolder = ViewHolder()
viewHolder.itemTime = view.findViewById(R.id.rileylink_history_time)
viewHolder.itemSource = view.findViewById(R.id.rileylink_history_source)
viewHolder.itemDescription = view.findViewById(R.id.rileylink_history_description)
view.tag = viewHolder
// }
// else {
// viewHolder = view.tag as ViewHolder
// }

if (view == null) {
rowView = layoutInflater.inflate(R.layout.rileylink_status_device_item, viewGroup, false)

viewHolder = ViewHolder(rowView)
rowView.tag = viewHolder

} else {
rowView = view
viewHolder = rowView.tag as ViewHolder
}

val item = historyItemList[i]
viewHolder.itemTime!!.text = StringUtil.toDateTimeString(dateUtil, item.dateTime)
viewHolder.itemSource!!.text = "Riley Link" // for now
viewHolder.itemDescription!!.text = item.getDescription(resourceHelper)
return view

return rowView!!

// // old
// if (view == null) {
// view = mInflator.inflate(R.layout.rileylink_status_device_item, viewGroup, false)
// }
// viewHolder = ViewHolder()
// viewHolder.itemTime = view.findViewById(R.id.rileylink_history_time)
// viewHolder.itemSource = view.findViewById(R.id.rileylink_history_source)
// viewHolder.itemDescription = view.findViewById(R.id.rileylink_history_description)
// view.tag = viewHolder
//
// val item = historyItemList[i]
// viewHolder.itemTime!!.text = StringUtil.toDateTimeString(dateUtil, item.dateTime)
// viewHolder.itemSource!!.text = "Riley Link" // for now
// viewHolder.itemDescription!!.text = item.getDescription(resourceHelper)
// return view
}

init {
Expand Down
Loading

0 comments on commit 3c7b5fd

Please sign in to comment.