prevent kotlin exceptions
This commit is contained in:
parent
ceaa3c8750
commit
2b7cb0d558
|
@ -27,7 +27,7 @@ class DummyService : DaggerService() {
|
|||
|
||||
private val disposable = CompositeDisposable()
|
||||
|
||||
override fun onBind(intent: Intent): IBinder? = null
|
||||
override fun onBind(intent: Intent?): IBinder? = null
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
|
|
@ -39,32 +39,37 @@ class TimeDateOrTZChangeReceiver : DaggerBroadcastReceiver() {
|
|||
val activePump: PumpInterface = activePlugin.activePump
|
||||
|
||||
aapsLogger.debug(LTag.PUMP,"TimeDateOrTZChangeReceiver::Date, Time and/or TimeZone changed. [action={}]", action)
|
||||
aapsLogger.debug(LTag.PUMP,"TimeDateOrTZChangeReceiver::Intent::{}", gson.toJson(intent))
|
||||
try {
|
||||
aapsLogger.debug(LTag.PUMP, "TimeDateOrTZChangeReceiver::Intent::{}", gson.toJson(intent))
|
||||
} catch (ignored : Exception) {}
|
||||
|
||||
if (action == null) {
|
||||
aapsLogger.error(LTag.PUMP,"TimeDateOrTZChangeReceiver::Action is null. Exiting.")
|
||||
} else if (Intent.ACTION_TIMEZONE_CHANGED == action) {
|
||||
aapsLogger.info(LTag.PUMP,"TimeDateOrTZChangeReceiver::Timezone changed. Notifying pump driver.")
|
||||
activePump.timezoneOrDSTChanged(TimeChangeType.TimezoneChange)
|
||||
} else if (Intent.ACTION_TIME_CHANGED == action) {
|
||||
val currentDst = calculateDST()
|
||||
if (currentDst == isDST) {
|
||||
aapsLogger.info(LTag.PUMP,"TimeDateOrTZChangeReceiver::Time changed (manual). Notifying pump driver.")
|
||||
activePump.timezoneOrDSTChanged(TimeChangeType.ManualTimeChange)
|
||||
} else {
|
||||
if (currentDst) {
|
||||
aapsLogger.info(LTag.PUMP,"TimeDateOrTZChangeReceiver::DST started. Notifying pump driver.")
|
||||
activePump.timezoneOrDSTChanged(TimeChangeType.DST_Started)
|
||||
} else {
|
||||
aapsLogger.info(LTag.PUMP,"TimeDateOrTZChangeReceiver::DST ended. Notifying pump driver.")
|
||||
activePump.timezoneOrDSTChanged(TimeChangeType.DST_Ended)
|
||||
}
|
||||
when {
|
||||
action == null -> {
|
||||
aapsLogger.error(LTag.PUMP,"TimeDateOrTZChangeReceiver::Action is null. Exiting.")
|
||||
}
|
||||
Intent.ACTION_TIMEZONE_CHANGED == action -> {
|
||||
aapsLogger.info(LTag.PUMP,"TimeDateOrTZChangeReceiver::Timezone changed. Notifying pump driver.")
|
||||
activePump.timezoneOrDSTChanged(TimeChangeType.TimezoneChange)
|
||||
}
|
||||
Intent.ACTION_TIME_CHANGED == action -> {
|
||||
val currentDst = calculateDST()
|
||||
if (currentDst == isDST) {
|
||||
aapsLogger.info(LTag.PUMP,"TimeDateOrTZChangeReceiver::Time changed (manual). Notifying pump driver.")
|
||||
activePump.timezoneOrDSTChanged(TimeChangeType.ManualTimeChange)
|
||||
} else {
|
||||
if (currentDst) {
|
||||
aapsLogger.info(LTag.PUMP,"TimeDateOrTZChangeReceiver::DST started. Notifying pump driver.")
|
||||
activePump.timezoneOrDSTChanged(TimeChangeType.DST_Started)
|
||||
} else {
|
||||
aapsLogger.info(LTag.PUMP,"TimeDateOrTZChangeReceiver::DST ended. Notifying pump driver.")
|
||||
activePump.timezoneOrDSTChanged(TimeChangeType.DST_Ended)
|
||||
}
|
||||
}
|
||||
isDST = currentDst
|
||||
}
|
||||
else -> {
|
||||
aapsLogger.error(LTag.PUMP,"TimeDateOrTZChangeReceiver::Unknown action received [name={}]. Exiting.", action)
|
||||
}
|
||||
isDST = currentDst
|
||||
} else {
|
||||
aapsLogger.error(LTag.PUMP,"TimeDateOrTZChangeReceiver::Unknown action received [name={}]. Exiting.", action)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ class LocationService : DaggerService() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
super.onStartCommand(intent, flags, startId)
|
||||
try {
|
||||
startForeground(notificationHolder.notificationID, notificationHolder.notification)
|
||||
|
|
|
@ -29,13 +29,13 @@ class AlarmSoundService : DaggerService() {
|
|||
startForeground(notificationHolder.notificationID, notificationHolder.notification)
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
startForeground(notificationHolder.notificationID, notificationHolder.notification)
|
||||
|
||||
player?.let { if (it.isPlaying) it.stop() }
|
||||
|
||||
aapsLogger.debug(LTag.CORE, "onStartCommand")
|
||||
if (intent.hasExtra("soundid")) resourceId = intent.getIntExtra("soundid", R.raw.error)
|
||||
if (intent?.hasExtra("soundid") == true) resourceId = intent.getIntExtra("soundid", R.raw.error)
|
||||
player = MediaPlayer()
|
||||
try {
|
||||
val afd = resourceHelper.openRawResourceFd(resourceId) ?: return START_STICKY
|
||||
|
|
|
@ -126,7 +126,7 @@ class DanaHistoryActivity : NoSplashAppCompatActivity() {
|
|||
})
|
||||
}
|
||||
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 = typeList[position]
|
||||
loadDataFromDB(selected.type)
|
||||
showingType = selected.type
|
||||
|
|
Loading…
Reference in a new issue