lint & deprecation

This commit is contained in:
Milos Kozak 2020-05-12 14:33:47 +02:00
parent b7ef191003
commit 7060c51681
23 changed files with 244 additions and 317 deletions

View file

@ -65,4 +65,8 @@ public class DatabaseHelperProvider implements DatabaseHelperInterface {
@NotNull @Override public CloseableIterator<DbRequest> getDbRequestInterator() {
return MainApp.getDbHelper().getDbRequestInterator();
}
@Override public long roundDateToSec(long date) {
return MainApp.getDbHelper().roundDateToSec(date);
}
}

View file

@ -3,14 +3,10 @@ package info.nightscout.androidaps.dependencyInjection
import dagger.Module
import dagger.android.ContributesAndroidInjector
import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.db.*
import info.nightscout.androidaps.interfaces.ProfileStore
import info.nightscout.androidaps.db.BgReading
import info.nightscout.androidaps.db.CareportalEvent
import info.nightscout.androidaps.db.ExtendedBolus
import info.nightscout.androidaps.db.ProfileSwitch
import info.nightscout.androidaps.db.TemporaryBasal
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
import info.nightscout.androidaps.db.Treatment
import info.nightscout.androidaps.plugins.general.food.FoodService
import info.nightscout.androidaps.plugins.treatments.TreatmentService
import info.nightscout.androidaps.utils.wizard.BolusWizard
import info.nightscout.androidaps.utils.wizard.QuickWizardEntry
@ -21,7 +17,9 @@ abstract class DataClassesModule {
@ContributesAndroidInjector abstract fun glucoseStatusInjector(): GlucoseStatus
@ContributesAndroidInjector abstract fun DatabaseHelperInjector(): DatabaseHelper
@ContributesAndroidInjector abstract fun treatmentServiceInjector(): TreatmentService
@ContributesAndroidInjector abstract fun foodServiceInjector(): FoodService
@ContributesAndroidInjector abstract fun bolusWizardInjector(): BolusWizard
@ContributesAndroidInjector abstract fun quickWizardEntryInjector(): QuickWizardEntry

View file

@ -28,6 +28,6 @@ class FoodPlugin @Inject constructor(
override fun onStart() {
super.onStart()
service = FoodService()
service = FoodService(injector)
}
}

View file

@ -15,7 +15,6 @@ import com.j256.ormlite.table.TableUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import java.sql.SQLException;
import java.util.ArrayList;
@ -25,15 +24,17 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.db.ICallback;
import info.nightscout.androidaps.events.Event;
import info.nightscout.androidaps.events.EventFoodDatabaseChanged;
import info.nightscout.androidaps.events.EventNsFood;
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.utils.FabricPrivacy;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers;
@ -43,16 +44,20 @@ import io.reactivex.schedulers.Schedulers;
*/
public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
private Logger log = StacktraceLoggerWrapper.getLogger(LTag.DATAFOOD);
@Inject AAPSLogger aapsLogger;
@Inject RxBusWrapper rxBus;
@Inject FabricPrivacy fabricPrivacy;
private CompositeDisposable disposable = new CompositeDisposable();
private static final ScheduledExecutorService foodEventWorker = Executors.newSingleThreadScheduledExecutor();
private static ScheduledFuture<?> scheduledFoodEventPost = null;
public FoodService() {
public FoodService(HasAndroidInjector injector) {
injector.androidInjector().inject(this);
onCreate();
dbInitialize();
disposable.add(RxBus.Companion.getINSTANCE()
disposable.add(rxBus
.toObservable(EventNsFood.class)
.observeOn(Schedulers.io())
.subscribe(event -> {
@ -62,7 +67,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
this.createFoodFromJsonIfNotExists(array);
else
this.deleteNS(array);
}, exception -> FabricPrivacy.getInstance().logException(exception))
}, fabricPrivacy::logException)
);
}
@ -88,7 +93,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
try {
return DaoManager.createDao(this.getConnectionSource(), Food.class);
} catch (SQLException e) {
log.error("Cannot create Dao for Food.class");
aapsLogger.error("Cannot create Dao for Food.class");
}
return null;
@ -98,18 +103,16 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
public void onCreate() {
super.onCreate();
try {
if (L.isEnabled(LTag.DATAFOOD))
log.info("onCreate");
aapsLogger.info(LTag.DATAFOOD, "onCreate");
TableUtils.createTableIfNotExists(this.getConnectionSource(), Food.class);
} catch (SQLException e) {
log.error("Can't create database", e);
aapsLogger.error("Can't create database", e);
throw new RuntimeException(e);
}
}
public void onUpgrade(ConnectionSource connectionSource, int oldVersion, int newVersion) {
if (L.isEnabled(LTag.DATAFOOD))
log.info("onUpgrade");
aapsLogger.info(LTag.DATAFOOD, "onUpgrade");
// this.resetFood();
}
@ -122,7 +125,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
TableUtils.dropTable(this.getConnectionSource(), Food.class, true);
TableUtils.createTableIfNotExists(this.getConnectionSource(), Food.class);
} catch (SQLException e) {
log.error("Unhandled exception", e);
aapsLogger.error("Unhandled exception", e);
}
scheduleFoodChange();
}
@ -147,9 +150,8 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
class PostRunnable implements Runnable {
public void run() {
if (L.isEnabled(LTag.DATAFOOD))
log.debug("Firing EventFoodChange");
RxBus.Companion.getINSTANCE().send(event);
aapsLogger.debug(LTag.DATAFOOD, "Firing EventFoodChange");
rxBus.send(event);
callback.setPost(null);
}
}
@ -183,7 +185,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
try {
return this.getDao().queryForAll();
} catch (SQLException e) {
log.error("Unhandled exception", e);
aapsLogger.error("Unhandled exception", e);
}
return new ArrayList<>();
@ -208,7 +210,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
Food food = Food.createFromJson(json);
this.createFoodFromJsonIfNotExists(food);
} catch (JSONException e) {
log.error("Unhandled exception", e);
aapsLogger.error("Unhandled exception", e);
}
}
@ -220,7 +222,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
this.createFoodFromJsonIfNotExists(food);
}
} catch (JSONException e) {
log.error("Unhandled exception", e);
aapsLogger.error("Unhandled exception", e);
}
}
@ -233,7 +235,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
String _id = json.getString("_id");
this.deleteByNSId(_id);
} catch (JSONException | SQLException e) {
log.error("Unhandled exception", e);
aapsLogger.error("Unhandled exception", e);
}
}
@ -244,7 +246,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
this.deleteNS(json);
}
} catch (JSONException e) {
log.error("Unhandled exception", e);
aapsLogger.error("Unhandled exception", e);
}
}
@ -258,8 +260,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
public void deleteByNSId(String _id) throws SQLException {
Food stored = this.findByNSId(_id);
if (stored != null) {
if (L.isEnabled(LTag.DATAFOOD))
log.debug("Removing Food record from database: " + stored.toString());
aapsLogger.debug(LTag.DATAFOOD, "Removing Food record from database: " + stored.toString());
this.delete(stored);
}
}
@ -276,7 +277,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
this.getDao().delete(food);
this.scheduleFoodChange();
} catch (SQLException e) {
log.error("Unhandled exception", e);
aapsLogger.error("Unhandled exception", e);
}
}
@ -312,10 +313,9 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
public void createOrUpdate(Food food) {
try {
this.getDao().createOrUpdate(food);
if (L.isEnabled(LTag.DATAFOOD))
log.debug("Created or Updated: " + food.toString());
aapsLogger.debug(LTag.DATAFOOD, "Created or Updated: " + food.toString());
} catch (SQLException e) {
log.error("Unable to createOrUpdate Food", e);
aapsLogger.error("Unable to createOrUpdate Food", e);
}
this.scheduleFoodChange();
}
@ -323,10 +323,9 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
public void create(Food food) {
try {
this.getDao().create(food);
if (L.isEnabled(LTag.DATAFOOD))
log.debug("New record: " + food.toString());
aapsLogger.debug(LTag.DATAFOOD, "New record: " + food.toString());
} catch (SQLException e) {
log.error("Unable to create Food", e);
aapsLogger.error("Unable to create Food", e);
}
this.scheduleFoodChange();
}
@ -346,7 +345,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
return list.get(0);
}
} catch (SQLException e) {
log.error("Unhandled exception", e);
aapsLogger.error("Unhandled exception", e);
}
return null;
}

