Skip to content

Commit

Permalink
Merge pull request #448 from ushahidi/420-dont-log-misleading-mesgs
Browse files Browse the repository at this point in the history
Log messages for gained and lost data connectivity
  • Loading branch information
eyedol committed May 3, 2016
2 parents eba66e3 + a81aa3a commit 54951c1
Showing 1 changed file with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,28 @@ public void onReceive(Context context, Intent intent) {
mAlertPresenter.lostConnectionThread.interrupt();
}

return;
}

if (mAlertPresenter.lostConnectionThread == null
|| !mAlertPresenter.lostConnectionThread.isAlive()) {
mAlertPresenter.lostConnectionThread = new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(AlertPresenter.MAX_DISCONNECT_TIME);
} catch (InterruptedException e) {
return;
App.getAppComponent().fileManager()
.append(context.getString(R.string.active_data_connection));
} else if (!Utility.isConnected(context) && App.getAppComponent().prefsFactory()
.serviceEnabled().get()) {
if (mAlertPresenter.lostConnectionThread == null
|| !mAlertPresenter.lostConnectionThread.isAlive()) {
mAlertPresenter.lostConnectionThread = new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(AlertPresenter.MAX_DISCONNECT_TIME);
} catch (InterruptedException e) {
return;
}
mAlertPresenter.dataConnectionLost();
}
mAlertPresenter.dataConnectionLost();
}
});
mAlertPresenter.lostConnectionThread.start();
});
mAlertPresenter.lostConnectionThread.start();
}
App.getAppComponent().fileManager()
.append(context.getString(R.string.no_data_connection));

}
App.getAppComponent().fileManager()
.append(context.getString(R.string.no_data_connection));
}
}

2 comments on commit 54951c1

@henrysthompson8
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9ad1bb38-6fa8-41fe-ac0c-820141f62eso

@Sammygracezhu
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mAlertPresenter.lostConnectionThread = new Thread(new Runnable() {

@OverRide
public void run() {
try {
Thread.sleep(AlertPresenter.MAX_DISCONNECT_TIME);
} catch (InterruptedException e) {
return;
}
mAlertPresenter.dataConnectionLost(); }
mAlertPresenter.dataConnectionLost();
}

});

Replace this with: mAlertPresenter.lostConnectionThread = new Thread(()->{
try {
Thread.sleep(AlertPresenter.MAX_DISCONNECT_TIME);
} catch (InterruptedException e) {
return;
}
mAlertPresenter.dataConnectionLost(); }
mAlertPresenter.dataConnectionLost();
});

?? Since Lambda expression is popular now.
And all Runnable interface can use lambda expression .

Please sign in to comment.