lint & deprecation

This commit is contained in:
Milos Kozak 2020-05-12 13:34:32 +02:00
parent 9c472e4e05
commit b7ef191003
11 changed files with 85 additions and 96 deletions

View file

@ -7,7 +7,6 @@ import android.content.ServiceConnection;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBinder;
import android.text.Html;
import android.text.Spanned;
import androidx.preference.PreferenceFragmentCompat;
@ -42,6 +41,7 @@ import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientS
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientUpdateGUI;
import info.nightscout.androidaps.plugins.general.nsclient.services.NSClientService;
import info.nightscout.androidaps.utils.FabricPrivacy;
import info.nightscout.androidaps.utils.HtmlHelper;
import info.nightscout.androidaps.utils.ToastUtils;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
import info.nightscout.androidaps.utils.sharedPreferences.SP;
@ -56,13 +56,14 @@ public class NSClientPlugin extends PluginBase {
private final RxBusWrapper rxBus;
private final ResourceHelper resourceHelper;
private final Context context;
private final FabricPrivacy fabricPrivacy;
private final SP sp;
private final Config config;
public Handler handler;
private final List<EventNSClientNewLog> listLog = new ArrayList<>();
Spanned textLog = Html.fromHtml("");
Spanned textLog = HtmlHelper.INSTANCE.fromHtml("");
public boolean paused;
boolean autoscroll;
@ -80,6 +81,7 @@ public class NSClientPlugin extends PluginBase {
RxBusWrapper rxBus,
ResourceHelper resourceHelper,
Context context,
FabricPrivacy fabricPrivacy,
SP sp,
NsClientReceiverDelegate nsClientReceiverDelegate,
Config config
@ -98,6 +100,7 @@ public class NSClientPlugin extends PluginBase {
this.rxBus = rxBus;
this.resourceHelper = resourceHelper;
this.context = context;
this.fabricPrivacy = fabricPrivacy;
this.sp = sp;
this.nsClientReceiverDelegate = nsClientReceiverDelegate;
this.config = config;
@ -134,17 +137,17 @@ public class NSClientPlugin extends PluginBase {
.subscribe(event -> {
status = event.getStatus(resourceHelper);
rxBus.send(new EventNSClientUpdateGUI());
}, exception -> FabricPrivacy.getInstance().logException(exception))
}, fabricPrivacy::logException)
);
disposable.add(rxBus
.toObservable(EventNetworkChange.class)
.observeOn(Schedulers.io())
.subscribe(event -> nsClientReceiverDelegate.onStatusEvent(event), exception -> FabricPrivacy.getInstance().logException(exception))
.subscribe(event -> nsClientReceiverDelegate.onStatusEvent(event), fabricPrivacy::logException)
);
disposable.add(rxBus
.toObservable(EventPreferenceChange.class)
.observeOn(Schedulers.io())
.subscribe(event -> nsClientReceiverDelegate.onStatusEvent(event), exception -> FabricPrivacy.getInstance().logException(exception))
.subscribe(event -> nsClientReceiverDelegate.onStatusEvent(event), fabricPrivacy::logException)
);
disposable.add(rxBus
.toObservable(EventAppExit.class)
@ -153,7 +156,7 @@ public class NSClientPlugin extends PluginBase {
if (nsClientService != null) {
context.unbindService(mConnection);
}
}, exception -> FabricPrivacy.getInstance().logException(exception))
}, fabricPrivacy::logException)
);
disposable.add(rxBus
.toObservable(EventNSClientNewLog.class)
@ -161,17 +164,17 @@ public class NSClientPlugin extends PluginBase {
.subscribe(event -> {
addToLog(event);
aapsLogger.debug(LTag.NSCLIENT, event.getAction() + " " + event.getLogText());
}, exception -> FabricPrivacy.getInstance().logException(exception))
}, fabricPrivacy::logException)
);
disposable.add(rxBus
.toObservable(EventChargingState.class)
.observeOn(Schedulers.io())
.subscribe(event -> nsClientReceiverDelegate.onStatusEvent(event), exception -> FabricPrivacy.getInstance().logException(exception))
.subscribe(event -> nsClientReceiverDelegate.onStatusEvent(event), fabricPrivacy::logException)
);
disposable.add(rxBus
.toObservable(EventNSClientResend.class)
.observeOn(Schedulers.io())
.subscribe(event -> resend(event.getReason()), exception -> FabricPrivacy.getInstance().logException(exception))
.subscribe(event -> resend(event.getReason()), fabricPrivacy::logException)
);
}
@ -236,7 +239,7 @@ public class NSClientPlugin extends PluginBase {
newTextLog.append(log.toPreparedHtml());
}
}
textLog = Html.fromHtml(newTextLog.toString());
textLog = HtmlHelper.INSTANCE.fromHtml(newTextLog.toString());
} catch (OutOfMemoryError e) {
ToastUtils.showToastInUiThread(context, rxBus, "Out of memory!\nStop using this phone !!!", R.raw.error);
}

