Use SystemClock.sleep instead of Thread.sleep.
Gets rid of all those pointless InterruptedException catching. (cherry picked from commit 6acaa2b)
This commit is contained in:
parent
c50fad81bb
commit
5c3ec9a086
|
@ -4,6 +4,7 @@ import android.app.Application;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
|
|
||||||
|
@ -167,10 +168,7 @@ public class MainApp extends Application {
|
||||||
Thread t = new Thread(new Runnable() {
|
Thread t = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
SystemClock.sleep(5000);
|
||||||
Thread.sleep(5000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
}
|
|
||||||
PumpInterface pump = MainApp.getConfigBuilder();
|
PumpInterface pump = MainApp.getConfigBuilder();
|
||||||
if (pump != null)
|
if (pump != null)
|
||||||
pump.refreshDataFromPump("Initialization");
|
pump.refreshDataFromPump("Initialization");
|
||||||
|
|
|
@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.NSClientInternal;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.SystemClock;
|
||||||
|
|
||||||
import com.j256.ormlite.dao.CloseableIterator;
|
import com.j256.ormlite.dao.CloseableIterator;
|
||||||
|
|
||||||
|
@ -35,10 +36,7 @@ public class UploadQueue {
|
||||||
if (NSClientService.handler == null) {
|
if (NSClientService.handler == null) {
|
||||||
Context context = MainApp.instance();
|
Context context = MainApp.instance();
|
||||||
context.startService(new Intent(context, NSClientService.class));
|
context.startService(new Intent(context, NSClientService.class));
|
||||||
try {
|
SystemClock.sleep(2000);
|
||||||
Thread.sleep(2000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.Overview.Dialogs;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -156,11 +157,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
||||||
Thread t = new Thread(new Runnable() {
|
Thread t = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
SystemClock.sleep(5000);
|
||||||
Thread.sleep(5000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
BolusProgressDialog.bolusEnded = true;
|
BolusProgressDialog.bolusEnded = true;
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpDanaR;
|
package info.nightscout.androidaps.plugins.PumpDanaR;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothSocket;
|
import android.bluetooth.BluetoothSocket;
|
||||||
|
import android.os.SystemClock;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -170,10 +171,7 @@ public class SerialIOThread extends Thread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
SystemClock.sleep(200);
|
||||||
Thread.sleep(200);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
}
|
|
||||||
if (!message.received) {
|
if (!message.received) {
|
||||||
log.warn("Reply not received " + message.getMessageName());
|
log.warn("Reply not received " + message.getMessageName());
|
||||||
if (message.getCommand() == 0xF0F1) {
|
if (message.getCommand() == 0xF0F1) {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import android.content.IntentFilter;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
|
import android.os.SystemClock;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
|
@ -552,10 +553,6 @@ public class DanaRExecutionService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void waitMsec(long msecs) {
|
private void waitMsec(long msecs) {
|
||||||
try {
|
SystemClock.sleep(msecs);
|
||||||
Thread.sleep(msecs);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpDanaRKorean;
|
package info.nightscout.androidaps.plugins.PumpDanaRKorean;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothSocket;
|
import android.bluetooth.BluetoothSocket;
|
||||||
|
import android.os.SystemClock;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -171,10 +172,7 @@ public class SerialIOThread extends Thread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
SystemClock.sleep(200);
|
||||||
Thread.sleep(200);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
}
|
|
||||||
if (!message.received) {
|
if (!message.received) {
|
||||||
log.warn("Reply not received " + message.getMessageName());
|
log.warn("Reply not received " + message.getMessageName());
|
||||||
if (message.getCommand() == 0xF0F1) {
|
if (message.getCommand() == 0xF0F1) {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import android.content.IntentFilter;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
|
import android.os.SystemClock;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
|
@ -524,10 +525,6 @@ public class DanaRKoreanExecutionService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void waitMsec(long msecs) {
|
private void waitMsec(long msecs) {
|
||||||
try {
|
SystemClock.sleep(msecs);
|
||||||
Thread.sleep(msecs);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpDanaRv2;
|
package info.nightscout.androidaps.plugins.PumpDanaRv2;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothSocket;
|
import android.bluetooth.BluetoothSocket;
|
||||||
|
import android.os.SystemClock;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -171,10 +172,7 @@ public class SerialIOThread extends Thread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
SystemClock.sleep(200);
|
||||||
Thread.sleep(200);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
}
|
|
||||||
if (!message.received) {
|
if (!message.received) {
|
||||||
log.warn("Reply not received " + message.getMessageName());
|
log.warn("Reply not received " + message.getMessageName());
|
||||||
if (message.getCommand() == 0xF0F1) {
|
if (message.getCommand() == 0xF0F1) {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import android.content.IntentFilter;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
|
import android.os.SystemClock;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
|
@ -554,10 +555,6 @@ public class DanaRv2ExecutionService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void waitMsec(long msecs) {
|
private void waitMsec(long msecs) {
|
||||||
try {
|
SystemClock.sleep(msecs);
|
||||||
Thread.sleep(msecs);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpVirtual;
|
package info.nightscout.androidaps.plugins.PumpVirtual;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
@ -222,28 +223,19 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
||||||
Double delivering = 0d;
|
Double delivering = 0d;
|
||||||
|
|
||||||
while (delivering < detailedBolusInfo.insulin) {
|
while (delivering < detailedBolusInfo.insulin) {
|
||||||
try {
|
SystemClock.sleep(200);
|
||||||
Thread.sleep(200);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
}
|
|
||||||
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
|
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
|
||||||
bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.bolusdelivering), delivering);
|
bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.bolusdelivering), delivering);
|
||||||
bolusingEvent.percent = Math.min((int) (delivering / detailedBolusInfo.insulin * 100), 100);
|
bolusingEvent.percent = Math.min((int) (delivering / detailedBolusInfo.insulin * 100), 100);
|
||||||
MainApp.bus().post(bolusingEvent);
|
MainApp.bus().post(bolusingEvent);
|
||||||
delivering += 0.1d;
|
delivering += 0.1d;
|
||||||
}
|
}
|
||||||
try {
|
SystemClock.sleep(200);
|
||||||
Thread.sleep(200);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
}
|
|
||||||
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
|
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
|
||||||
bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.bolusdelivered), detailedBolusInfo.insulin);
|
bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.bolusdelivered), detailedBolusInfo.insulin);
|
||||||
bolusingEvent.percent = 100;
|
bolusingEvent.percent = 100;
|
||||||
MainApp.bus().post(bolusingEvent);
|
MainApp.bus().post(bolusingEvent);
|
||||||
try {
|
SystemClock.sleep(1000);
|
||||||
Thread.sleep(1000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
}
|
|
||||||
if (Config.logPumpComm)
|
if (Config.logPumpComm)
|
||||||
log.debug("Delivering treatment insulin: " + detailedBolusInfo.insulin + "U carbs: " + detailedBolusInfo.carbs + "g " + result);
|
log.debug("Delivering treatment insulin: " + detailedBolusInfo.insulin + "U carbs: " + detailedBolusInfo.carbs + "g " + result);
|
||||||
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
||||||
|
|
|
@ -2,6 +2,7 @@ package info.nightscout.utils;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.view.ContextThemeWrapper;
|
import android.support.v7.view.ContextThemeWrapper;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
|
@ -28,10 +29,7 @@ public class OKDialog {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
if (runnable != null) {
|
if (runnable != null) {
|
||||||
try {
|
SystemClock.sleep(100);
|
||||||
Thread.sleep(100);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
}
|
|
||||||
activity.runOnUiThread(runnable);
|
activity.runOnUiThread(runnable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,10 +50,7 @@ public class OKDialog {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
if (runnable != null) {
|
if (runnable != null) {
|
||||||
try {
|
SystemClock.sleep(100);
|
||||||
Thread.sleep(100);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
}
|
|
||||||
activity.runOnUiThread(runnable);
|
activity.runOnUiThread(runnable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.support.v4.app.NotificationCompat;
|
import android.support.v4.app.NotificationCompat;
|
||||||
|
@ -400,11 +401,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
SystemClock.sleep(seconds * 1000);
|
||||||
Thread.sleep(seconds * 1000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
//e.printStackTrace();
|
|
||||||
}
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if(valid) {
|
if(valid) {
|
||||||
NotificationManagerCompat notificationManager =
|
NotificationManagerCompat notificationManager =
|
||||||
|
|
|
@ -15,6 +15,7 @@ import android.graphics.Rect;
|
||||||
import android.graphics.Shader;
|
import android.graphics.Shader;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
|
@ -473,11 +474,7 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
|
||||||
setIsAnimated(true);
|
setIsAnimated(true);
|
||||||
for (int i = 0; i <= 8 * 1000 / 40; i++) {
|
for (int i = 0; i <= 8 * 1000 / 40; i++) {
|
||||||
updateRainbow();
|
updateRainbow();
|
||||||
try {
|
SystemClock.sleep(40);
|
||||||
Thread.sleep(40);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mSgv.getPaint().setShader(null);
|
mSgv.getPaint().setShader(null);
|
||||||
setIsAnimated(false);
|
setIsAnimated(false);
|
||||||
|
|
|
@ -15,6 +15,7 @@ import android.graphics.RectF;
|
||||||
import android.graphics.Shader;
|
import android.graphics.Shader;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.support.wearable.watchface.WatchFaceStyle;
|
import android.support.wearable.watchface.WatchFaceStyle;
|
||||||
|
@ -504,11 +505,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
|
||||||
setIsAnimated(true);
|
setIsAnimated(true);
|
||||||
for (int i = 0; i <= 8 * 1000 / 40; i++) {
|
for (int i = 0; i <= 8 * 1000 / 40; i++) {
|
||||||
animationStep();
|
animationStep();
|
||||||
try {
|
SystemClock.sleep(40);
|
||||||
Thread.sleep(40);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
setIsAnimated(false);
|
setIsAnimated(false);
|
||||||
prepareDrawTime();
|
prepareDrawTime();
|
||||||
|
|
|
@ -15,6 +15,7 @@ import android.graphics.Rect;
|
||||||
import android.graphics.Shader;
|
import android.graphics.Shader;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
|
@ -427,11 +428,7 @@ public class NOChart extends WatchFace implements SharedPreferences.OnSharedPref
|
||||||
setIsAnimated(true);
|
setIsAnimated(true);
|
||||||
for (int i = 0; i <= 8 * 1000 / 40; i++) {
|
for (int i = 0; i <= 8 * 1000 / 40; i++) {
|
||||||
updateRainbow();
|
updateRainbow();
|
||||||
try {
|
SystemClock.sleep(40);
|
||||||
Thread.sleep(40);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mSgv.getPaint().setShader(null);
|
mSgv.getPaint().setShader(null);
|
||||||
setIsAnimated(false);
|
setIsAnimated(false);
|
||||||
|
|
Loading…
Reference in a new issue