Skip to content

Commit

Permalink
* Suppress error MQTT error message on Android 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
thanksmister committed Nov 15, 2018
1 parent a4667ff commit bd05cdd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,20 @@ abstract class BaseActivity : DaggerAppCompatActivity() {
* with the alarm disabled because the disable time will be longer than this.
*/
open fun showScreenSaver() {
if (!configuration.isAlarmTriggeredMode() && configuration.hasScreenSaver() && !isFinishing() ) {
if (!configuration.isAlarmTriggeredMode() && configuration.hasScreenSaver() && !isFinishing) {
inactivityHandler.removeCallbacks(inactivityCallback)
val hasWeather = (configuration.showWeatherModule() && darkSkyOptions.isValid)
dialogUtils.showScreenSaver(this@BaseActivity,
configuration.showPhotoScreenSaver(),
imageOptions,
View.OnClickListener {
dialogUtils.hideScreenSaverDialog()
resetInactivityTimer()
}, darkSkyDataSource, hasWeather)
try {
dialogUtils.showScreenSaver(this@BaseActivity,
configuration.showPhotoScreenSaver(),
imageOptions,
View.OnClickListener {
dialogUtils.hideScreenSaverDialog()
resetInactivityTimer()
}, darkSkyDataSource, hasWeather)
} catch (e: Exception) {
Timber.e(e.message)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,9 @@ class AlarmPanelService : LifecycleService(), MQTTModule.MQTTListener {
}

override fun onMQTTDisconnect() {
Timber.e("onMQTTDisconnect")
Timber.w("onMQTTDisconnect")
if(hasNetwork()) {
if(!mqttAlertMessageShown) {
if(!mqttAlertMessageShown && Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
mqttAlertMessageShown = true
sendAlertMessage(getString(R.string.error_mqtt_connection))
}
Expand All @@ -341,21 +341,19 @@ class AlarmPanelService : LifecycleService(), MQTTModule.MQTTListener {
}

override fun onMQTTException(message: String) {
Timber.e("onMQTTException: $message")
Timber.w("onMQTTException: $message")
if(hasNetwork()) {
if(!mqttAlertMessageShown) {
if(!mqttAlertMessageShown && Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
mqttAlertMessageShown = true
sendAlertMessage(getString(R.string.error_mqtt_exception))
}
reconnectHandler.postDelayed(restartMqttRunnable, 30000)
}
}

private val restartMqttRunnable = object: Runnable {
override fun run() {
if (mqttModule != null) {
mqttModule!!.restart()
}
private val restartMqttRunnable = Runnable {
if (mqttModule != null) {
mqttModule!!.restart()
}
}

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ def versions = [:]
versions.lifecycle = "1.1.1"
versions.support = "27.1.1"
versions.kotlin = "1.2.20"
versions.navigation = "1.0.0-alpha03"
versions.navigation = "1.0.0-alpha07"
versions.min_sdk = 16
versions.target_sdk = 27
versions.constraint_layout = "1.1.0"
versions.constraint_layout = "1.1.3"
versions.retrofit = "2.2.0"
versions.stetho = "1.3.1"
versions.dagger = "2.15"
Expand Down

0 comments on commit bd05cdd

Please sign in to comment.