mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-16 12:47:32 +01:00
Fix some static analysis warnings
This commit is contained in:
parent
08dfa2a47d
commit
5028458fe8
@ -108,7 +108,7 @@ public abstract class AbstractWeekChartFragment extends AbstractChartFragment {
|
|||||||
List<BarEntry> entries = new ArrayList<>();
|
List<BarEntry> entries = new ArrayList<>();
|
||||||
ArrayList<String> labels = new ArrayList<String>();
|
ArrayList<String> labels = new ArrayList<String>();
|
||||||
|
|
||||||
int balance = 0;
|
long balance = 0;
|
||||||
for (int counter = 0; counter < TOTAL_DAYS; counter++) {
|
for (int counter = 0; counter < TOTAL_DAYS; counter++) {
|
||||||
ActivityAmounts amounts = getActivityAmountsForDay(db, day, device);
|
ActivityAmounts amounts = getActivityAmountsForDay(db, day, device);
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ public abstract class AbstractWeekChartFragment extends AbstractChartFragment {
|
|||||||
set.setValueFormatter(getPieValueFormatter());
|
set.setValueFormatter(getPieValueFormatter());
|
||||||
}
|
}
|
||||||
|
|
||||||
return new DayData(data, formatPieValue((int) totalValue));
|
return new DayData(data, formatPieValue((long) totalValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -321,7 +321,7 @@ public abstract class AbstractWeekChartFragment extends AbstractChartFragment {
|
|||||||
|
|
||||||
abstract float[] getTotalsForActivityAmounts(ActivityAmounts activityAmounts);
|
abstract float[] getTotalsForActivityAmounts(ActivityAmounts activityAmounts);
|
||||||
|
|
||||||
abstract String formatPieValue(int value);
|
abstract String formatPieValue(long value);
|
||||||
|
|
||||||
abstract String[] getPieLabels();
|
abstract String[] getPieLabels();
|
||||||
|
|
||||||
@ -335,9 +335,9 @@ public abstract class AbstractWeekChartFragment extends AbstractChartFragment {
|
|||||||
|
|
||||||
abstract String getPieDescription(int targetValue);
|
abstract String getPieDescription(int targetValue);
|
||||||
|
|
||||||
protected abstract int calculateBalance(ActivityAmounts amounts);
|
protected abstract long calculateBalance(ActivityAmounts amounts);
|
||||||
|
|
||||||
protected abstract String getBalanceMessage(int balance, int targetValue);
|
protected abstract String getBalanceMessage(long balance, int targetValue);
|
||||||
|
|
||||||
private class WeekChartsData<T extends ChartData<?>> extends DefaultChartsData<T> {
|
private class WeekChartsData<T extends ChartData<?>> extends DefaultChartsData<T> {
|
||||||
private final String balanceMessage;
|
private final String balanceMessage;
|
||||||
|
@ -60,7 +60,7 @@ public class WeekSleepChartFragment extends AbstractWeekChartFragment {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int calculateBalance(ActivityAmounts activityAmounts) {
|
protected long calculateBalance(ActivityAmounts activityAmounts) {
|
||||||
long balance = 0;
|
long balance = 0;
|
||||||
|
|
||||||
for (ActivityAmount amount : activityAmounts.getAmounts()) {
|
for (ActivityAmount amount : activityAmounts.getAmounts()) {
|
||||||
@ -72,13 +72,13 @@ public class WeekSleepChartFragment extends AbstractWeekChartFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getBalanceMessage(int balance, int targetValue) {
|
protected String getBalanceMessage(long balance, int targetValue) {
|
||||||
if (balance > 0) {
|
if (balance > 0) {
|
||||||
final long totalBalance = balance - (targetValue * TOTAL_DAYS);
|
final long totalBalance = balance - (targetValue * TOTAL_DAYS);
|
||||||
if (totalBalance > 0)
|
if (totalBalance > 0)
|
||||||
return getString(R.string.overslept, getHM((int) totalBalance));
|
return getString(R.string.overslept, getHM(totalBalance));
|
||||||
else
|
else
|
||||||
return getString(R.string.lack_of_sleep, getHM((int) Math.abs(totalBalance)));
|
return getString(R.string.lack_of_sleep, getHM(Math.abs(totalBalance)));
|
||||||
} else
|
} else
|
||||||
return getString(R.string.no_data);
|
return getString(R.string.no_data);
|
||||||
}
|
}
|
||||||
@ -100,8 +100,8 @@ public class WeekSleepChartFragment extends AbstractWeekChartFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String formatPieValue(int value) {
|
protected String formatPieValue(long value) {
|
||||||
return DateTimeUtils.formatDurationHoursMinutes((long) value, TimeUnit.MINUTES);
|
return DateTimeUtils.formatDurationHoursMinutes(value, TimeUnit.MINUTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -114,7 +114,7 @@ public class WeekSleepChartFragment extends AbstractWeekChartFragment {
|
|||||||
return new IValueFormatter() {
|
return new IValueFormatter() {
|
||||||
@Override
|
@Override
|
||||||
public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
|
public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
|
||||||
return formatPieValue((int) value);
|
return formatPieValue((long) value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -164,7 +164,7 @@ public class WeekSleepChartFragment extends AbstractWeekChartFragment {
|
|||||||
chart.getLegend().setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
|
chart.getLegend().setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getHM(int value) {
|
private String getHM(long value) {
|
||||||
return DateTimeUtils.formatDurationHoursMinutes(value, TimeUnit.MINUTES);
|
return DateTimeUtils.formatDurationHoursMinutes(value, TimeUnit.MINUTES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ public class WeekStepsChartFragment extends AbstractWeekChartFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
float[] getTotalsForActivityAmounts(ActivityAmounts activityAmounts) {
|
float[] getTotalsForActivityAmounts(ActivityAmounts activityAmounts) {
|
||||||
int totalSteps = 0;
|
long totalSteps = 0;
|
||||||
for (ActivityAmount amount : activityAmounts.getAmounts()) {
|
for (ActivityAmount amount : activityAmounts.getAmounts()) {
|
||||||
totalSteps += amount.getTotalSteps();
|
totalSteps += amount.getTotalSteps();
|
||||||
}
|
}
|
||||||
@ -58,8 +58,8 @@ public class WeekStepsChartFragment extends AbstractWeekChartFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int calculateBalance(ActivityAmounts activityAmounts) {
|
protected long calculateBalance(ActivityAmounts activityAmounts) {
|
||||||
int balance = 0;
|
long balance = 0;
|
||||||
for (ActivityAmount amount : activityAmounts.getAmounts()) {
|
for (ActivityAmount amount : activityAmounts.getAmounts()) {
|
||||||
balance += amount.getTotalSteps();
|
balance += amount.getTotalSteps();
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ public class WeekStepsChartFragment extends AbstractWeekChartFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String formatPieValue(int value) {
|
protected String formatPieValue(long value) {
|
||||||
return String.valueOf(value);
|
return String.valueOf(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,13 +103,13 @@ public class WeekStepsChartFragment extends AbstractWeekChartFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getBalanceMessage(int balance, int targetValue) {
|
protected String getBalanceMessage(long balance, int targetValue) {
|
||||||
if (balance > 0) {
|
if (balance > 0) {
|
||||||
final long totalBalance = balance - (targetValue * TOTAL_DAYS);
|
final long totalBalance = balance - (targetValue * TOTAL_DAYS);
|
||||||
if (totalBalance > 0)
|
if (totalBalance > 0)
|
||||||
return getString(R.string.overstep, (int) Math.abs(totalBalance));
|
return getString(R.string.overstep, Math.abs(totalBalance));
|
||||||
else
|
else
|
||||||
return getString(R.string.lack_of_step, (int) Math.abs(totalBalance));
|
return getString(R.string.lack_of_step, Math.abs(totalBalance));
|
||||||
} else
|
} else
|
||||||
return getString(R.string.no_data);
|
return getString(R.string.no_data);
|
||||||
}
|
}
|
||||||
|
@ -548,9 +548,9 @@ public class XWatchSupport extends AbstractBTLEDeviceSupport {
|
|||||||
int yearInt, monthInt, dayInt, hoursMinutesInt = 0;
|
int yearInt, monthInt, dayInt, hoursMinutesInt = 0;
|
||||||
int hours, minutes = 0;
|
int hours, minutes = 0;
|
||||||
|
|
||||||
yearInt = Integer.valueOf(String.format("%02x", year, 16));
|
yearInt = Integer.valueOf(String.format("%02x", year), 16);
|
||||||
monthInt = Integer.valueOf(String.format("%02x", month, 16));
|
monthInt = Integer.valueOf(String.format("%02x", month), 16);
|
||||||
dayInt = Integer.valueOf(String.format("%02x", day, 16));
|
dayInt = Integer.valueOf(String.format("%02x", day), 16);
|
||||||
hoursMinutesInt = Integer.valueOf(String.format("%02x", hoursminutes), 16);
|
hoursMinutesInt = Integer.valueOf(String.format("%02x", hoursminutes), 16);
|
||||||
|
|
||||||
minutes = hoursMinutesInt % 4;
|
minutes = hoursMinutesInt % 4;
|
||||||
|
@ -200,7 +200,6 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
music[5] = musicState;
|
music[5] = musicState;
|
||||||
System.arraycopy(songtitle.getBytes(StandardCharsets.UTF_8), 0, music, 6, songtitle.getBytes(StandardCharsets.UTF_8).length);
|
System.arraycopy(songtitle.getBytes(StandardCharsets.UTF_8), 0, music, 6, songtitle.getBytes(StandardCharsets.UTF_8).length);
|
||||||
music[music.length - 1] = ZeTimeConstants.CMD_END;
|
music[music.length - 1] = ZeTimeConstants.CMD_END;
|
||||||
if (music != null) {
|
|
||||||
try {
|
try {
|
||||||
TransactionBuilder builder = performInitialized("setMusicStateInfo");
|
TransactionBuilder builder = performInitialized("setMusicStateInfo");
|
||||||
replyMsgToWatch(builder, music);
|
replyMsgToWatch(builder, music);
|
||||||
@ -210,7 +209,6 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSetCallState(CallSpec callSpec) {
|
public void onSetCallState(CallSpec callSpec) {
|
||||||
@ -345,7 +343,6 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
}
|
}
|
||||||
System.arraycopy(songtitle.getBytes(StandardCharsets.UTF_8), 0, music, 6, songtitle.getBytes(StandardCharsets.UTF_8).length);
|
System.arraycopy(songtitle.getBytes(StandardCharsets.UTF_8), 0, music, 6, songtitle.getBytes(StandardCharsets.UTF_8).length);
|
||||||
music[music.length - 1] = ZeTimeConstants.CMD_END;
|
music[music.length - 1] = ZeTimeConstants.CMD_END;
|
||||||
if (music != null) {
|
|
||||||
try {
|
try {
|
||||||
TransactionBuilder builder = performInitialized("setMusicStateInfo");
|
TransactionBuilder builder = performInitialized("setMusicStateInfo");
|
||||||
replyMsgToWatch(builder, music);
|
replyMsgToWatch(builder, music);
|
||||||
@ -355,7 +352,6 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAddCalendarEvent(CalendarEventSpec calendarEventSpec) {
|
public void onAddCalendarEvent(CalendarEventSpec calendarEventSpec) {
|
||||||
@ -379,8 +375,6 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
CalendarEvent[14] = (byte) calendarEventSpec.title.getBytes(StandardCharsets.UTF_8).length;
|
CalendarEvent[14] = (byte) calendarEventSpec.title.getBytes(StandardCharsets.UTF_8).length;
|
||||||
System.arraycopy(calendarEventSpec.title.getBytes(StandardCharsets.UTF_8), 0, CalendarEvent, 15, calendarEventSpec.title.getBytes(StandardCharsets.UTF_8).length);
|
System.arraycopy(calendarEventSpec.title.getBytes(StandardCharsets.UTF_8), 0, CalendarEvent, 15, calendarEventSpec.title.getBytes(StandardCharsets.UTF_8).length);
|
||||||
CalendarEvent[CalendarEvent.length-1] = ZeTimeConstants.CMD_END;
|
CalendarEvent[CalendarEvent.length-1] = ZeTimeConstants.CMD_END;
|
||||||
if(CalendarEvent != null)
|
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
TransactionBuilder builder = performInitialized("sendCalendarEvenr");
|
TransactionBuilder builder = performInitialized("sendCalendarEvenr");
|
||||||
sendMsgToWatch(builder, CalendarEvent);
|
sendMsgToWatch(builder, CalendarEvent);
|
||||||
@ -389,7 +383,6 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
GB.toast(getContext(), "Error sending calendar event: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
GB.toast(getContext(), "Error sending calendar event: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSetTime() {
|
public void onSetTime() {
|
||||||
@ -449,8 +442,6 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
}
|
}
|
||||||
System.arraycopy(weatherSpec.location.getBytes(StandardCharsets.UTF_8), 0, weather, 25, weatherSpec.location.getBytes(StandardCharsets.UTF_8).length);
|
System.arraycopy(weatherSpec.location.getBytes(StandardCharsets.UTF_8), 0, weather, 25, weatherSpec.location.getBytes(StandardCharsets.UTF_8).length);
|
||||||
weather[weather.length-1] = ZeTimeConstants.CMD_END;
|
weather[weather.length-1] = ZeTimeConstants.CMD_END;
|
||||||
if(weather != null)
|
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
TransactionBuilder builder = performInitialized("sendWeahter");
|
TransactionBuilder builder = performInitialized("sendWeahter");
|
||||||
sendMsgToWatch(builder, weather);
|
sendMsgToWatch(builder, weather);
|
||||||
@ -459,7 +450,6 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
GB.toast(getContext(), "Error sending weather: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
GB.toast(getContext(), "Error sending weather: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAppReorder(UUID[] uuids) {
|
public void onAppReorder(UUID[] uuids) {
|
||||||
@ -620,8 +610,6 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
notification[5] = ZeTimeConstants.NOTIFICATION_SOCIAL;
|
notification[5] = ZeTimeConstants.NOTIFICATION_SOCIAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(notification != null)
|
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
TransactionBuilder builder = performInitialized("sendNotification");
|
TransactionBuilder builder = performInitialized("sendNotification");
|
||||||
sendMsgToWatch(builder, notification);
|
sendMsgToWatch(builder, notification);
|
||||||
@ -630,7 +618,6 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
GB.toast(getContext(), "Error sending notification: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
GB.toast(getContext(), "Error sending notification: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCharacteristicChanged(BluetoothGatt gatt,
|
public boolean onCharacteristicChanged(BluetoothGatt gatt,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user