View file

@ -2,13 +2,11 @@ package info.nightscout.androidaps.plugins.general.nsclient.acks;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import info.nightscout.androidaps.events.Event;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart;
import io.socket.client.Ack;
@ -16,16 +14,23 @@ import io.socket.client.Ack;
* Created by mike on 29.12.2015.
*/
public class NSAddAck extends Event implements Ack {
private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
private final AAPSLogger aapsLogger;
private final RxBusWrapper rxBus;
public String _id = null;
public String nsClientID = null;
public JSONObject json = null;
public NSAddAck(AAPSLogger aapsLogger, RxBusWrapper rxBus) {
this.aapsLogger = aapsLogger;
this.rxBus = rxBus;
}
public void call(Object... args) {
// Regular response
try {
JSONArray responsearray = (JSONArray) (args[0]);
JSONObject response = null;
JSONObject response;
if (responsearray.length() > 0) {
response = responsearray.getJSONObject(0);
_id = response.getString("_id");
@ -34,10 +39,10 @@ public class NSAddAck extends Event implements Ack {
nsClientID = response.getString("NSCLIENT_ID");
}
}
RxBus.Companion.getINSTANCE().send(this);
rxBus.send(this);
return;
} catch (Exception e) {
log.error("Unhandled exception", e);
aapsLogger.error("Unhandled exception", e);
}
// Check for not authorized
try {
@ -45,15 +50,13 @@ public class NSAddAck extends Event implements Ack {
if (response.has("result")) {
_id = null;
if (response.getString("result").contains("Not")) {
RxBus.Companion.getINSTANCE().send(new EventNSClientRestart());
rxBus.send(new EventNSClientRestart());
return;
}
if (L.isEnabled(LTag.NSCLIENT))
log.debug("DBACCESS " + response.getString("result"));
aapsLogger.debug(LTag.NSCLIENT, "DBACCESS " + response.getString("result"));
}
return;
} catch (Exception e) {
log.error("Unhandled exception", e);
aapsLogger.error("Unhandled exception", e);
}
}
}

View file

@ -2,11 +2,10 @@ package info.nightscout.androidaps.plugins.general.nsclient.acks;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import info.nightscout.androidaps.events.Event;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
import info.nightscout.androidaps.plugins.bus.RxBus;
import io.socket.client.Ack;
@ -14,7 +13,7 @@ import io.socket.client.Ack;
* Created by mike on 21.02.2016.
*/
public class NSUpdateAck extends Event implements Ack {
private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
private final AAPSLogger aapsLogger;
public boolean result = false;
public String _id;
public String action;
@ -27,17 +26,18 @@ public class NSUpdateAck extends Event implements Ack {
result = true;
else if (response.getString("result").equals("Missing _id")) {
result = true;
log.debug("Internal error: Missing _id returned on dbUpdate ack");
aapsLogger.debug(LTag.NSCLIENT, "Internal error: Missing _id returned on dbUpdate ack");
}
RxBus.Companion.getINSTANCE().send(this);
} catch (JSONException e) {
log.error("Unhandled exception", e);
aapsLogger.error("Unhandled exception", e);
}
}
public NSUpdateAck(String action, String _id) {
public NSUpdateAck(String action, String _id, AAPSLogger aapsLogger) {
super();
this.action = action;
this._id = _id;
this.aapsLogger = aapsLogger;
}
}

View file

@ -20,6 +20,7 @@ import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.aps.loop.APSResult;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.HtmlHelper;
import info.nightscout.androidaps.utils.Round;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
import info.nightscout.androidaps.utils.sharedPreferences.SP;
@ -158,7 +159,7 @@ public class NSDeviceStatus {
public Spanned getExtendedPumpStatus() {
if (deviceStatusPumpData != null && deviceStatusPumpData.extended != null)
return deviceStatusPumpData.extended;
return Html.fromHtml("");
return HtmlHelper.INSTANCE.fromHtml("");
}
public Spanned getPumpStatus() {
@ -170,7 +171,7 @@ public class NSDeviceStatus {
string.append(": </span>");
if (deviceStatusPumpData == null)
return Html.fromHtml("");
return HtmlHelper.INSTANCE.fromHtml("");
// test warning level
int level = Levels.INFO;
@ -225,7 +226,7 @@ public class NSDeviceStatus {
string.append("</span>"); // color
return Html.fromHtml(string.toString());
return HtmlHelper.INSTANCE.fromHtml(string.toString());
}
static class DeviceStatusPumpData {
@ -273,7 +274,7 @@ public class NSDeviceStatus {
String value = extendedJson.getString(key);
exteneded.append("<b>").append(key).append(":</b> ").append(value).append("<br>");
}
deviceStatusPumpData.extended = Html.fromHtml(exteneded.toString());
deviceStatusPumpData.extended = HtmlHelper.INSTANCE.fromHtml(exteneded.toString());
}
} catch (Exception e) {
aapsLogger.error("Unhandled exception", e);
@ -345,7 +346,7 @@ public class NSDeviceStatus {
}
string.append("</span>"); // color
return Html.fromHtml(string.toString());
return HtmlHelper.INSTANCE.fromHtml(string.toString());
}
public static long getOpenApsTimestamp() {
@ -365,11 +366,11 @@ public class NSDeviceStatus {
string.append("<b>").append(DateUtil.minAgo(resourceHelper, deviceStatusOpenAPSData.clockEnacted)).append("</b> ").append(deviceStatusOpenAPSData.enacted.getString("reason")).append("<br>");
if (deviceStatusOpenAPSData.suggested != null)
string.append("<b>").append(DateUtil.minAgo(resourceHelper, deviceStatusOpenAPSData.clockSuggested)).append("</b> ").append(deviceStatusOpenAPSData.suggested.getString("reason")).append("<br>");
return Html.fromHtml(string.toString());
return HtmlHelper.INSTANCE.fromHtml(string.toString());
} catch (JSONException e) {
aapsLogger.error("Unhandled exception", e);
}
return Html.fromHtml("");
return HtmlHelper.INSTANCE.fromHtml("");
}
// ********* Uploader data ***********
@ -441,7 +442,7 @@ public class NSDeviceStatus {
string.append(minBattery);
string.append("%");
return Html.fromHtml(string.toString());
return HtmlHelper.INSTANCE.fromHtml(string.toString());
}
public Spanned getExtendedUploaderStatus() {
@ -455,7 +456,7 @@ public class NSDeviceStatus {
string.append("<b>").append(device).append(":</b> ").append(uploader.battery).append("%<br>");
}
return Html.fromHtml(string.toString());
return HtmlHelper.INSTANCE.fromHtml(string.toString());
}
public static APSResult getAPSResult(HasAndroidInjector injector) {

View file

@ -19,7 +19,6 @@ import com.j256.ormlite.dao.CloseableIterator;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import java.net.URISyntaxException;
import java.sql.SQLException;
@ -41,9 +40,7 @@ import info.nightscout.androidaps.interfaces.DatabaseHelperInterface;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.ProfileStore;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin;
import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue;
@ -87,13 +84,13 @@ public class NSClientService extends DaggerService {
@Inject RxBusWrapper rxBus;
@Inject ResourceHelper resourceHelper;
@Inject SP sp;
@Inject FabricPrivacy fabricPrivacy;
@Inject NSClientPlugin nsClientPlugin;
@Inject BuildHelper buildHelper;
@Inject Config config;
@Inject DateUtil dateUtil;
@Inject UploadQueue uploadQueue;
private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
private CompositeDisposable disposable = new CompositeDisposable();
static public PowerManager.WakeLock mWakeLock;
@ -157,7 +154,7 @@ public class NSClientService extends DaggerService {
destroy();
initialize();
}
}, exception -> FabricPrivacy.getInstance().logException(exception))
}, fabricPrivacy::logException)
);
disposable.add(rxBus
.toObservable(EventPreferenceChange.class)
@ -171,17 +168,16 @@ public class NSClientService extends DaggerService {
destroy();
initialize();
}
}, exception -> FabricPrivacy.getInstance().logException(exception))
}, fabricPrivacy::logException)
);
disposable.add(rxBus
.toObservable(EventAppExit.class)
.observeOn(Schedulers.io())
.subscribe(event -> {
if (L.isEnabled(LTag.NSCLIENT))
log.debug("EventAppExit received");
aapsLogger.debug(LTag.NSCLIENT, "EventAppExit received");
destroy();
stopSelf();
}, exception -> FabricPrivacy.getInstance().logException(exception))
}, fabricPrivacy::logException)
);
disposable.add(rxBus
.toObservable(EventNSClientRestart.class)
@ -189,22 +185,22 @@ public class NSClientService extends DaggerService {
.subscribe(event -> {
latestDateInReceivedData = 0;
restart();
}, exception -> FabricPrivacy.getInstance().logException(exception))
}, fabricPrivacy::logException)
);
disposable.add(rxBus
.toObservable(NSAuthAck.class)
.observeOn(Schedulers.io())
.subscribe(this::processAuthAck, exception -> FabricPrivacy.getInstance().logException(exception))
.subscribe(this::processAuthAck, fabricPrivacy::logException)
);
disposable.add(rxBus
.toObservable(NSUpdateAck.class)
.observeOn(Schedulers.io())
.subscribe(this::processUpdateAck, exception -> FabricPrivacy.getInstance().logException(exception))
.subscribe(this::processUpdateAck, fabricPrivacy::logException)
);
disposable.add(rxBus
.toObservable(NSAddAck.class)
.observeOn(Schedulers.io())
.subscribe(this::processAddAck, exception -> FabricPrivacy.getInstance().logException(exception))
.subscribe(this::processAddAck, fabricPrivacy::logException)
);
}
@ -274,6 +270,7 @@ public class NSClientService extends DaggerService {
return START_STICKY;
}
@SuppressWarnings("deprecation")
public void initialize() {
dataCounter = 0;
@ -366,8 +363,7 @@ public class NSClientService extends DaggerService {
private Emitter.Listener onDisconnect = new Emitter.Listener() {
@Override
public void call(Object... args) {
if (L.isEnabled(LTag.NSCLIENT))
log.debug("disconnect reason: {}", args);
aapsLogger.debug(LTag.NSCLIENT, "disconnect reason: {}", args);
rxBus.send(new EventNSClientNewLog("NSCLIENT", "disconnect event"));
}
};
@ -401,7 +397,7 @@ public class NSClientService extends DaggerService {
authMessage.put("from", latestDateInReceivedData); // send data newer than
authMessage.put("secret", nsAPIhashCode);
} catch (JSONException e) {
log.error("Unhandled exception", e);
aapsLogger.error("Unhandled exception", e);
return;
}
rxBus.send(new EventNSClientNewLog("AUTH", "requesting auth"));
@ -455,8 +451,7 @@ public class NSClientService extends DaggerService {
data = (JSONObject) args[0];
handleAnnouncement(data);
} catch (Exception e) {
log.error("Unhandled exception", e);
return;
aapsLogger.error("Unhandled exception", e);
}
}
};
@ -482,8 +477,7 @@ public class NSClientService extends DaggerService {
data = (JSONObject) args[0];
handleAlarm(data);
} catch (Exception e) {
log.error("Unhandled exception", e);
return;
aapsLogger.error("Unhandled exception", e);
}
}
};
@ -494,7 +488,7 @@ public class NSClientService extends DaggerService {
data = (JSONObject) args[0];
handleUrgentAlarm(data);
} catch (Exception e) {
log.error("Unhandled exception", e);
aapsLogger.error("Unhandled exception", e);
}
};
@ -517,8 +511,7 @@ public class NSClientService extends DaggerService {
rxBus.send(new EventDismissNotification(Notification.NSURGENTALARM));
aapsLogger.debug(LTag.NSCLIENT, data.toString());
} catch (Exception e) {
log.error("Unhandled exception", e);
return;
aapsLogger.error("Unhandled exception", e);
}
}
};
@ -723,7 +716,7 @@ public class NSClientService extends DaggerService {
}
rxBus.send(new EventNSClientNewLog("LAST", dateUtil.dateAndTimeString(latestDateInReceivedData)));
} catch (JSONException e) {
log.error("Unhandled exception", e);
aapsLogger.error("Unhandled exception", e);
}
//rxBus.send(new EventNSClientNewLog("NSCLIENT", "onDataUpdate end");
} finally {
@ -743,7 +736,7 @@ public class NSClientService extends DaggerService {
mSocket.emit("dbUpdate", message, ack);
rxBus.send(new EventNSClientNewLog("DBUPDATE " + dbr.collection, "Sent " + dbr._id));
} catch (JSONException e) {
log.error("Unhandled exception", e);
aapsLogger.error("Unhandled exception", e);
}
}
@ -757,7 +750,7 @@ public class NSClientService extends DaggerService {
mSocket.emit("dbUpdateUnset", message, ack);
rxBus.send(new EventNSClientNewLog("DBUPDATEUNSET " + dbr.collection, "Sent " + dbr._id));
} catch (JSONException e) {
log.error("Unhandled exception", e);
aapsLogger.error("Unhandled exception", e);
}
}
@ -770,7 +763,7 @@ public class NSClientService extends DaggerService {
mSocket.emit("dbRemove", message, ack);
rxBus.send(new EventNSClientNewLog("DBREMOVE " + dbr.collection, "Sent " + dbr._id));
} catch (JSONException e) {
log.error("Unhandled exception", e);
aapsLogger.error("Unhandled exception", e);
}
}
@ -783,7 +776,7 @@ public class NSClientService extends DaggerService {
mSocket.emit("dbAdd", message, ack);
rxBus.send(new EventNSClientNewLog("DBADD " + dbr.collection, "Sent " + dbr.nsClientID));
} catch (JSONException e) {
log.error("Unhandled exception", e);
aapsLogger.error("Unhandled exception", e);
}
}
@ -818,16 +811,16 @@ public class NSClientService extends DaggerService {
while (iterator.hasNext() && maxcount > 0) {
DbRequest dbr = iterator.next();
if (dbr.action.equals("dbAdd")) {
NSAddAck addAck = new NSAddAck();
NSAddAck addAck = new NSAddAck(aapsLogger, rxBus);
dbAdd(dbr, addAck);
} else if (dbr.action.equals("dbRemove")) {
NSUpdateAck removeAck = new NSUpdateAck(dbr.action, dbr._id);
NSUpdateAck removeAck = new NSUpdateAck(dbr.action, dbr._id, aapsLogger);
dbRemove(dbr, removeAck);
} else if (dbr.action.equals("dbUpdate")) {
NSUpdateAck updateAck = new NSUpdateAck(dbr.action, dbr._id);
NSUpdateAck updateAck = new NSUpdateAck(dbr.action, dbr._id, aapsLogger);
dbUpdate(dbr, updateAck);
} else if (dbr.action.equals("dbUpdateUnset")) {
NSUpdateAck updateUnsetAck = new NSUpdateAck(dbr.action, dbr._id);
NSUpdateAck updateUnsetAck = new NSUpdateAck(dbr.action, dbr._id, aapsLogger);
dbUpdateUnset(dbr, updateUnsetAck);
}
maxcount--;
@ -836,7 +829,7 @@ public class NSClientService extends DaggerService {
iterator.close();
}
} catch (SQLException e) {
log.error("Unhandled exception", e);
aapsLogger.error("Unhandled exception", e);
}
rxBus.send(new EventNSClientNewLog("QUEUE", "Resend ended: " + reason));
@ -1038,7 +1031,7 @@ public class NSClientService extends DaggerService {
ret.add(newarr);
}
} catch (JSONException e) {
log.error("Unhandled exception", e);
aapsLogger.error("Unhandled exception", e);
ret = new ArrayList<>();
ret.add(array);
}

