Skip to content

Commit bd05cdd

Browse files
committed
* Suppress error MQTT error message on Android 5.0
1 parent a4667ff commit bd05cdd

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

app/src/main/java/com/thanksmister/iot/mqtt/alarmpanel/BaseActivity.kt

+12-8
Original file line numberDiff line numberDiff line change
@@ -190,16 +190,20 @@ abstract class BaseActivity : DaggerAppCompatActivity() {
190190
* with the alarm disabled because the disable time will be longer than this.
191191
*/
192192
open fun showScreenSaver() {
193-
if (!configuration.isAlarmTriggeredMode() && configuration.hasScreenSaver() && !isFinishing() ) {
193+
if (!configuration.isAlarmTriggeredMode() && configuration.hasScreenSaver() && !isFinishing) {
194194
inactivityHandler.removeCallbacks(inactivityCallback)
195195
val hasWeather = (configuration.showWeatherModule() && darkSkyOptions.isValid)
196-
dialogUtils.showScreenSaver(this@BaseActivity,
197-
configuration.showPhotoScreenSaver(),
198-
imageOptions,
199-
View.OnClickListener {
200-
dialogUtils.hideScreenSaverDialog()
201-
resetInactivityTimer()
202-
}, darkSkyDataSource, hasWeather)
196+
try {
197+
dialogUtils.showScreenSaver(this@BaseActivity,
198+
configuration.showPhotoScreenSaver(),
199+
imageOptions,
200+
View.OnClickListener {
201+
dialogUtils.hideScreenSaverDialog()
202+
resetInactivityTimer()
203+
}, darkSkyDataSource, hasWeather)
204+
} catch (e: Exception) {
205+
Timber.e(e.message)
206+
}
203207
}
204208
}
205209

app/src/main/java/com/thanksmister/iot/mqtt/alarmpanel/network/AlarmPanelService.kt

+7-9
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,9 @@ class AlarmPanelService : LifecycleService(), MQTTModule.MQTTListener {
330330
}
331331

332332
override fun onMQTTDisconnect() {
333-
Timber.e("onMQTTDisconnect")
333+
Timber.w("onMQTTDisconnect")
334334
if(hasNetwork()) {
335-
if(!mqttAlertMessageShown) {
335+
if(!mqttAlertMessageShown && Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
336336
mqttAlertMessageShown = true
337337
sendAlertMessage(getString(R.string.error_mqtt_connection))
338338
}
@@ -341,21 +341,19 @@ class AlarmPanelService : LifecycleService(), MQTTModule.MQTTListener {
341341
}
342342

343343
override fun onMQTTException(message: String) {
344-
Timber.e("onMQTTException: $message")
344+
Timber.w("onMQTTException: $message")
345345
if(hasNetwork()) {
346-
if(!mqttAlertMessageShown) {
346+
if(!mqttAlertMessageShown && Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
347347
mqttAlertMessageShown = true
348348
sendAlertMessage(getString(R.string.error_mqtt_exception))
349349
}
350350
reconnectHandler.postDelayed(restartMqttRunnable, 30000)
351351
}
352352
}
353353

354-
private val restartMqttRunnable = object: Runnable {
355-
override fun run() {
356-
if (mqttModule != null) {
357-
mqttModule!!.restart()
358-
}
354+
private val restartMqttRunnable = Runnable {
355+
if (mqttModule != null) {
356+
mqttModule!!.restart()
359357
}
360358
}
361359

build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ def versions = [:]
5353
versions.lifecycle = "1.1.1"
5454
versions.support = "27.1.1"
5555
versions.kotlin = "1.2.20"
56-
versions.navigation = "1.0.0-alpha03"
56+
versions.navigation = "1.0.0-alpha07"
5757
versions.min_sdk = 16
5858
versions.target_sdk = 27
59-
versions.constraint_layout = "1.1.0"
59+
versions.constraint_layout = "1.1.3"
6060
versions.retrofit = "2.2.0"
6161
versions.stetho = "1.3.1"
6262
versions.dagger = "2.15"

0 commit comments

Comments
 (0)