Skip to content

Commit

Permalink
do not connect to MQTT server unless messages need to be sent
Browse files Browse the repository at this point in the history
also fix version number
  • Loading branch information
ostrya committed May 30, 2019
1 parent 2c15593 commit 5296ffb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
applicationId "org.ostrya.presencepublisher"
minSdkVersion 14
targetSdkVersion 28
versionCode 9
versionName "1.4.1"
versionCode 10
versionName "1.5.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ private void registerWatchDog() {

private void start() {
try {
executorService.submit(() -> doSend(getMessagesToSend()));
List<String> messages = getMessagesToSend();
if (!messages.isEmpty()) {
Log.d(TAG, "Schedule sending messages");
executorService.submit(() -> doSend(messages));
}
} catch (RuntimeException e) {
Log.w(TAG, "Error while getting messages to send", e);
}
Expand Down Expand Up @@ -194,7 +198,7 @@ private List<String> getMessagesToSend() {
}
}
if (content.isEmpty() && sharedPreferences.getBoolean(OFFLINE_PING, false)) {
Log.d(TAG, "Correct Wi-Fi disconnected");
Log.d(TAG, "Not connected to any expected network");
content.add(sharedPreferences.getString(CONTENT_OFFLINE, DEFAULT_CONTENT_OFFLINE));
}
return content;
Expand Down

0 comments on commit 5296ffb

Please sign in to comment.