View file

@ -296,7 +296,7 @@ public class TDDStatsActivity extends NoSplashAppCompatActivity {
historyList = historyList.subList(0, Math.min(10, historyList.size()));
//fill single gaps
dummies = new LinkedList();
dummies = new LinkedList<>();
DateFormat df = new SimpleDateFormat("dd.MM.", Locale.getDefault());
for (int i = 0; i < historyList.size() - 1; i++) {
TDD elem1 = historyList.get(i);

View file

@ -2,19 +2,15 @@ package info.nightscout.androidaps.data;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface;
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.Round;
public class IobTotal implements DataPointWithLabelInterface {
private static Logger log = StacktraceLoggerWrapper.getLogger(IobTotal.class);
public double iob;
public double activity;
@ -108,8 +104,7 @@ public class IobTotal implements DataPointWithLabelInterface {
json.put("basaliob", basaliob);
json.put("activity", activity);
json.put("time", DateUtil.toISOString(new Date()));
} catch (JSONException e) {
log.error("Unhandled exception", e);
} catch (JSONException ignored) {
}
return json;
}
@ -139,8 +134,7 @@ public class IobTotal implements DataPointWithLabelInterface {
JSONObject iwzt = iobWithZeroTemp.determineBasalJson();
json.put("iobWithZeroTemp", iwzt);
}
} catch (JSONException e) {
log.error("Unhandled exception", e);
} catch (JSONException ignored) {
}
return json;
}

