code cleanup

This commit is contained in:
Milos Kozak 2020-12-06 15:09:32 +01:00
parent f370def798
commit 5f3aaf6b54
189 changed files with 495 additions and 527 deletions

View file

@ -122,7 +122,7 @@ class CareDialog : DialogFragmentWithDate() {
}
}
val bg = Profile.fromMgdlToUnits(GlucoseStatus(injector).getGlucoseStatusData()?.glucose
val bg = Profile.fromMgdlToUnits(GlucoseStatus(injector).glucoseStatusData?.glucose
?: 0.0, profileFunction.getUnits())
val bgTextWatcher: TextWatcher = object : TextWatcher {
override fun afterTextChanged(s: Editable) {}

View file

@ -40,7 +40,7 @@ import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
import info.nightscout.androidaps.utils.sharedPreferences.SP;
public class DetermineBasalAdapterAMAJS {
private HasAndroidInjector injector;
private final HasAndroidInjector injector;
@Inject AAPSLogger aapsLogger;
@Inject ConstraintChecker constraintChecker;
@Inject SP sp;
@ -48,7 +48,7 @@ public class DetermineBasalAdapterAMAJS {
@Inject TreatmentsPlugin treatmentsPlugin;
@Inject OpenHumansUploader openHumansUploader;
private ScriptReader mScriptReader;
private final ScriptReader mScriptReader;
private JSONObject mProfile;
private JSONObject mGlucoseStatus;

View file

@ -55,7 +55,7 @@ public class DetermineBasalAdapterSMBJS {
@Inject OpenHumansUploader openHumansUploader;
private ScriptReader mScriptReader;
private final ScriptReader mScriptReader;
private JSONObject mProfile;
private JSONObject mGlucoseStatus;
private JSONArray mIobData;

View file

@ -2,5 +2,4 @@ package info.nightscout.androidaps.plugins.configBuilder.events
import info.nightscout.androidaps.events.EventUpdateGui
class EventConfigBuilderUpdateGui : EventUpdateGui() {
}
class EventConfigBuilderUpdateGui : EventUpdateGui()

View file

@ -26,9 +26,9 @@ public abstract class Objective {
@Inject public SP sp;
@Inject public ResourceHelper resourceHelper;
private String spName;
@StringRes private int objective;
@StringRes private int gate;
private final String spName;
@StringRes private final int objective;
@StringRes private final int gate;
private long startedOn;
private long accomplishedOn;
List<Task> tasks = new ArrayList<>();
@ -116,7 +116,7 @@ public abstract class Objective {
public abstract class Task {
@StringRes
private int task;
private final int task;
private Objective objective;
ArrayList<Hint> hints = new ArrayList<>();
@ -138,8 +138,6 @@ public abstract class Objective {
return isCompleted();
}
;
public String getProgress() {
return resourceHelper.gs(isCompleted() ? R.string.completed_well_done : R.string.not_completed_yet);
}
@ -160,7 +158,7 @@ public abstract class Objective {
public class MinimumDurationTask extends Task {
private long minimumDuration;
private final long minimumDuration;
MinimumDurationTask(long minimumDuration) {
super(R.string.time_elapsed);
@ -197,7 +195,7 @@ public abstract class Objective {
@StringRes
int question;
ArrayList<Option> options = new ArrayList<>();
private String spIdentifier;
private final String spIdentifier;
private boolean answered;
private long disabledTo;
@ -274,8 +272,7 @@ public abstract class Objective {
public boolean evaluate() {
boolean selection = cb.isChecked();
if (selection && isCorrect) return true;
if (!selection && !isCorrect) return true;
return false;
return !selection && !isCorrect;
}
}

View file

@ -78,9 +78,7 @@ public class Objective0 extends Objective {
@Override
public boolean isCompleted() {
APSInterface usedAPS = activePlugin.getActiveAPS();
if (((PluginBase) usedAPS).isEnabled(PluginType.APS))
return true;
return false;
return ((PluginBase) usedAPS).isEnabled(PluginType.APS);
}
});
tasks.add(new Task(R.string.activate_profile) {

View file

@ -10,6 +10,7 @@ import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin;
import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin;
import info.nightscout.androidaps.plugins.general.nsclient.services.NSClientService;
import info.nightscout.androidaps.utils.T;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
import info.nightscout.androidaps.utils.sharedPreferences.SP;
@ -50,7 +51,7 @@ public class Objective3 extends Objective {
@Override
public boolean specialActionEnabled() {
return nsClientPlugin.nsClientService.isConnected && nsClientPlugin.nsClientService.hasWriteAuth;
return NSClientService.isConnected && NSClientService.hasWriteAuth;
}
@Override

View file

@ -36,12 +36,12 @@ class PhoneCheckerPlugin @Inject constructor(
private fun isDevModeEnabled(): Boolean {
return android.provider.Settings.Secure.getInt(context.contentResolver,
android.provider.Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
android.provider.Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0
}
override fun onStart() {
super.onStart()
phoneRooted = RootBeer(context).isRooted()
phoneRooted = RootBeer(context).isRooted
devMode = isDevModeEnabled()
}
}

View file

@ -46,7 +46,7 @@ class TriggerBg(injector: HasAndroidInjector) : Trigger(injector) {
}
override fun shouldRun(): Boolean {
val glucoseStatus = GlucoseStatus(injector).getGlucoseStatusData()
val glucoseStatus = GlucoseStatus(injector).glucoseStatusData
if (glucoseStatus == null && comparator.value == Comparator.Compare.IS_NOT_AVAILABLE) {
aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription())
return true

View file

@ -58,7 +58,7 @@ class TriggerDelta(injector: HasAndroidInjector) : Trigger(injector) {
}
override fun shouldRun(): Boolean {
val glucoseStatus = GlucoseStatus(injector).getGlucoseStatusData()
val glucoseStatus = GlucoseStatus(injector).glucoseStatusData
?: return if (comparator.value == Comparator.Compare.IS_NOT_AVAILABLE) {
aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription())
true

View file

@ -105,9 +105,7 @@ public class Food {
return false;
if (!Objects.equals(subcategory, other.subcategory))
return false;
if (!Objects.equals(units, other.units))
return false;
return true;
return Objects.equals(units, other.units);
}
public void copyFrom(Food other) {

View file

@ -49,7 +49,7 @@ class FoodFragment : DaggerFragment() {
super.onViewCreated(view, savedInstanceState)
food_recyclerview.setHasFixedSize(true)
food_recyclerview.setLayoutManager(LinearLayoutManager(view.context))
food_recyclerview.layoutManager = LinearLayoutManager(view.context)
food_recyclerview.adapter = RecyclerViewAdapter(foodPlugin.service?.foodData ?: ArrayList())
food_clearfilter.setOnClickListener {
@ -69,7 +69,7 @@ class FoodFragment : DaggerFragment() {
filterData()
}
}
food_subcategory.setOnItemSelectedListener(object : AdapterView.OnItemSelectedListener {
food_subcategory.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
filterData()
}
@ -77,7 +77,7 @@ class FoodFragment : DaggerFragment() {
override fun onNothingSelected(parent: AdapterView<*>?) {
filterData()
}
})
}
food_filter.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {

View file

@ -48,7 +48,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
@Inject RxBusWrapper rxBus;
@Inject FabricPrivacy fabricPrivacy;
private CompositeDisposable disposable = new CompositeDisposable();
private final CompositeDisposable disposable = new CompositeDisposable();
private static final ScheduledExecutorService foodEventWorker = Executors.newSingleThreadScheduledExecutor();
private static ScheduledFuture<?> scheduledFoodEventPost = null;

View file

@ -208,10 +208,10 @@ class ImportExportPrefs @Inject constructor(
// import is OK when we do not have errors (warnings are allowed)
val importOkCheckedAgain = checkIfImportIsOk(prefsReloaded)
then(prefsReloaded, importOkCheckedAgain);
then(prefsReloaded, importOkCheckedAgain)
}
} else {
then(prefs, importOk);
then(prefs, importOk)
}
}
@ -278,7 +278,7 @@ class ImportExportPrefs @Inject constructor(
}
}
public fun importSharedPreferences(activity: FragmentActivity, importFile: PrefsFile) {
fun importSharedPreferences(activity: FragmentActivity, importFile: PrefsFile) {
askToConfirmImport(activity, importFile) { password ->
@ -335,7 +335,7 @@ class ImportExportPrefs @Inject constructor(
for ((_, value) in prefs.metadata) {
if (value.status == PrefsStatus.ERROR)
importOk = false;
importOk = false
}
return importOk
}

View file

@ -167,10 +167,10 @@ class PrefFileListProvider @Inject constructor(
meta[PrefsMetadataKey.CREATED_AT]?.let { createdAt ->
try {
val date1 = DateTime.parse(createdAt.value);
val date1 = DateTime.parse(createdAt.value)
val date2 = DateTime.now()
val daysOld = Days.daysBetween(date1.toLocalDate(), date2.toLocalDate()).getDays()
val daysOld = Days.daysBetween(date1.toLocalDate(), date2.toLocalDate()).days
if (daysOld > IMPORT_AGE_NOT_YET_OLD_DAYS) {
createdAt.status = PrefsStatus.WARN

View file

@ -244,7 +244,7 @@ class EncryptedPrefsFormat @Inject constructor(
metadata[PrefsMetadataKey.FILE_FORMAT] = PrefMetadata(resourceHelper.gs(R.string.prefdecrypt_wrong_json), PrefsStatus.ERROR)
}
return metadata;
return metadata
}
}

View file

@ -37,7 +37,7 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList
@Inject UploadQueue uploadQueue;
@Inject FabricPrivacy fabricPrivacy;
private CompositeDisposable disposable = new CompositeDisposable();
private final CompositeDisposable disposable = new CompositeDisposable();
private TextView logTextView;
private TextView queueTextView;

View file

@ -51,7 +51,7 @@ import io.reactivex.schedulers.Schedulers;
@Singleton
public class NSClientPlugin extends PluginBase {
private CompositeDisposable disposable = new CompositeDisposable();
private final CompositeDisposable disposable = new CompositeDisposable();
private final AAPSLogger aapsLogger;
private final RxBusWrapper rxBus;
@ -73,7 +73,7 @@ public class NSClientPlugin extends PluginBase {
public NSClientService nsClientService = null;
private NsClientReceiverDelegate nsClientReceiverDelegate;
private final NsClientReceiverDelegate nsClientReceiverDelegate;
@Inject
public NSClientPlugin(
@ -209,7 +209,7 @@ public class NSClientPlugin extends PluginBase {
}
}
private ServiceConnection mConnection = new ServiceConnection() {
private final ServiceConnection mConnection = new ServiceConnection() {
public void onServiceDisconnected(ComponentName name) {
aapsLogger.debug(LTag.NSCLIENT, "Service is disconnected");
@ -276,7 +276,7 @@ public class NSClientPlugin extends PluginBase {
}
public boolean hasWritePermission() {
return nsClientService.hasWriteAuth;
return NSClientService.hasWriteAuth;
}
public void handleClearAlarm(NSAlarm originalAlarm, long silenceTimeInMsec) {

View file

@ -389,7 +389,7 @@ public class NSDeviceStatus {
// ********* Uploader data ***********
private static HashMap<String, Uploader> uploaders = new HashMap<>();
private static final HashMap<String, Uploader> uploaders = new HashMap<>();
static class Uploader {
long clock = 0L;

View file

@ -10,9 +10,9 @@ import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
public class NSTreatment {
private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
private static final Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
private JSONObject data;
private final JSONObject data;
private String action = null; // "update", "remove" or null (add)
public NSTreatment(JSONObject obj) {

View file

@ -91,10 +91,10 @@ public class NSClientService extends DaggerService {
@Inject DateUtil dateUtil;
@Inject UploadQueue uploadQueue;
private CompositeDisposable disposable = new CompositeDisposable();
private final CompositeDisposable disposable = new CompositeDisposable();
static public PowerManager.WakeLock mWakeLock;
private IBinder mBinder = new NSClientService.LocalBinder();
private final IBinder mBinder = new NSClientService.LocalBinder();
static ProfileStore profileStore;
@ -123,9 +123,9 @@ public class NSClientService extends DaggerService {
private String nsAPIhashCode = "";
private final ArrayList<Long> reconnections = new ArrayList<>();
private int WATCHDOG_INTERVAL_MINUTES = 2;
private int WATCHDOG_RECONNECT_IN = 15;
private int WATCHDOG_MAXCONNECTIONS = 5;
private final int WATCHDOG_INTERVAL_MINUTES = 2;
private final int WATCHDOG_RECONNECT_IN = 15;
private final int WATCHDOG_MAXCONNECTIONS = 5;
public NSClientService() {
super();
@ -322,7 +322,7 @@ public class NSClientService extends DaggerService {
}
}
private Emitter.Listener onConnect = new Emitter.Listener() {
private final Emitter.Listener onConnect = new Emitter.Listener() {
@Override
public void call(Object... args) {
connectCounter++;
@ -360,7 +360,7 @@ public class NSClientService extends DaggerService {
}
}
private Emitter.Listener onDisconnect = new Emitter.Listener() {
private final Emitter.Listener onDisconnect = new Emitter.Listener() {
@Override
public void call(Object... args) {
aapsLogger.debug(LTag.NSCLIENT, "disconnect reason: {}", args);
@ -412,7 +412,7 @@ public class NSClientService extends DaggerService {
nsDevice = sp.getString("careportal_enteredby", "");
}
private Emitter.Listener onError = new Emitter.Listener() {
private final Emitter.Listener onError = new Emitter.Listener() {
@Override
public void call(final Object... args) {
String msg = "Unknown Error";
@ -423,7 +423,7 @@ public class NSClientService extends DaggerService {
}
};
private Emitter.Listener onPing = new Emitter.Listener() {
private final Emitter.Listener onPing = new Emitter.Listener() {
@Override
public void call(final Object... args) {
rxBus.send(new EventNSClientNewLog("PING", "received"));
@ -432,7 +432,7 @@ public class NSClientService extends DaggerService {
}
};
private Emitter.Listener onAnnouncement = new Emitter.Listener() {
private final Emitter.Listener onAnnouncement = new Emitter.Listener() {
/*
{
"level":0,
@ -456,7 +456,7 @@ public class NSClientService extends DaggerService {
}
};
private Emitter.Listener onAlarm = new Emitter.Listener() {
private final Emitter.Listener onAlarm = new Emitter.Listener() {
/*
{
"level":1,
@ -482,7 +482,7 @@ public class NSClientService extends DaggerService {
}
};
private Emitter.Listener onUrgentAlarm = args -> {
private final Emitter.Listener onUrgentAlarm = args -> {
JSONObject data;
try {
data = (JSONObject) args[0];
@ -492,7 +492,7 @@ public class NSClientService extends DaggerService {
}
};
private Emitter.Listener onClearAlarm = new Emitter.Listener() {
private final Emitter.Listener onClearAlarm = new Emitter.Listener() {
/*
{
"clear":true,
@ -516,7 +516,7 @@ public class NSClientService extends DaggerService {
}
};
private Emitter.Listener onDataUpdate = new Emitter.Listener() {
private final Emitter.Listener onDataUpdate = new Emitter.Listener() {
@Override
public void call(final Object... args) {
NSClientService.handler.post(() -> {

View file

@ -33,7 +33,7 @@ class QuickWizardListActivity : NoSplashAppCompatActivity() {
private var disposable: CompositeDisposable = CompositeDisposable()
private inner class RecyclerViewAdapter internal constructor(internal var fragmentManager: FragmentManager) : RecyclerView.Adapter<RecyclerViewAdapter.QuickWizardEntryViewHolder>() {
private inner class RecyclerViewAdapter(var fragmentManager: FragmentManager) : RecyclerView.Adapter<RecyclerViewAdapter.QuickWizardEntryViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QuickWizardEntryViewHolder {
return QuickWizardEntryViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.overview_quickwizardlist_item, parent, false), fragmentManager)
@ -48,7 +48,7 @@ class QuickWizardListActivity : NoSplashAppCompatActivity() {
override fun getItemCount(): Int = quickWizard.size()
private inner class QuickWizardEntryViewHolder internal constructor(itemView: View, internal var fragmentManager: FragmentManager) : RecyclerView.ViewHolder(itemView) {
private inner class QuickWizardEntryViewHolder(itemView: View, var fragmentManager: FragmentManager) : RecyclerView.ViewHolder(itemView) {
val buttonText: TextView = itemView.findViewById(R.id.overview_quickwizard_item_buttonText)
val carbs: TextView = itemView.findViewById(R.id.overview_quickwizard_item_carbs)
val from: TextView = itemView.findViewById(R.id.overview_quickwizard_item_from)

View file

@ -315,7 +315,7 @@ public class AreaGraphSeries<E extends DoubleDataPoint> extends BaseSeries<E> {
canvas.drawPath(mPath, paint);
canvas.drawPath(mSecondPath, paint);
if (mStyles.drawBackground) {
canvas.drawRect((float)startX, (float)startY2, endX, endY1, mPaintBackground);
canvas.drawRect(startX, startY2, endX, endY1, mPaintBackground);
}
} else if (mStyles.drawDataPoints) {
//fix: last value not drawn as datapoint. Draw first point here, and then on every step the end values (above)

View file

@ -11,9 +11,9 @@ import java.io.Serializable;
public class DoubleDataPoint implements DataPointInterface, Serializable {
private static final long serialVersionUID=1428267322645L;
private double x;
private double y1;
private double y2;
private final double x;
private final double y1;
private final double y2;
public DoubleDataPoint(double x, double y1, double y2) {
this.x=x;

View file

@ -12,10 +12,10 @@ import java.util.Date;
public class ScaledDataPoint implements DataPointInterface, Serializable {
private static final long serialVersionUID=1428263342645L;
private double x;
private double y;
private final double x;
private final double y;
private Scale scale;
private final Scale scale;
public ScaledDataPoint(double x, double y, Scale scale) {
this.x=x;

View file

@ -137,7 +137,7 @@ class PersistentNotificationPlugin @Inject constructor(
var line1_aa: String
val units = profileFunction.getUnits()
val lastBG = iobCobCalculatorPlugin.lastBg()
val glucoseStatus = GlucoseStatus(injector).getGlucoseStatusData()
val glucoseStatus = GlucoseStatus(injector).glucoseStatusData
if (lastBG != null) {
line1_aa = lastBG.valueToUnitsToString(units)
line1 = line1_aa

View file

@ -289,7 +289,7 @@ class SmsCommunicatorPlugin @Inject constructor(
val agoMin = (agoMsec / 60.0 / 1000.0).toInt()
reply = resourceHelper.gs(R.string.sms_lastbg) + " " + lastBG.valueToUnitsToString(units) + " " + String.format(resourceHelper.gs(R.string.sms_minago), agoMin) + ", "
}
val glucoseStatus = GlucoseStatus(injector).getGlucoseStatusData()
val glucoseStatus = GlucoseStatus(injector).glucoseStatusData
if (glucoseStatus != null) reply += resourceHelper.gs(R.string.sms_delta) + " " + Profile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units + ", "
activePlugin.activeTreatments.updateTotalIOBTreatments()
val bolusIob = activePlugin.activeTreatments.lastCalculationTreatments.round()
@ -350,7 +350,7 @@ class SmsCommunicatorPlugin @Inject constructor(
"STATUS" -> {
val reply = if (loopPlugin.isEnabled(PluginType.LOOP)) {
if (loopPlugin.isSuspended()) String.format(resourceHelper.gs(R.string.loopsuspendedfor), loopPlugin.minutesToEndOfSuspend())
if (loopPlugin.isSuspended) String.format(resourceHelper.gs(R.string.loopsuspendedfor), loopPlugin.minutesToEndOfSuspend())
else resourceHelper.gs(R.string.smscommunicator_loopisenabled)
} else
resourceHelper.gs(R.string.smscommunicator_loopisdisabled)

View file

@ -35,7 +35,7 @@ class SmsCommunicatorOtpActivity : NoSplashAppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE)
setContentView(R.layout.activity_smscommunicator_otp)
smscommunicator_otp_verify_edit.addTextChangedListener(object : TextWatcher {

View file

@ -19,10 +19,10 @@ import java.util.concurrent.locks.ReentrantLock;
* Created by emmablack on 12/26/14.
*/
class SendToDataLayerThread extends AsyncTask<DataMap,Void,Void> {
private GoogleApiClient googleApiClient;
private final GoogleApiClient googleApiClient;
private static final String TAG = "SendToDataLayerThread";
private String path;
private String logPrefix = ""; // "WR: ";
private final String path;
private final String logPrefix = ""; // "WR: ";
private static int concurrency = 0;
private static int state = 0;
private static final ReentrantLock lock = new ReentrantLock();

View file

@ -769,7 +769,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
}
private void executeTask(AsyncTask task, DataMap... parameters) {
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Object[]) parameters);
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, parameters);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
// task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
// } else {

View file

@ -22,8 +22,8 @@ class InsulinFragment : DaggerFragment() {
override fun onResume() {
super.onResume()
insulin_name?.setText(activePlugin.activeInsulin.friendlyName)
insulin_comment?.setText(activePlugin.activeInsulin.comment)
insulin_name?.text = activePlugin.activeInsulin.friendlyName
insulin_comment?.text = activePlugin.activeInsulin.comment
insulin_dia?.text = resourceHelper.gs(R.string.dia) + ": " + activePlugin.activeInsulin.dia + "h"
insulin_graph?.show(activePlugin.activeInsulin)
}

View file

@ -23,7 +23,7 @@ public class GlucoseStatus {
@Inject public AAPSLogger aapsLogger;
@Inject public IobCobCalculatorPlugin iobCobCalculatorPlugin;
private HasAndroidInjector injector;
private final HasAndroidInjector injector;
public double glucose = 0d;
public double noise = 0d;

View file

@ -72,7 +72,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat
private final FabricPrivacy fabricPrivacy;
private final DateUtil dateUtil;
private CompositeDisposable disposable = new CompositeDisposable();
private final CompositeDisposable disposable = new CompositeDisposable();
private LongSparseArray<IobTotal> iobTable = new LongSparseArray<>(); // oldest at index 0
private LongSparseArray<IobTotal> absIobTable = new LongSparseArray<>(); // oldest at index 0, absolute insulin in the body

View file

@ -73,10 +73,10 @@ public class IobCobOref1Thread extends Thread {
private final HasAndroidInjector injector;
private final IobCobCalculatorPlugin iobCobCalculatorPlugin; // cannot be injected : HistoryBrowser uses different instance
private final TreatmentsPlugin treatmentsPlugin; // cannot be injected : HistoryBrowser uses different instance
private boolean bgDataReload;
private boolean limitDataToOldestAvailable;
private String from;
private long end;
private final boolean bgDataReload;
private final boolean limitDataToOldestAvailable;
private final String from;
private final long end;
private PowerManager.WakeLock mWakeLock;
@ -300,10 +300,7 @@ public class IobCobOref1Thread extends Thread {
// If mealCOB is zero but all deviations since hitting COB=0 are positive, exclude from autosens
if (autosensData.cob > 0 || autosensData.absorbing || autosensData.mealCarbs > 0) {
if (deviation > 0)
autosensData.absorbing = true;
else
autosensData.absorbing = false;
autosensData.absorbing = deviation > 0;
// stop excluding positive deviations as soon as mealCOB=0 if meal has been absorbing for >5h
if (autosensData.mealStartCounter > 60 && autosensData.cob < 0.5) {
autosensData.absorbing = false;
@ -329,10 +326,7 @@ public class IobCobOref1Thread extends Thread {
//if (iob.iob > currentBasal || uam ) {
if (iob.iob > 2 * currentBasal || autosensData.uam || autosensData.mealStartCounter < 9) {
autosensData.mealStartCounter++;
if (deviation > 0)
autosensData.uam = true;
else
autosensData.uam = false;
autosensData.uam = deviation > 0;
if (!autosensData.type.equals("uam")) {
// process.stderr.write("u(");
}

View file

@ -70,10 +70,10 @@ public class IobCobThread extends Thread {
private final HasAndroidInjector injector;
private final IobCobCalculatorPlugin iobCobCalculatorPlugin; // cannot be injected : HistoryBrowser uses different instance
private final TreatmentsPlugin treatmentsPlugin; // cannot be injected : HistoryBrowser uses different instance
private boolean bgDataReload;
private boolean limitDataToOldestAvailable;
private String from;
private long end;
private final boolean bgDataReload;
private final boolean limitDataToOldestAvailable;
private final String from;
private final long end;
private PowerManager.WakeLock mWakeLock;

View file

@ -2,5 +2,4 @@ package info.nightscout.androidaps.plugins.profile.local.events
import info.nightscout.androidaps.events.Event
class EventLocalProfileChanged : Event() {
}
class EventLocalProfileChanged : Event()

View file

@ -40,7 +40,7 @@ public class ComboFragment extends DaggerFragment implements View.OnClickListene
@Inject SP sp;
@Inject FabricPrivacy fabricPrivacy;
private CompositeDisposable disposable = new CompositeDisposable();
private final CompositeDisposable disposable = new CompositeDisposable();
private TextView stateView;
private TextView activityView;

View file

@ -451,7 +451,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
}
}
private BolusProgressReporter bolusProgressReporter = (state, percent, delivered) -> {
private final BolusProgressReporter bolusProgressReporter = (state, percent, delivered) -> {
EventOverviewBolusProgress event = EventOverviewBolusProgress.INSTANCE;
switch (state) {
case PROGRAMMING:
@ -966,9 +966,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
checkPumpTime(preCheckResult.state);
checkBasalRate(preCheckResult.state);
CommandResult historyCheckError = checkHistory();
if (historyCheckError != null) {
return historyCheckError;
}
return historyCheckError;
} else {
long now = System.currentTimeMillis();
TemporaryBasal aapsTbr = treatmentsPlugin.getTempBasalFromHistory(now);

View file

@ -61,7 +61,7 @@ public class RuffyScripter implements RuffyCommands {
private final Object screenlock = new Object();
private IRTHandler mHandler = new IRTHandler.Stub() {
private final IRTHandler mHandler = new IRTHandler.Stub() {
@Override
public void log(String message) {
if (log.isTraceEnabled()) {
@ -667,7 +667,7 @@ public class RuffyScripter implements RuffyCommands {
synchronized (screenlock) {
try {
// updates usually come in every ~500, occasionally up to 1100ms
screenlock.wait((long) 2000);
screenlock.wait(2000);
} catch (InterruptedException e) {
throw new CommandException("Interrupted");
}

View file

@ -21,7 +21,7 @@ import info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.history.Tbr;
import info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.history.Tdd;
public class ReadHistoryCommand extends BaseCommand {
private static Logger log = StacktraceLoggerWrapper.getLogger(ReadHistoryCommand.class);
private static final Logger log = StacktraceLoggerWrapper.getLogger(ReadHistoryCommand.class);
private final PumpHistoryRequest request;
private final PumpHistory history = new PumpHistory();

View file

@ -44,11 +44,11 @@ public class InsightAlertService extends DaggerService implements InsightConnect
private static final int NOTIFICATION_ID = 31345;
private LocalBinder localBinder = new LocalBinder();
private final LocalBinder localBinder = new LocalBinder();
private boolean connectionRequested;
private final Object $alertLock = new Object[0];
private Alert alert = null;
private MutableLiveData<Alert> alertLiveData = new MutableLiveData<>();
private final MutableLiveData<Alert> alertLiveData = new MutableLiveData<>();
private Thread thread;
private Vibrator vibrator;
private boolean vibrating;
@ -56,7 +56,7 @@ public class InsightAlertService extends DaggerService implements InsightConnect
private long ignoreTimestamp;
private AlertType ignoreType;
private ServiceConnection serviceConnection = new ServiceConnection() {
private final ServiceConnection serviceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder binder) {
connectionService = ((InsightConnectionService.LocalBinder) binder).getService();

View file

@ -46,7 +46,7 @@ public class LocalInsightFragment extends DaggerFragment implements View.OnClick
@Inject FabricPrivacy fabricPrivacy;
@Inject DateUtil dateUtil;
private CompositeDisposable disposable = new CompositeDisposable();
private final CompositeDisposable disposable = new CompositeDisposable();
private static final boolean ENABLE_OPERATING_MODE_BUTTON = false;

View file

@ -157,11 +157,11 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
public static final String ALERT_CHANNEL_ID = "AndroidAPS-InsightAlert";
private PumpDescription pumpDescription;
private final PumpDescription pumpDescription;
private InsightAlertService alertService;
private InsightConnectionService connectionService;
private long timeOffset;
private ServiceConnection serviceConnection = new ServiceConnection() {
private final ServiceConnection serviceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder binder) {
if (binder instanceof InsightConnectionService.LocalBinder) {

View file

@ -37,7 +37,7 @@ public class InsightAlertActivity extends DaggerAppCompatActivity {
private Button mute;
private Button confirm;
private ServiceConnection serviceConnection = new ServiceConnection() {
private final ServiceConnection serviceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder binder) {
alertService = ((InsightAlertService.LocalBinder) binder).getService();

View file

@ -43,11 +43,11 @@ public class InsightPairingActivity extends NoSplashAppCompatActivity implements
private TextView code;
private Button exit;
private RecyclerView deviceList;
private DeviceAdapter deviceAdapter = new DeviceAdapter();
private final DeviceAdapter deviceAdapter = new DeviceAdapter();
private InsightConnectionService service;
private ServiceConnection serviceConnection = new ServiceConnection() {
private final ServiceConnection serviceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder binder) {
service = ((InsightConnectionService.LocalBinder) binder).getService();
@ -199,7 +199,7 @@ public class InsightPairingActivity extends NoSplashAppCompatActivity implements
service.pair(device.getAddress());
}
private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
private final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
@ -214,7 +214,7 @@ public class InsightPairingActivity extends NoSplashAppCompatActivity implements
private class DeviceAdapter extends RecyclerView.Adapter<DeviceAdapter.ViewHolder> {
private List<BluetoothDevice> bluetoothDevices = new ArrayList<>();
private final List<BluetoothDevice> bluetoothDevices = new ArrayList<>();
public void addDevice(BluetoothDevice bluetoothDevice) {
if (!bluetoothDevices.contains(bluetoothDevice)) {
@ -248,7 +248,7 @@ public class InsightPairingActivity extends NoSplashAppCompatActivity implements
public class ViewHolder extends RecyclerView.ViewHolder {
private TextView deviceName;
private final TextView deviceName;
public ViewHolder(View itemView) {
super(itemView);

View file

@ -29,7 +29,7 @@ public class InsightPairingInformationActivity extends NoSplashAppCompatActivity
private TextView systemIdAppendix;
private TextView manufacturingDate;
private ServiceConnection serviceConnection = new ServiceConnection() {
private final ServiceConnection serviceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder binder) {
connectionService = ((InsightConnectionService.LocalBinder) binder).getService();

View file

@ -9,7 +9,7 @@ public enum Service {
PARAMETER((short) 0x0200, null),
REMOTE_CONTROL((short) 0x0100, "MAbcV2X6PVjxuz+R");
private short version;
private final short version;
private String servicePassword;
Service(short version, String servicePassword) {

View file

@ -6,8 +6,8 @@ import info.nightscout.androidaps.plugins.pump.insight.app_layer.configuration.O
public class ConfigurationMessageRequest<T extends AppLayerMessage> extends MessageRequest<T> {
private MessageRequest<OpenConfigurationWriteSessionMessage> openRequest;
private MessageRequest<CloseConfigurationWriteSessionMessage> closeRequest;
private final MessageRequest<OpenConfigurationWriteSessionMessage> openRequest;
private final MessageRequest<CloseConfigurationWriteSessionMessage> closeRequest;
public ConfigurationMessageRequest(T request, MessageRequest<OpenConfigurationWriteSessionMessage> openRequest, MessageRequest<CloseConfigurationWriteSessionMessage> closeRequest) {
super(request);

View file

@ -95,29 +95,29 @@ public class InsightConnectionService extends DaggerService implements Connectio
private static final int TIMEOUT_DURING_HANDSHAKE_NOTIFICATION_THRESHOLD = 3;
private static final long RESPONSE_TIMEOUT = 6000;
private List<StateCallback> stateCallbacks = new ArrayList<>();
private final List<StateCallback> stateCallbacks = new ArrayList<>();
private final List<Object> connectionRequests = new ArrayList<>();
private List<ExceptionCallback> exceptionCallbacks = new ArrayList<>();
private LocalBinder localBinder = new LocalBinder();
private final List<ExceptionCallback> exceptionCallbacks = new ArrayList<>();
private final LocalBinder localBinder = new LocalBinder();
private PairingDataStorage pairingDataStorage;
private InsightState state;
private PowerManager.WakeLock wakeLock;
private DelayedActionThread disconnectTimer;
private DelayedActionThread recoveryTimer;
private DelayedActionThread timeoutTimer;
private BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
private final BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
private BluetoothDevice bluetoothDevice;
private BluetoothSocket bluetoothSocket;
private ConnectionEstablisher connectionEstablisher;
private InputStreamReader inputStreamReader;
private OutputStreamWriter outputStreamWriter;
private KeyRequest keyRequest;
private ByteBuf buffer = new ByteBuf(BUFFER_SIZE);
private final ByteBuf buffer = new ByteBuf(BUFFER_SIZE);
private String verificationString;
private KeyPair keyPair;
private byte[] randomBytes;
private MessageQueue messageQueue = new MessageQueue();
private List<info.nightscout.androidaps.plugins.pump.insight.app_layer.Service> activatedServices = new ArrayList<>();
private final MessageQueue messageQueue = new MessageQueue();
private final List<info.nightscout.androidaps.plugins.pump.insight.app_layer.Service> activatedServices = new ArrayList<>();
private long lastDataTime;
private long lastConnected;
private long recoveryDuration = 0;

View file

@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.pump.insight.exceptions;
public class ConnectionFailedException extends InsightException {
private long durationOfConnectionAttempt;
private final long durationOfConnectionAttempt;
public ConnectionFailedException(long durationOfConnectionAttempt) {
this.durationOfConnectionAttempt = durationOfConnectionAttempt;

View file

@ -4,7 +4,7 @@ import info.nightscout.androidaps.plugins.pump.insight.exceptions.AppLayerExcept
public abstract class AppLayerErrorException extends AppLayerException {
private int errorCode;
private final int errorCode;
public AppLayerErrorException(int errorCode) {
this.errorCode = errorCode;

View file

@ -148,8 +148,7 @@ public abstract class SatlMessage {
public static boolean hasCompletePacket(ByteBuf byteBuf) {
if (byteBuf.getSize() < 37) return false;
if (byteBuf.getSize() < byteBuf.getUInt16LE(4) + 8) return false;
return true;
return byteBuf.getSize() >= byteBuf.getUInt16LE(4) + 8;
}
public Nonce getNonce() {

View file

@ -6,7 +6,7 @@ import java.nio.charset.StandardCharsets;
public class ByteBuf {
private byte[] bytes;
private final byte[] bytes;
private int size = 0;
public ByteBuf(int length) {

View file

@ -10,10 +10,10 @@ import java.util.UUID;
public class ConnectionEstablisher extends Thread {
private Callback callback;
private boolean forPairing;
private BluetoothAdapter bluetoothAdapter;
private BluetoothDevice bluetoothDevice;
private final Callback callback;
private final boolean forPairing;
private final BluetoothAdapter bluetoothAdapter;
private final BluetoothDevice bluetoothDevice;
private BluetoothSocket socket;
public ConnectionEstablisher(Callback callback, boolean forPairing, BluetoothAdapter bluetoothAdapter, BluetoothDevice bluetoothDevice, BluetoothSocket socket) {

View file

@ -2,8 +2,8 @@ package info.nightscout.androidaps.plugins.pump.insight.utils;
public class DelayedActionThread extends Thread {
private long duration;
private Runnable runnable;
private final long duration;
private final Runnable runnable;
private DelayedActionThread(String name, long duration, Runnable runnable) {
setName(name);

View file

@ -5,8 +5,8 @@ import java.util.Map;
public class IDStorage<T, I> {
private Map<T, I> types = new HashMap<>();
private Map<I, T> ids = new HashMap<>();
private final Map<T, I> types = new HashMap<>();
private final Map<I, T> ids = new HashMap<>();
public void put(T type, I id) {
types.put(type, id);

View file

@ -7,8 +7,8 @@ public class InputStreamReader extends Thread {
private static final int BUFFER_SIZE = 1024;
private InputStream inputStream;
private Callback callback;
private final InputStream inputStream;
private final Callback callback;
public InputStreamReader(InputStream inputStream, Callback callback) {
setName(getClass().getSimpleName());

View file

@ -7,8 +7,8 @@ public class OutputStreamWriter extends Thread {
private static final int BUFFER_SIZE = 1024;
private OutputStream outputStream;
private Callback callback;
private final OutputStream outputStream;
private final Callback callback;
private final ByteBuf buffer = new ByteBuf(BUFFER_SIZE);
public OutputStreamWriter(OutputStream outputStream, Callback callback) {

View file

@ -10,7 +10,7 @@ import info.nightscout.androidaps.plugins.pump.insight.descriptors.SystemIdentif
public class PairingDataStorage {
private SharedPreferences preferences;
private final SharedPreferences preferences;
private boolean paired;
private String macAddress;

View file

@ -43,8 +43,8 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper;
@Singleton
public class MDIPlugin extends PumpPluginBase implements PumpInterface {
private TreatmentsPlugin treatmentsPlugin;
private PumpDescription pumpDescription = new PumpDescription();
private final TreatmentsPlugin treatmentsPlugin;
private final PumpDescription pumpDescription = new PumpDescription();
@Inject
public MDIPlugin(

View file

@ -42,8 +42,8 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
@Singleton
public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin {
private ProfileFunction profileFunction;
private DateUtil dateUtil;
private final ProfileFunction profileFunction;
private final DateUtil dateUtil;
@Inject
public SensitivityAAPSPlugin(

View file

@ -36,9 +36,9 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
@Singleton
public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin {
private SP sp;
private DateUtil dateUtil;
private ProfileFunction profileFunction;
private final SP sp;
private final DateUtil dateUtil;
private final ProfileFunction profileFunction;
@Inject
public SensitivityWeightedAveragePlugin(

View file

@ -66,7 +66,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
@Inject DatabaseHelperInterface databaseHelper;
@Inject OpenHumansUploader openHumansUploader;
private CompositeDisposable disposable = new CompositeDisposable();
private final CompositeDisposable disposable = new CompositeDisposable();
private static final ScheduledExecutorService treatmentEventWorker = Executors.newSingleThreadScheduledExecutor();
private static ScheduledFuture<?> scheduledTreatmentEventPost = null;

View file

@ -80,7 +80,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
private final FabricPrivacy fabricPrivacy;
private final DateUtil dateUtil;
private CompositeDisposable disposable = new CompositeDisposable();
private final CompositeDisposable disposable = new CompositeDisposable();
protected TreatmentService service;

View file

@ -52,7 +52,7 @@ public class TreatmentsTempTargetFragment extends DaggerFragment {
@Inject FabricPrivacy fabricPrivacy;
@Inject DateUtil dateUtil;
private CompositeDisposable disposable = new CompositeDisposable();
private final CompositeDisposable disposable = new CompositeDisposable();
private RecyclerView recyclerView;

View file

@ -24,12 +24,12 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
*/
public class QueueThread extends Thread {
private CommandQueue queue;
private AAPSLogger aapsLogger;
private RxBusWrapper rxBus;
private ActivePluginProvider activePlugin;
private ResourceHelper resourceHelper;
private SP sp;
private final CommandQueue queue;
private final AAPSLogger aapsLogger;
private final RxBusWrapper rxBus;
private final ActivePluginProvider activePlugin;
private final ResourceHelper resourceHelper;
private final SP sp;
private boolean connectLogged = false;
boolean waitingForDisconnect = false;

View file

@ -19,7 +19,7 @@ import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
* Created by mike on 11.07.2016.
*/
public class JSONFormatter {
private static Logger log = StacktraceLoggerWrapper.getLogger(JSONFormatter.class);
private static final Logger log = StacktraceLoggerWrapper.getLogger(JSONFormatter.class);
public static Spanned format(final String jsonString) {
final JsonVisitor visitor = new JsonVisitor(1, '\t');

View file

@ -38,26 +38,26 @@ public class TimeListEdit {
private final int ONEHOURINSECONDS = 60 * 60;
private View[] intervals = new View[24];
private SpinnerHelper[] spinners = new SpinnerHelper[24];
private NumberPicker[] numberPickers1 = new NumberPicker[24];
private NumberPicker[] numberPickers2 = new NumberPicker[24];
private ImageView[] addButtons = new ImageView[24];
private ImageView[] removeButtons = new ImageView[24];
private final View[] intervals = new View[24];
private final SpinnerHelper[] spinners = new SpinnerHelper[24];
private final NumberPicker[] numberPickers1 = new NumberPicker[24];
private final NumberPicker[] numberPickers2 = new NumberPicker[24];
private final ImageView[] addButtons = new ImageView[24];
private final ImageView[] removeButtons = new ImageView[24];
private ImageView finalAdd;
private Context context;
private View view;
private int resLayoutId;
private String tagPrefix;
private final Context context;
private final View view;
private final int resLayoutId;
private final String tagPrefix;
private String label;
private JSONArray data1;
private JSONArray data2;
private double step;
private double min;
private double max;
private NumberFormat formatter;
private Runnable save;
private final JSONArray data1;
private final JSONArray data2;
private final double step;
private final double min;
private final double max;
private final NumberFormat formatter;
private final Runnable save;
private LinearLayout layout;
private TextView textlabel;
private int inflatedUntil = -1;

View file

@ -53,7 +53,7 @@ object PrefImportSummaryDialog {
for ((metaKey, metaEntry) in prefs.metadata) {
val rowLayout = LayoutInflater.from(themedCtx).inflate(R.layout.import_summary_item, null)
val label = (rowLayout.findViewById<View>(R.id.summary_text) as TextView)
label.setText(metaKey.formatForDisplay(context, metaEntry.value))
label.text = metaKey.formatForDisplay(context, metaEntry.value)
(rowLayout.findViewById<View>(R.id.summary_icon) as ImageView).setImageResource(metaKey.icon)
(rowLayout.findViewById<View>(R.id.status_icon) as ImageView).setImageResource(metaEntry.status.icon)
@ -84,9 +84,9 @@ object PrefImportSummaryDialog {
detailsBtn.setOnClickListener {
val detailsLayout = LayoutInflater.from(context).inflate(R.layout.import_summary_details, null)
val wview = detailsLayout.findViewById<View>(R.id.details_webview) as WebView
wview.loadData("<!doctype html><html><head><meta charset=\"utf-8\"><style>body { color: white; }</style></head><body>" + details.joinToString("<hr>"), "text/html; charset=utf-8", "utf-8");
wview.setBackgroundColor(Color.TRANSPARENT);
wview.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
wview.loadData("<!doctype html><html><head><meta charset=\"utf-8\"><style>body { color: white; }</style></head><body>" + details.joinToString("<hr>"), "text/html; charset=utf-8", "utf-8")
wview.setBackgroundColor(Color.TRANSPARENT)
wview.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null)
AlertDialogHelper.Builder(context, R.style.AppTheme)
.setCustomTitle(AlertDialogHelper.buildCustomTitle(

View file

@ -68,7 +68,7 @@ class TddCalculator @Inject constructor(
val absoluteRate = tbr?.tempBasalConvertedToAbsolute(t, profile) ?: profile.getBasal(t)
tdd.basal += absoluteRate / 60.0 * 5.0
if (!activePlugin.activePump.isFakingTempsByExtendedBoluses()) {
if (!activePlugin.activePump.isFakingTempsByExtendedBoluses) {
// they are not included in TBRs
val eb = getExtendedBolusFromHistory(t)
val absoluteEbRate = eb?.absoluteRate() ?: 0.0

View file

@ -172,7 +172,7 @@ class BolusWizard @Inject constructor(
}
// Insulin from 15 min trend
glucoseStatus = GlucoseStatus(injector).getGlucoseStatusData()
glucoseStatus = GlucoseStatus(injector).glucoseStatusData
glucoseStatus?.let {
if (useTrend) {
trend = it.short_avgdelta

View file

@ -107,7 +107,7 @@ class QuickWizardEntry @Inject constructor(private val injector: HasAndroidInjec
}
if (loopPlugin.isEnabled(loopPlugin.getType()) && loopPlugin.isSuperBolus) superBolus = false
// Trend
val glucoseStatus = GlucoseStatus(injector).getGlucoseStatusData()
val glucoseStatus = GlucoseStatus(injector).glucoseStatusData
var trend = false
if (useTrend() == YES) {
trend = true

View file

@ -19,8 +19,8 @@ import java.util.Map;
*/
public class Menu implements Parcelable{
private MenuType type;
private Map<MenuAttribute,Object> attributes = new HashMap<>();
private final MenuType type;
private final Map<MenuAttribute,Object> attributes = new HashMap<>();
public Menu(MenuType type)
{
@ -53,7 +53,7 @@ public class Menu implements Parcelable{
} else if (BolusType.class.toString().equals(clas)) {
o = BolusType.valueOf(value);
} else if (String.class.toString().equals(clas)) {
o = new String(value);
o = value;
}
if (o != null) {

View file

@ -60,7 +60,7 @@ public class TDDStatsActivity extends NoSplashAppCompatActivity {
@Inject DatabaseHelperInterface databaseHelper;
@Inject FabricPrivacy fabricPrivacy;
private CompositeDisposable disposable = new CompositeDisposable();
private final CompositeDisposable disposable = new CompositeDisposable();
TextView statusView, statsMessage, totalBaseBasal2;
EditText totalBaseBasal;

View file

@ -38,7 +38,7 @@ public class Profile {
@Inject public FabricPrivacy fabricPrivacy;
@Inject public ConfigInterface configInterface;
private HasAndroidInjector injector;
private final HasAndroidInjector injector;
private JSONObject json;
private String units;
@ -138,7 +138,7 @@ public class Profile {
public String log() {
String ret = "\n";
for (Integer hour = 0; hour < 24; hour++) {
double value = getBasalTimeFromMidnight((Integer) (hour * 60 * 60));
double value = getBasalTimeFromMidnight(hour * 60 * 60);
ret += "NS basal value for " + hour + ":00 is " + value + "\n";
}
ret += "NS units: " + getUnits();

View file

@ -46,7 +46,7 @@ class DefaultProfile @Inject constructor(val injector: HasAndroidInjector) {
profile.put("dia", 5.0)
profile.put("carbs_hr", 20) // not used
profile.put("delay", 5.0) // not used
profile.put("timezone", TimeZone.getDefault().getID())
profile.put("timezone", TimeZone.getDefault().id)
profile.put("target_high", JSONArray().put(JSONObject().put("time", "00:00").put("value", Profile.fromMgdlToUnits(108.0, units))))
profile.put("target_low", JSONArray().put(JSONObject().put("time", "00:00").put("value", Profile.fromMgdlToUnits(108.0, units))))
profile.put("units", units)

View file

@ -37,7 +37,7 @@ class DefaultProfileDPV @Inject constructor(val injector: HasAndroidInjector) {
profile.put("dia", 5.0)
profile.put("carbs_hr", 20) // not used
profile.put("delay", 5.0) // not used
profile.put("timezone", TimeZone.getDefault().getID())
profile.put("timezone", TimeZone.getDefault().id)
profile.put("target_high", JSONArray().put(JSONObject().put("time", "00:00").put("value", Profile.fromMgdlToUnits(108.0, units))))
profile.put("target_low", JSONArray().put(JSONObject().put("time", "00:00").put("value", Profile.fromMgdlToUnits(108.0, units))))
profile.put("units", units)

View file

@ -14,8 +14,8 @@ public class Constraint<T extends Comparable<T>> {
private T value;
private T originalValue;
private List<String> reasons = new ArrayList<>();
private List<String> mostLimiting = new ArrayList<>();
private final List<String> reasons = new ArrayList<>();
private final List<String> mostLimiting = new ArrayList<>();
public Constraint(T value) {
this.value = value;

View file

@ -192,7 +192,7 @@ public class APSResult {
protected void doClone(APSResult newResult) {
newResult.date = date;
newResult.reason = reason != null ? new String(reason) : null;
newResult.reason = reason != null ? reason : null;
newResult.rate = rate;
newResult.duration = duration;
newResult.tempBasalRequested = tempBasalRequested;

View file

@ -12,7 +12,7 @@ public enum ManufacturerType {
private String description;
private final String description;
ManufacturerType(String description) {

View file

@ -520,9 +520,7 @@ public class NSUpload {
public static boolean isIdValid(String _id) {
if (_id == null)
return false;
if (_id.length() == 24)
return true;
return false;
return _id.length() == 24;
}
public void generateCareportalEvent(String eventType, long time, String notes) {

View file

@ -8,7 +8,7 @@ import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
public class NSMbg {
private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
private static final Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
public long date;
public double mbg;
public String json;

View file

@ -14,9 +14,9 @@ import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
* {"mgdl":105,"mills":1455136282375,"device":"xDrip-BluetoothWixel","direction":"Flat","filtered":98272,"unfiltered":98272,"noise":1,"rssi":100}
*/
public class NSSgv {
private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
private static final Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
private JSONObject data;
private final JSONObject data;
public NSSgv(JSONObject obj) {
this.data = obj;

View file

@ -250,7 +250,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
Rect bounds = new Rect((int) endX, (int) endY + 3, (int) (xpluslength), (int) endY + 8);
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
canvas.drawRect(bounds, mPaint);
mPaint.setTextSize((float) (scaledTextSize));
mPaint.setTextSize(scaledTextSize);
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL));
mPaint.setFakeBoldText(true);
canvas.drawText(value.getLabel(), endX, endY, mPaint);

View file

@ -6,7 +6,7 @@ package info.nightscout.androidaps.plugins.general.overview.graphExtensions;
public class Scale {
private double multiplier;
private double shift;
private final double shift;
public Scale() {
shift = 0;

View file

@ -52,7 +52,7 @@ import io.reactivex.schedulers.Schedulers;
// When using this class, make sure that your first step is to create mConnection (see MedtronicPumpPlugin)
public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpInterface, ConstraintsInterface {
private CompositeDisposable disposable = new CompositeDisposable();
private final CompositeDisposable disposable = new CompositeDisposable();
protected HasAndroidInjector injector;
protected AAPSLogger aapsLogger;

View file

@ -6,11 +6,11 @@ package info.nightscout.androidaps.plugins.pump.common.data;
public class DoseSettings {
private double step;
private int durationStep;
private int maxDuration;
private double minDose;
private Double maxDose;
private final double step;
private final int durationStep;
private final int maxDuration;
private final double minDose;
private final Double maxDose;
public DoseSettings(double step, int durationStep, int maxDuration, double minDose, Double maxDose)
{

View file

@ -29,7 +29,7 @@ public enum PumpHistoryEntryGroup {
Unknown(R.string.history_group_unknown),
;
private int resourceId;
private final int resourceId;
private String translated;
private static List<PumpHistoryEntryGroup> translatedList;

View file

@ -9,7 +9,7 @@ public enum PumpStatusType {
Suspended("suspended") //
;
private String statusString;
private final String statusString;
PumpStatusType(String statusString) {

View file

@ -143,7 +143,7 @@ public enum PumpType {
MDI("MDI", ManufacturerType.AndroidAPS, "MDI");
private String description;
private final String description;
private ManufacturerType manufacturer;
private String model;
private double bolusSize;
@ -160,7 +160,7 @@ public enum PumpType {
private boolean hasCustomUnreachableAlertCheck;
private PumpType parent;
private static Map<String, PumpType> mapByDescription;
private static final Map<String, PumpType> mapByDescription;
static {
mapByDescription = new HashMap<>();
@ -454,7 +454,7 @@ public enum PumpType {
} else {
DoseStepSize specialBolusSize = getBaseBasalSpecialSteps();
basalStepSize = specialBolusSize.getStepSizeForAmount((double) basalAmount);
basalStepSize = specialBolusSize.getStepSizeForAmount(basalAmount);
}
if (basalAmount > getTbrSettings().getMaxDose())

View file

@ -145,7 +145,7 @@ public class ByteUtil {
public static String showPrintable(byte[] ra) {
String s = new String();
String s = "";
for (int i = 0; i < ra.length; i++) {
char c = (char) ra[i];
if (((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z'))) {

View file

@ -24,7 +24,7 @@ public class ProfileUtil {
stringBuilder.append(", ");
}
if (stringBuilder.length() > 3)
return stringBuilder.toString().substring(0, stringBuilder.length() - 2);
return stringBuilder.substring(0, stringBuilder.length() - 2);
else
return stringBuilder.toString();
}
@ -45,7 +45,7 @@ public class ProfileUtil {
stringBuilder.append(", ");
}
if (stringBuilder.length() > 3)
return stringBuilder.toString().substring(0, stringBuilder.length() - 2);
return stringBuilder.substring(0, stringBuilder.length() - 2);
else
return stringBuilder.toString();
}

View file

@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.pump.common.utils;
import org.joda.time.LocalDateTime;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
@ -23,7 +24,7 @@ public class StringUtil {
if (ra == null)
return "null array";
else
return new String(ra, Charset.forName("UTF-8"));
return new String(ra, StandardCharsets.UTF_8);
}

View file

@ -108,7 +108,7 @@ class AlarmSoundService : DaggerService() {
// TODO replace with VolumeShaper when min API level >= 26
private val volumeUpdater = object : Runnable {
override fun run() {
currentVolumeLevel++;
currentVolumeLevel++
val volumePercentage = 100.0.coerceAtMost(currentVolumeLevel / VOLUME_INCREASE_STEPS.toDouble() * 100)
val volume = (1 - (ln(1.0.coerceAtLeast(100.0 - volumePercentage)) / ln(100.0))).toFloat()

View file

@ -2,7 +2,7 @@ package info.nightscout.androidaps.utils;
public final class CRC {
private static int[] CRC16_TABLE = new int[]{
private static final int[] CRC16_TABLE = new int[]{
0, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad,
0xe1ce, 0xf1ef, 0x1231, 0x210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 0x9339, 0x8318, 0xb37b, 0xa35a,
0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 0x2462, 0x3443, 0x420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, 0xa56a, 0xb54b,

View file

@ -53,7 +53,7 @@ public class DateUtil {
/**
* The date format in iso.
*/
private static String FORMAT_DATE_ISO_OUT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
private static final String FORMAT_DATE_ISO_OUT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
/**
* Takes in an ISO date string of the following format:
@ -222,7 +222,7 @@ public class DateUtil {
public static String minAgoShort(long time) {
int mins = (int) ((time - now()) / 1000 / 60);
return (mins > 0 ? "+" : "") + Integer.toString(mins);
return (mins > 0 ? "+" : "") + mins;
}
public static String hourAgo(long time, ResourceHelper resourceHelper) {
@ -230,7 +230,7 @@ public class DateUtil {
return resourceHelper.gs(R.string.hoursago, hours);
}
private static LongSparseArray<String> timeStrings = new LongSparseArray<>();
private static final LongSparseArray<String> timeStrings = new LongSparseArray<>();
public String timeStringFromSeconds(int seconds) {
String cached = timeStrings.get(seconds);

View file

@ -10,10 +10,10 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper;
* Created by mike on 11.07.2016.
*/
public class DecimalFormatter {
private static DecimalFormat format0dec = new DecimalFormat("0");
private static DecimalFormat format1dec = new DecimalFormat("0.0");
private static DecimalFormat format2dec = new DecimalFormat("0.00");
private static DecimalFormat format3dec = new DecimalFormat("0.000");
private static final DecimalFormat format0dec = new DecimalFormat("0");
private static final DecimalFormat format1dec = new DecimalFormat("0.0");
private static final DecimalFormat format2dec = new DecimalFormat("0.00");
private static final DecimalFormat format3dec = new DecimalFormat("0.000");
public static String to0Decimal(double value) {
return format0dec.format(value);

View file

@ -25,7 +25,7 @@ object AlertDialogHelper {
val titleLayout = LayoutInflater.from(ContextThemeWrapper(context, themeResId)).inflate(layoutResource, null)
(titleLayout.findViewById<View>(R.id.alertdialog_title) as TextView).text = title
(titleLayout.findViewById<View>(R.id.alertdialog_icon) as ImageView).setImageResource(iconResource)
titleLayout.findViewById<View>(R.id.alertdialog_title).setSelected(true)
titleLayout.findViewById<View>(R.id.alertdialog_title).isSelected = true
return titleLayout
}

View file

@ -24,8 +24,8 @@ fun String.hexStringToByteArray() : ByteArray {
val lowerCased = this.toLowerCase(Locale.getDefault())
for (i in 0 until length step 2) {
val firstIndex = HEX_CHARS.indexOf(lowerCased[i]);
val secondIndex = HEX_CHARS.indexOf(lowerCased[i + 1]);
val firstIndex = HEX_CHARS.indexOf(lowerCased[i])
val secondIndex = HEX_CHARS.indexOf(lowerCased[i + 1])
val octet = firstIndex.shl(4).or(secondIndex)
result.set(i.shr(1), octet.toByte())

View file

@ -135,9 +135,9 @@ class PasswordCheck @Inject constructor(
passwordExplanation?.let { alertDialogBuilder.setMessage(it) }
passwordWarning?.let {
val extraWarning: TextView = promptsView.findViewById<View>(R.id.password_prompt_extra_message) as TextView;
extraWarning.text = context.getString(it);
extraWarning.visibility = View.VISIBLE;
val extraWarning: TextView = promptsView.findViewById<View>(R.id.password_prompt_extra_message) as TextView
extraWarning.text = context.getString(it)
extraWarning.visibility = View.VISIBLE
}
val userInput = promptsView.findViewById<View>(R.id.password_prompt_pass) as EditText

Some files were not shown because too many files have changed in this diff Show more