View file

@ -22,6 +22,7 @@ import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientN
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart;
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientUpdateGUI;
import info.nightscout.androidaps.utils.FabricPrivacy;
import info.nightscout.androidaps.utils.HtmlHelper;
import info.nightscout.androidaps.utils.alertDialogs.OKDialog;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
import info.nightscout.androidaps.utils.sharedPreferences.SP;
@ -155,7 +156,7 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList
logScrollview.fullScroll(ScrollView.FOCUS_DOWN);
}
urlTextView.setText(nsClientPlugin.url());
Spanned queuetext = Html.fromHtml(resourceHelper.gs(R.string.queue) + " <b>" + uploadQueue.size() + "</b>");
Spanned queuetext = HtmlHelper.INSTANCE.fromHtml(resourceHelper.gs(R.string.queue) + " <b>" + uploadQueue.size() + "</b>");
queueTextView.setText(queuetext);
statusTextView.setText(nsClientPlugin.status);
}

View file

@ -3,19 +3,26 @@ package info.nightscout.androidaps.plugins.general.nsclient.acks;
import org.json.JSONObject;
import info.nightscout.androidaps.events.Event;
import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
import io.socket.client.Ack;
public class NSAuthAck extends Event implements Ack{
public class NSAuthAck extends Event implements Ack {
private final RxBusWrapper rxBus;
public boolean read = false;
public boolean write = false;
public boolean write_treatment = false;
public void call(Object...args) {
JSONObject response = (JSONObject)args[0];
public NSAuthAck(RxBusWrapper rxBus) {
this.rxBus = rxBus;
}
public void call(Object... args) {
JSONObject response = (JSONObject) args[0];
read = response.optBoolean("read");
write = response.optBoolean("write");
write_treatment = response.optBoolean("write_treatment");
RxBus.Companion.getINSTANCE().send(this);
rxBus.send(this);
}
}

View file

@ -6,7 +6,7 @@ import org.json.JSONObject;
import info.nightscout.androidaps.events.Event;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
import io.socket.client.Ack;
/**
@ -14,6 +14,8 @@ import io.socket.client.Ack;
*/
public class NSUpdateAck extends Event implements Ack {
private final AAPSLogger aapsLogger;
private final RxBusWrapper rxBus;
public boolean result = false;
public String _id;
public String action;
@ -28,16 +30,17 @@ public class NSUpdateAck extends Event implements Ack {
result = true;
aapsLogger.debug(LTag.NSCLIENT, "Internal error: Missing _id returned on dbUpdate ack");
}
RxBus.Companion.getINSTANCE().send(this);
rxBus.send(this);
} catch (JSONException e) {
aapsLogger.error("Unhandled exception", e);
}
}
public NSUpdateAck(String action, String _id, AAPSLogger aapsLogger) {
public NSUpdateAck(String action, String _id, AAPSLogger aapsLogger, RxBusWrapper rxBus) {
super();
this.action = action;
this._id = _id;
this.aapsLogger = aapsLogger;
this.rxBus = rxBus;
}
}

View file

@ -329,7 +329,7 @@ public class NSClientService extends DaggerService {
String socketId = mSocket != null ? mSocket.id() : "NULL";
rxBus.send(new EventNSClientNewLog("NSCLIENT", "connect #" + connectCounter + " event. ID: " + socketId));
if (mSocket != null)
sendAuthMessage(new NSAuthAck());
sendAuthMessage(new NSAuthAck(rxBus));
watchdog();
}
};
@ -814,13 +814,13 @@ public class NSClientService extends DaggerService {
NSAddAck addAck = new NSAddAck(aapsLogger, rxBus);
dbAdd(dbr, addAck);
} else if (dbr.action.equals("dbRemove")) {
NSUpdateAck removeAck = new NSUpdateAck(dbr.action, dbr._id, aapsLogger);
NSUpdateAck removeAck = new NSUpdateAck(dbr.action, dbr._id, aapsLogger, rxBus);
dbRemove(dbr, removeAck);
} else if (dbr.action.equals("dbUpdate")) {
NSUpdateAck updateAck = new NSUpdateAck(dbr.action, dbr._id, aapsLogger);
NSUpdateAck updateAck = new NSUpdateAck(dbr.action, dbr._id, aapsLogger, rxBus);
dbUpdate(dbr, updateAck);
} else if (dbr.action.equals("dbUpdateUnset")) {
NSUpdateAck updateUnsetAck = new NSUpdateAck(dbr.action, dbr._id, aapsLogger);
NSUpdateAck updateUnsetAck = new NSUpdateAck(dbr.action, dbr._id, aapsLogger, rxBus);
dbUpdateUnset(dbr, updateUnsetAck);
}
maxcount--;

