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