View file

@ -20,7 +20,6 @@ import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
// When no interval match the lastest record without duration is used
public class ProfileIntervals<T extends Interval> {
private static Logger log = StacktraceLoggerWrapper.getLogger(ProfileIntervals.class);
private LongSparseArray<T> rawData; // oldest at index 0

View file

@ -10,7 +10,7 @@ import info.nightscout.androidaps.logging.LTag;
* Created by mike on 19.03.2018.
*/
public class Constraint<T extends Comparable> {
public class Constraint<T extends Comparable<T>> {
private T value;
private T originalValue;
@ -85,14 +85,12 @@ public class Constraint<T extends Comparable> {
return from.getClass().getSimpleName().replace("Plugin", "");
}
public Constraint addReason(String reason, Object from) {
public void addReason(String reason, Object from) {
reasons.add(translateFrom(from) + ": " + reason);
return this;
}
public Constraint addMostLimingReason(String reason, Object from) {
private void addMostLimingReason(String reason, Object from) {
mostLimiting.add(translateFrom(from) + ": " + reason);
return this;
}
public String getReasons(AAPSLogger aapsLogger) {
@ -102,7 +100,7 @@ public class Constraint<T extends Comparable> {
if (count++ != 0) sb.append("\n");
sb.append(r);
}
aapsLogger.debug(LTag.CONSTRAINTS, "Limiting origial value: " + originalValue + " to " + value + ". Reason: " + sb.toString());
aapsLogger.debug(LTag.CONSTRAINTS, "Limiting original value: " + originalValue + " to " + value + ". Reason: " + sb.toString());
return sb.toString();
}
@ -117,7 +115,7 @@ public class Constraint<T extends Comparable> {
if (count++ != 0) sb.append("\n");
sb.append(r);
}
aapsLogger.debug(LTag.CONSTRAINTS, "Limiting origial value: " + originalValue + " to " + value + ". Reason: " + sb.toString());
aapsLogger.debug(LTag.CONSTRAINTS, "Limiting original value: " + originalValue + " to " + value + ". Reason: " + sb.toString());
return sb.toString();
}
@ -126,8 +124,6 @@ public class Constraint<T extends Comparable> {
}
public void copyReasons(Constraint<?> another) {
for (String s : another.getReasonList()) {
reasons.add(s);
}
reasons.addAll(another.getReasonList());
}
}

View file

@ -1,6 +1,5 @@
package info.nightscout.androidaps.plugins.aps.loop;
import android.text.Html;
import android.text.Spanned;
import org.json.JSONArray;
@ -20,14 +19,15 @@ import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.androidaps.interfaces.ProfileFunction;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
import info.nightscout.androidaps.interfaces.ProfileFunction;
import info.nightscout.androidaps.utils.DecimalFormatter;
import info.nightscout.androidaps.utils.HtmlHelper;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
import info.nightscout.androidaps.utils.sharedPreferences.SP;
@ -153,9 +153,9 @@ public class APSResult {
// reason
ret += "<b>" + resourceHelper.gs(R.string.reason) + "</b>: " + reason.replace("<", "&lt;").replace(">", "&gt;");
return Html.fromHtml(ret);
return HtmlHelper.INSTANCE.fromHtml(ret);
} else
return Html.fromHtml(resourceHelper.gs(R.string.nochangerequested));
return HtmlHelper.INSTANCE.fromHtml(resourceHelper.gs(R.string.nochangerequested));
}
public APSResult newAndClone(HasAndroidInjector injector) {