make classes static where possible

This commit is contained in:
Milos Kozak 2021-02-19 13:35:57 +01:00
parent e0d2507687
commit 87ffeb1d31
8 changed files with 42 additions and 44 deletions

View file

@ -39,7 +39,7 @@ public class AreaGraphSeries<E extends DoubleDataPoint> extends BaseSeries<E> {
/** /**
* wrapped styles regarding the line * wrapped styles regarding the line
*/ */
private final class Styles { private static final class Styles {
/** /**
* the thickness of the line. * the thickness of the line.
* This option will be ignored if you are * This option will be ignored if you are
@ -115,7 +115,7 @@ public class AreaGraphSeries<E extends DoubleDataPoint> extends BaseSeries<E> {
/** /**
* creates a series without data * creates a series without data
*/ */
public AreaGraphSeries() { @SuppressWarnings("unused") public AreaGraphSeries() {
init(); init();
} }
@ -174,9 +174,9 @@ public class AreaGraphSeries<E extends DoubleDataPoint> extends BaseSeries<E> {
Iterator<E> values = getValues(minX, maxX); Iterator<E> values = getValues(minX, maxX);
// draw background // draw background
double lastEndY1 = 0; double lastEndY1;
double lastEndY2 = 0; double lastEndY2;
double lastEndX = 0; double lastEndX;
// draw data // draw data
mPaint.setStrokeWidth(mStyles.thickness); mPaint.setStrokeWidth(mStyles.thickness);
@ -205,8 +205,6 @@ public class AreaGraphSeries<E extends DoubleDataPoint> extends BaseSeries<E> {
lastEndY1 = 0; lastEndY1 = 0;
lastEndY2 = 0; lastEndY2 = 0;
lastEndX = 0; lastEndX = 0;
double lastUsedEndX = 0;
float firstX = 0;
int i=0; int i=0;
while (values.hasNext()) { while (values.hasNext()) {
E value = values.next(); E value = values.next();

View file

@ -1,9 +1,5 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions; package info.nightscout.androidaps.plugins.general.overview.graphExtensions;
/**
* Created by mike on 24.04.2017.
*/
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Paint; import android.graphics.Paint;
@ -25,7 +21,7 @@ public class FixedLineGraphSeries<E extends DataPointInterface> extends BaseSeri
/** /**
* wrapped styles regarding the line * wrapped styles regarding the line
*/ */
private final class Styles { private static final class Styles {
/** /**
* the thickness of the line. * the thickness of the line.
* This option will be ignored if you are * This option will be ignored if you are
@ -100,7 +96,7 @@ public class FixedLineGraphSeries<E extends DataPointInterface> extends BaseSeri
/** /**
* creates a series without data * creates a series without data
*/ */
public FixedLineGraphSeries() { @SuppressWarnings("unused") public FixedLineGraphSeries() {
init(); init();
} }
@ -158,8 +154,8 @@ public class FixedLineGraphSeries<E extends DataPointInterface> extends BaseSeri
Iterator<E> values = getValues(minX, maxX); Iterator<E> values = getValues(minX, maxX);
// draw background // draw background
double lastEndY = 0; double lastEndY;
double lastEndX = 0; double lastEndX;
// draw data // draw data
mPaint.setStrokeWidth(mStyles.thickness); mPaint.setStrokeWidth(mStyles.thickness);
@ -263,8 +259,8 @@ public class FixedLineGraphSeries<E extends DataPointInterface> extends BaseSeri
lastUsedEndX = endX; lastUsedEndX = endX;
} else if (mStyles.drawDataPoints) { } else if (mStyles.drawDataPoints) {
//fix: last value not drawn as datapoint. Draw first point here, and then on every step the end values (above) //fix: last value not drawn as datapoint. Draw first point here, and then on every step the end values (above)
float first_X = (float) x + (graphLeft + 1); // float first_X = (float) x + (graphLeft + 1);
float first_Y = (float) (graphTop - y) + graphHeight; // float first_Y = (float) (graphTop - y) + graphHeight;
//TODO canvas.drawCircle(first_X, first_Y, dataPointsRadius, mPaint); //TODO canvas.drawCircle(first_X, first_Y, dataPointsRadius, mPaint);
} }
lastEndY = orgY; lastEndY = orgY;
@ -289,7 +285,7 @@ public class FixedLineGraphSeries<E extends DataPointInterface> extends BaseSeri
* *
* @return the thickness of the line * @return the thickness of the line
*/ */
public int getThickness() { @SuppressWarnings("unused") public int getThickness() {
return mStyles.thickness; return mStyles.thickness;
} }
@ -312,7 +308,7 @@ public class FixedLineGraphSeries<E extends DataPointInterface> extends BaseSeri
* @return whether the background will be drawn * @return whether the background will be drawn
* @see #getBackgroundColor() * @see #getBackgroundColor()
*/ */
public boolean isDrawBackground() { @SuppressWarnings("unused") public boolean isDrawBackground() {
return mStyles.drawBackground; return mStyles.drawBackground;
} }
@ -335,7 +331,7 @@ public class FixedLineGraphSeries<E extends DataPointInterface> extends BaseSeri
* @return flag whether the data points are highlighted * @return flag whether the data points are highlighted
* @see #setDataPointsRadius(float) * @see #setDataPointsRadius(float)
*/ */
public boolean isDrawDataPoints() { @SuppressWarnings("unused") public boolean isDrawDataPoints() {
return mStyles.drawDataPoints; return mStyles.drawDataPoints;
} }
@ -346,7 +342,7 @@ public class FixedLineGraphSeries<E extends DataPointInterface> extends BaseSeri
* @param drawDataPoints flag whether the data points are highlighted * @param drawDataPoints flag whether the data points are highlighted
* @see #setDataPointsRadius(float) * @see #setDataPointsRadius(float)
*/ */
public void setDrawDataPoints(boolean drawDataPoints) { @SuppressWarnings("unused") public void setDrawDataPoints(boolean drawDataPoints) {
mStyles.drawDataPoints = drawDataPoints; mStyles.drawDataPoints = drawDataPoints;
} }
@ -354,7 +350,7 @@ public class FixedLineGraphSeries<E extends DataPointInterface> extends BaseSeri
* @return the radius for the data points. * @return the radius for the data points.
* @see #setDrawDataPoints(boolean) * @see #setDrawDataPoints(boolean)
*/ */
public float getDataPointsRadius() { @SuppressWarnings("unused") public float getDataPointsRadius() {
return mStyles.dataPointsRadius; return mStyles.dataPointsRadius;
} }
@ -362,7 +358,7 @@ public class FixedLineGraphSeries<E extends DataPointInterface> extends BaseSeri
* @param dataPointsRadius the radius for the data points. * @param dataPointsRadius the radius for the data points.
* @see #setDrawDataPoints(boolean) * @see #setDrawDataPoints(boolean)
*/ */
public void setDataPointsRadius(float dataPointsRadius) { @SuppressWarnings("unused") public void setDataPointsRadius(float dataPointsRadius) {
mStyles.dataPointsRadius = dataPointsRadius; mStyles.dataPointsRadius = dataPointsRadius;
} }
@ -371,7 +367,7 @@ public class FixedLineGraphSeries<E extends DataPointInterface> extends BaseSeri
* the line. * the line.
* @see #setDrawBackground(boolean) * @see #setDrawBackground(boolean)
*/ */
public int getBackgroundColor() { @SuppressWarnings("unused") public int getBackgroundColor() {
return mStyles.backgroundColor; return mStyles.backgroundColor;
} }

View file

@ -266,7 +266,7 @@ public class TimeListEdit {
} }
class SpinnerAdapter extends ArrayAdapter<CharSequence> { static class SpinnerAdapter extends ArrayAdapter<CharSequence> {
List<Integer> values; List<Integer> values;
SpinnerAdapter(@NonNull Context context, int resource, final @NonNull List<CharSequence> objects, final @NonNull List<Integer> values) { SpinnerAdapter(@NonNull Context context, int resource, final @NonNull List<CharSequence> objects, final @NonNull List<Integer> values) {
@ -371,6 +371,7 @@ public class TimeListEdit {
} }
@SuppressWarnings("SameParameterValue")
private void addItem(int index, int timeAsSeconds, double value1, double value2) { private void addItem(int index, int timeAsSeconds, double value1, double value2) {
if (itemsCount() >= 24) return; if (itemsCount() >= 24) return;
if (itemsCount() > inflatedUntil) { if (itemsCount() > inflatedUntil) {

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.data;
import androidx.collection.LongSparseArray; import androidx.collection.LongSparseArray;
import org.jetbrains.annotations.NotNull;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
@ -66,7 +67,7 @@ public class Profile {
this.injector = injector; this.injector = injector;
} }
@Override @NotNull @Override
public String toString() { public String toString() {
if (json != null) if (json != null)
return json.toString(); return json.toString();
@ -137,7 +138,7 @@ public class Profile {
public String log() { public String log() {
String ret = "\n"; String ret = "\n";
for (Integer hour = 0; hour < 24; hour++) { for (int hour = 0; hour < 24; hour++) {
double value = getBasalTimeFromMidnight(hour * 60 * 60); double value = getBasalTimeFromMidnight(hour * 60 * 60);
ret += "NS basal value for " + hour + ":00 is " + value + "\n"; ret += "NS basal value for " + hour + ":00 is " + value + "\n";
} }
@ -184,7 +185,7 @@ public class Profile {
for (int index = 0; index < array.length(); index++) { for (int index = 0; index < array.length(); index++) {
try { try {
final JSONObject o = array.getJSONObject(index); final JSONObject o = array.getJSONObject(index);
long tas = 0; long tas;
try { try {
String time = o.getString("time"); String time = o.getString("time");
tas = getShitfTimeSecs(DateUtil.toSeconds(time)); tas = getShitfTimeSecs(DateUtil.toSeconds(time));
@ -318,7 +319,7 @@ public class Profile {
*/ */
Integer getShitfTimeSecs(Integer originalTime) { Integer getShitfTimeSecs(Integer originalTime) {
Integer shiftedTime = originalTime + timeshift * 60 * 60; int shiftedTime = originalTime + timeshift * 60 * 60;
shiftedTime = (shiftedTime + 24 * 60 * 60) % (24 * 60 * 60); shiftedTime = (shiftedTime + 24 * 60 * 60) % (24 * 60 * 60);
return shiftedTime; return shiftedTime;
} }
@ -358,7 +359,7 @@ public class Profile {
private double getValueToTime(LongSparseArray<Double> array, Integer timeAsSeconds) { private double getValueToTime(LongSparseArray<Double> array, Integer timeAsSeconds) {
Double lastValue = null; Double lastValue = null;
for (Integer index = 0; index < array.size(); index++) { for (int index = 0; index < array.size(); index++) {
long tas = array.keyAt(index); long tas = array.keyAt(index);
double value = array.valueAt(index); double value = array.valueAt(index);
if (lastValue == null) lastValue = value; if (lastValue == null) lastValue = value;
@ -459,8 +460,8 @@ public class Profile {
ic_v = convertToSparseArray(ic); ic_v = convertToSparseArray(ic);
ProfileValue[] ret = new ProfileValue[ic_v.size()]; ProfileValue[] ret = new ProfileValue[ic_v.size()];
for (Integer index = 0; index < ic_v.size(); index++) { for (int index = 0; index < ic_v.size(); index++) {
Integer tas = (int) ic_v.keyAt(index); int tas = (int) ic_v.keyAt(index);
double value = ic_v.valueAt(index); double value = ic_v.valueAt(index);
ret[index] = new ProfileValue(tas, value); ret[index] = new ProfileValue(tas, value);
} }
@ -488,7 +489,7 @@ public class Profile {
return getValuesList(basal_v, null, new DecimalFormat("0.00"), resourceHelper.gs(R.string.profile_ins_units_per_hour)); return getValuesList(basal_v, null, new DecimalFormat("0.00"), resourceHelper.gs(R.string.profile_ins_units_per_hour));
} }
public class ProfileValue { public static class ProfileValue {
public ProfileValue(int timeAsSeconds, double value) { public ProfileValue(int timeAsSeconds, double value) {
this.timeAsSeconds = timeAsSeconds; this.timeAsSeconds = timeAsSeconds;
this.value = value; this.value = value;
@ -515,8 +516,8 @@ public class Profile {
basal_v = convertToSparseArray(basal); basal_v = convertToSparseArray(basal);
ProfileValue[] ret = new ProfileValue[basal_v.size()]; ProfileValue[] ret = new ProfileValue[basal_v.size()];
for (Integer index = 0; index < basal_v.size(); index++) { for (int index = 0; index < basal_v.size(); index++) {
Integer tas = (int) basal_v.keyAt(index); int tas = (int) basal_v.keyAt(index);
double value = basal_v.valueAt(index); double value = basal_v.valueAt(index);
ret[index] = new ProfileValue(tas, value); ret[index] = new ProfileValue(tas, value);
} }
@ -566,7 +567,7 @@ public class Profile {
return toMgdl(getTargetHighTimeFromMidnight(timeAsSeconds), units); return toMgdl(getTargetHighTimeFromMidnight(timeAsSeconds), units);
} }
public class TargetValue { public static class TargetValue {
TargetValue(int timeAsSeconds, double low, double high) { TargetValue(int timeAsSeconds, double low, double high) {
this.timeAsSeconds = timeAsSeconds; this.timeAsSeconds = timeAsSeconds;
this.low = low; this.low = low;
@ -585,8 +586,8 @@ public class Profile {
targetHigh_v = convertToSparseArray(targetHigh); targetHigh_v = convertToSparseArray(targetHigh);
TargetValue[] ret = new TargetValue[targetLow_v.size()]; TargetValue[] ret = new TargetValue[targetLow_v.size()];
for (Integer index = 0; index < targetLow_v.size(); index++) { for (int index = 0; index < targetLow_v.size(); index++) {
Integer tas = (int) targetLow_v.keyAt(index); int tas = (int) targetLow_v.keyAt(index);
double low = targetLow_v.valueAt(index); double low = targetLow_v.valueAt(index);
double high = targetHigh_v.valueAt(index); double high = targetHigh_v.valueAt(index);
ret[index] = new TargetValue(tas, low, high); ret[index] = new TargetValue(tas, low, high);

View file

@ -22,7 +22,7 @@ public class MedtronicConst {
public static final int BolusDebugEnabled = R.string.key_medtronic_bolus_debug; public static final int BolusDebugEnabled = R.string.key_medtronic_bolus_debug;
} }
public class Statistics { public static class Statistics {
public static final String StatsPrefix = "medtronic_"; public static final String StatsPrefix = "medtronic_";
public static final String FirstPumpStart = Prefix + "first_pump_use"; public static final String FirstPumpStart = Prefix + "first_pump_use";

View file

@ -10,6 +10,8 @@ import androidx.viewpager.widget.ViewPager;
import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.tabs.TabLayout; import com.google.android.material.tabs.TabLayout;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -68,7 +70,7 @@ public class RileyLinkStatusActivity extends NoSplashAppCompatActivity {
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to * A {@link FragmentPagerAdapter} that returns a fragment corresponding to
* one of the sections/tabs/pages. * one of the sections/tabs/pages.
*/ */
public class SectionsPagerAdapter extends FragmentPagerAdapter { public static class SectionsPagerAdapter extends FragmentPagerAdapter {
List<Fragment> fragmentList = new ArrayList<>(); List<Fragment> fragmentList = new ArrayList<>();
List<String> fragmentTitle = new ArrayList<>(); List<String> fragmentTitle = new ArrayList<>();
@ -78,7 +80,7 @@ public class RileyLinkStatusActivity extends NoSplashAppCompatActivity {
super(fm); super(fm);
} }
@Override @NotNull @Override
public Fragment getItem(int position) { public Fragment getItem(int position) {
this.lastSelectedPosition = position; this.lastSelectedPosition = position;
return fragmentList.get(position); return fragmentList.get(position);

View file

@ -194,7 +194,7 @@ public abstract class BaseComplicationProviderService extends ComplicationProvid
IntentFilter messageFilter = new IntentFilter(Intent.ACTION_SEND); IntentFilter messageFilter = new IntentFilter(Intent.ACTION_SEND);
messageReceiver = new BaseComplicationProviderService.MessageReceiver(); messageReceiver = new MessageReceiver();
localBroadcastManager = LocalBroadcastManager.getInstance(this); localBroadcastManager = LocalBroadcastManager.getInstance(this);
localBroadcastManager.registerReceiver(messageReceiver, messageFilter); localBroadcastManager.registerReceiver(messageReceiver, messageFilter);
@ -395,7 +395,7 @@ public abstract class BaseComplicationProviderService extends ComplicationProvid
/* /*
* Listen to broadcast --> new data was stored by ListenerService to Persistence * Listen to broadcast --> new data was stored by ListenerService to Persistence
*/ */
public class MessageReceiver extends BroadcastReceiver { public static class MessageReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
Set<String> complications = Persistence.setOf(KEY_COMPLICATIONS); Set<String> complications = Persistence.setOf(KEY_COMPLICATIONS);

View file

@ -12,7 +12,7 @@ public class SharedPreferencesMock implements SharedPreferences {
private final EditorInternals editor = new EditorInternals(); private final EditorInternals editor = new EditorInternals();
class EditorInternals implements Editor { static class EditorInternals implements Editor {
Map<String, Object> innerMap = new HashMap<>(); Map<String, Object> innerMap = new HashMap<>();