View file

@ -4,15 +4,10 @@ import javax.inject.Inject;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
import info.nightscout.androidaps.plugins.common.ManufacturerType;
import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport;
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventRefreshButtonState;
import info.nightscout.androidaps.plugins.pump.medtronic.service.RileyLinkMedtronicService;
/**
* Created by geoff on 7/16/16.
@ -34,7 +29,7 @@ public class ResetRileyLinkConfigurationTask extends PumpTask {
@Override
public void run() {
RileyLinkPumpDevice pumpAbstract = (RileyLinkPumpDevice)activePlugin.getActivePump();
RileyLinkPumpDevice pumpAbstract = (RileyLinkPumpDevice) activePlugin.getActivePump();
rxBus.send(new EventRefreshButtonState(false));

View file

@ -8,7 +8,6 @@ import android.content.ServiceConnection;
import android.os.Binder;
import android.os.IBinder;
import android.os.Vibrator;
import android.text.Html;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationCompat;
@ -34,6 +33,7 @@ import info.nightscout.androidaps.plugins.pump.insight.exceptions.InsightExcepti
import info.nightscout.androidaps.plugins.pump.insight.exceptions.app_layer_errors.AppLayerErrorException;
import info.nightscout.androidaps.plugins.pump.insight.utils.AlertUtils;
import info.nightscout.androidaps.plugins.pump.insight.utils.ExceptionTranslator;
import info.nightscout.androidaps.utils.HtmlHelper;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
public class InsightAlertService extends DaggerService implements InsightConnectionService.StateCallback {
@ -299,7 +299,7 @@ public class InsightAlertService extends DaggerService implements InsightConnect
notificationBuilder.setContentTitle(alertUtils.getAlertCode(alert.getAlertType()) + " " + alertUtils.getAlertTitle(alert.getAlertType()));
String description = alertUtils.getAlertDescription(alert);
if (description != null)
notificationBuilder.setContentText(Html.fromHtml(description).toString());
notificationBuilder.setContentText(HtmlHelper.INSTANCE.fromHtml(description).toString());
Intent fullScreenIntent = new Intent(this, InsightAlertActivity.class);
PendingIntent fullScreenPendingIntent = PendingIntent.getActivity(this, 0, fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT);

View file

@ -22,6 +22,7 @@ import info.nightscout.androidaps.plugins.pump.insight.InsightAlertService;
import info.nightscout.androidaps.plugins.pump.insight.descriptors.Alert;
import info.nightscout.androidaps.plugins.pump.insight.descriptors.AlertStatus;
import info.nightscout.androidaps.plugins.pump.insight.utils.AlertUtils;
import info.nightscout.androidaps.utils.HtmlHelper;
public class InsightAlertActivity extends DaggerAppCompatActivity {
@ -91,7 +92,7 @@ public class InsightAlertActivity extends DaggerAppCompatActivity {
if (description == null) this.errorDescription.setVisibility(View.GONE);
else {
this.errorDescription.setVisibility(View.VISIBLE);
this.errorDescription.setText(Html.fromHtml(description));
this.errorDescription.setText(HtmlHelper.INSTANCE.fromHtml(description));
}
}

View file

@ -66,16 +66,6 @@ class VirtualPumpPlugin @Inject constructor(
), PumpInterface {
companion object {
private lateinit var virtualPumpPlugin: VirtualPumpPlugin
@Deprecated("Use dagger to get an instance")
fun getPlugin(): VirtualPumpPlugin {
checkNotNull(virtualPumpPlugin) { "Accessing VirtualPumpPlugin before first instantiation" }
return virtualPumpPlugin
}
}
private val disposable = CompositeDisposable()
var batteryPercent = 50
var reservoirInUnits = 50
@ -86,7 +76,6 @@ class VirtualPumpPlugin @Inject constructor(
private val pumpDescription = PumpDescription()
init {
virtualPumpPlugin = this
pumpDescription.isBolusCapable = true
pumpDescription.bolusStep = 0.1
pumpDescription.isExtendedBolusCapable = true

View file

@ -38,6 +38,7 @@ import info.nightscout.androidaps.events.Event;
import info.nightscout.androidaps.events.EventNsTreatment;
import info.nightscout.androidaps.events.EventReloadTreatmentData;
import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
@ -60,6 +61,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
@Inject FabricPrivacy fabricPrivacy;
@Inject RxBusWrapper rxBus;
@Inject MedtronicPumpPlugin medtronicPumpPlugin;
@Inject DatabaseHelperInterface databaseHelper;
private CompositeDisposable disposable = new CompositeDisposable();
@ -289,7 +291,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
}
try {
Treatment old;
treatment.date = DatabaseHelper.roundDateToSec(treatment.date);
treatment.date = databaseHelper.roundDateToSec(treatment.date);
if (treatment.source == Source.PUMP) {
// check for changed from pump change in NS
@ -412,7 +414,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
aapsLogger.debug(LTag.DATATREATMENTS, "DoubleBolusDebug: createOrUpdateMedtronic:: originalTreatment={}, fromNightScout={}", treatment, fromNightScout);
try {
treatment.date = DatabaseHelper.roundDateToSec(treatment.date);
treatment.date = databaseHelper.roundDateToSec(treatment.date);
Treatment existingTreatment = getRecord(treatment.pumpId, treatment.date);

View file

@ -30,8 +30,6 @@ import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
* Created by mike on 28.06.2016.
*/
public class NumberPickerVertical extends NumberPicker {
private static Logger log = StacktraceLoggerWrapper.getLogger(NumberPickerVertical.class);
public NumberPickerVertical(Context context) {
super(context);
}

View file

@ -3,14 +3,10 @@ package info.nightscout.androidaps.data;
import androidx.annotation.Nullable;
import androidx.collection.LongSparseArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import info.nightscout.androidaps.interfaces.Interval;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
/**
* Created by mike on 09.05.2017.
@ -23,11 +19,11 @@ public class ProfileIntervals<T extends Interval> {
private LongSparseArray<T> rawData; // oldest at index 0
public ProfileIntervals () {
public ProfileIntervals() {
rawData = new LongSparseArray<>();
}
public ProfileIntervals (ProfileIntervals<T> other) {
public ProfileIntervals(ProfileIntervals<T> other) {
rawData = other.rawData.clone();
}

View file

@ -5,10 +5,7 @@ import com.j256.ormlite.table.DatabaseTable;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
import info.nightscout.androidaps.utils.DateUtil;
/**
@ -18,7 +15,6 @@ import info.nightscout.androidaps.utils.DateUtil;
*/
@DatabaseTable(tableName = "DBRequests")
public class DbRequest {
private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.DATABASE);
@DatabaseField(id = true)
public String nsClientID = null;

View file

@ -3,23 +3,18 @@ package info.nightscout.androidaps.db;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import org.slf4j.Logger;
import java.util.Objects;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.core.R;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.interfaces.Interval;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.DecimalFormatter;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
@DatabaseTable(tableName = "TempTargets")
public class TempTarget implements Interval {
private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.DATABASE);
@DatabaseField(id = true)
public long date;

View file

@ -15,9 +15,10 @@ interface DatabaseHelperInterface {
fun create(record: DbRequest)
fun getDanaRHistoryRecordsByType(type: Byte): List<DanaRHistoryRecord>
fun getTDDs(): List<TDD>
fun size(table: String) : Long
fun size(table: String): Long
fun deleteAllDbRequests()
fun deleteDbRequest(id: String) : Int
fun deleteDbRequest(id: String): Int
fun deleteDbRequestbyMongoId(action: String, _id: String)
fun getDbRequestInterator() : CloseableIterator<DbRequest>
fun getDbRequestInterator(): CloseableIterator<DbRequest>
fun roundDateToSec(date: Long): Long
}

View file

@ -4,6 +4,7 @@ import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
@ -365,7 +366,7 @@ import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
*/
public class DeviceStatus {
private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
private final AAPSLogger aapsLogger;
public String device = null;
public JSONObject pump = null;
@ -375,6 +376,10 @@ public class DeviceStatus {
public int uploaderBattery = 0;
public String created_at = null;
public DeviceStatus(AAPSLogger aapsLogger) {
this.aapsLogger = aapsLogger;
}
public JSONObject mongoRecord() {
JSONObject record = new JSONObject();
@ -389,7 +394,7 @@ public class DeviceStatus {
if (uploaderBattery != 0) record.put("uploaderBattery", uploaderBattery);
if (created_at != null) record.put("created_at", created_at);
} catch (JSONException e) {
log.error("Unhandled exception", e);
aapsLogger.error("Unhandled exception", e);
}
return record;
}

View file

@ -1,28 +0,0 @@
package info.nightscout.androidaps.plugins.bus
import info.nightscout.androidaps.events.Event
import io.reactivex.Observable
import io.reactivex.schedulers.Schedulers
import io.reactivex.subjects.PublishSubject
class RxBus {
companion object {
@JvmStatic
@Deprecated("Get via Dagger. Will be removed once fully transitioned to Dagger")
var INSTANCE: RxBus = RxBus()//TODO: remove as soon as Dagger is fully set up
}
private val publisher = PublishSubject.create<Event>()
fun send(event: Event) {
publisher.onNext(event)
}
// Listen should return an Observable and not the publisher
// Using ofType we filter only events that match that class type
fun <T> toObservable(eventType: Class<T>): Observable<T> =
publisher
.subscribeOn(Schedulers.io())
.ofType(eventType)
}

View file

@ -2,20 +2,24 @@ package info.nightscout.androidaps.plugins.bus
import info.nightscout.androidaps.events.Event
import io.reactivex.Observable
import io.reactivex.schedulers.Schedulers
import io.reactivex.subjects.PublishSubject
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
open class RxBusWrapper @Inject constructor() {
private val bus: RxBus = RxBus.INSTANCE
private val publisher = PublishSubject.create<Event>()
fun send(event: Event) {
bus.send(event)
publisher.onNext(event)
}
// Listen should return an Observable and not the publisher
// Using ofType we filter only events that match that class type
fun <T> toObservable(eventType: Class<T>): Observable<T> =
bus.toObservable(eventType)
publisher
.subscribeOn(Schedulers.io())
.ofType(eventType)
}

View file

@ -199,7 +199,7 @@ public class NSUpload {
return;
}
DeviceStatus deviceStatus = new DeviceStatus();
DeviceStatus deviceStatus = new DeviceStatus(aapsLogger);
try {
LoopInterface.LastRun lastRun = loopPlugin.getLastRun();
if (lastRun != null && lastRun.getLastAPSRun() > System.currentTimeMillis() - 300 * 1000L) {