mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-28 03:25:49 +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<>();
|
||||
ArrayList<String> labels = new ArrayList<String>();
|
||||
|
||||
int balance = 0;
|
||||
long balance = 0;
|
||||
for (int counter = 0; counter < TOTAL_DAYS; counter++) {
|
||||
ActivityAmounts amounts = getActivityAmountsForDay(db, day, device);
|
||||
|
||||
@ -171,7 +171,7 @@ public abstract class AbstractWeekChartFragment extends AbstractChartFragment {
|
||||
set.setValueFormatter(getPieValueFormatter());
|
||||
}
|
||||
|
||||
return new DayData(data, formatPieValue((int) totalValue));
|
||||
return new DayData(data, formatPieValue((long) totalValue));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -321,7 +321,7 @@ public abstract class AbstractWeekChartFragment extends AbstractChartFragment {
|
||||
|
||||
abstract float[] getTotalsForActivityAmounts(ActivityAmounts activityAmounts);
|
||||
|
||||
abstract String formatPieValue(int value);
|
||||
abstract String formatPieValue(long value);
|
||||
|
||||
abstract String[] getPieLabels();
|
||||
|
||||
@ -335,9 +335,9 @@ public abstract class AbstractWeekChartFragment extends AbstractChartFragment {
|
||||
|
||||
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 final String balanceMessage;
|
||||
|
@ -60,7 +60,7 @@ public class WeekSleepChartFragment extends AbstractWeekChartFragment {
|
||||
|
||||
|
||||
@Override
|
||||
protected int calculateBalance(ActivityAmounts activityAmounts) {
|
||||
protected long calculateBalance(ActivityAmounts activityAmounts) {
|
||||
long balance = 0;
|
||||
|
||||
for (ActivityAmount amount : activityAmounts.getAmounts()) {
|
||||
@ -72,13 +72,13 @@ public class WeekSleepChartFragment extends AbstractWeekChartFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBalanceMessage(int balance, int targetValue) {
|
||||
protected String getBalanceMessage(long balance, int targetValue) {
|
||||
if (balance > 0) {
|
||||
final long totalBalance = balance - (targetValue * TOTAL_DAYS);
|
||||
if (totalBalance > 0)
|
||||
return getString(R.string.overslept, getHM((int) totalBalance));
|
||||
return getString(R.string.overslept, getHM(totalBalance));
|
||||
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
|
||||
return getString(R.string.no_data);
|
||||
}
|
||||
@ -100,8 +100,8 @@ public class WeekSleepChartFragment extends AbstractWeekChartFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String formatPieValue(int value) {
|
||||
return DateTimeUtils.formatDurationHoursMinutes((long) value, TimeUnit.MINUTES);
|
||||
protected String formatPieValue(long value) {
|
||||
return DateTimeUtils.formatDurationHoursMinutes(value, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -114,7 +114,7 @@ public class WeekSleepChartFragment extends AbstractWeekChartFragment {
|
||||
return new IValueFormatter() {
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
private String getHM(int value) {
|
||||
private String getHM(long value) {
|
||||
return DateTimeUtils.formatDurationHoursMinutes(value, TimeUnit.MINUTES);
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class WeekStepsChartFragment extends AbstractWeekChartFragment {
|
||||
|
||||
@Override
|
||||
float[] getTotalsForActivityAmounts(ActivityAmounts activityAmounts) {
|
||||
int totalSteps = 0;
|
||||
long totalSteps = 0;
|
||||
for (ActivityAmount amount : activityAmounts.getAmounts()) {
|
||||
totalSteps += amount.getTotalSteps();
|
||||
}
|
||||
@ -58,8 +58,8 @@ public class WeekStepsChartFragment extends AbstractWeekChartFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int calculateBalance(ActivityAmounts activityAmounts) {
|
||||
int balance = 0;
|
||||
protected long calculateBalance(ActivityAmounts activityAmounts) {
|
||||
long balance = 0;
|
||||
for (ActivityAmount amount : activityAmounts.getAmounts()) {
|
||||
balance += amount.getTotalSteps();
|
||||
}
|
||||
@ -67,7 +67,7 @@ public class WeekStepsChartFragment extends AbstractWeekChartFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String formatPieValue(int value) {
|
||||
protected String formatPieValue(long value) {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@ -103,13 +103,13 @@ public class WeekStepsChartFragment extends AbstractWeekChartFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBalanceMessage(int balance, int targetValue) {
|
||||
protected String getBalanceMessage(long balance, int targetValue) {
|
||||
if (balance > 0) {
|
||||
final long totalBalance = balance - (targetValue * TOTAL_DAYS);
|
||||
if (totalBalance > 0)
|
||||
return getString(R.string.overstep, (int) Math.abs(totalBalance));
|
||||
return getString(R.string.overstep, Math.abs(totalBalance));
|
||||
else
|
||||
return getString(R.string.lack_of_step, (int) Math.abs(totalBalance));
|
||||
return getString(R.string.lack_of_step, Math.abs(totalBalance));
|
||||
} else
|
||||
return getString(R.string.no_data);
|
||||
}
|
||||
|
@ -1,19 +1,19 @@
|
||||
/* Copyright (C) 2018 Andreas Shimokawa, ladbsoft
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
Gadgetbridge is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Gadgetbridge is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* Copyright (C) 2018 Andreas Shimokawa, ladbsoft
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
Gadgetbridge is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Gadgetbridge is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.xwatch;
|
||||
|
||||
import android.bluetooth.BluetoothGatt;
|
||||
@ -548,9 +548,9 @@ public class XWatchSupport extends AbstractBTLEDeviceSupport {
|
||||
int yearInt, monthInt, dayInt, hoursMinutesInt = 0;
|
||||
int hours, minutes = 0;
|
||||
|
||||
yearInt = Integer.valueOf(String.format("%02x", year, 16));
|
||||
monthInt = Integer.valueOf(String.format("%02x", month, 16));
|
||||
dayInt = Integer.valueOf(String.format("%02x", day, 16));
|
||||
yearInt = Integer.valueOf(String.format("%02x", year), 16);
|
||||
monthInt = Integer.valueOf(String.format("%02x", month), 16);
|
||||
dayInt = Integer.valueOf(String.format("%02x", day), 16);
|
||||
hoursMinutesInt = Integer.valueOf(String.format("%02x", hoursminutes), 16);
|
||||
|
||||
minutes = hoursMinutesInt % 4;
|
||||
|
@ -200,14 +200,12 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
music[5] = musicState;
|
||||
System.arraycopy(songtitle.getBytes(StandardCharsets.UTF_8), 0, music, 6, songtitle.getBytes(StandardCharsets.UTF_8).length);
|
||||
music[music.length - 1] = ZeTimeConstants.CMD_END;
|
||||
if (music != null) {
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("setMusicStateInfo");
|
||||
replyMsgToWatch(builder, music);
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
GB.toast(getContext(), "Error setting music state and info: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||
}
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("setMusicStateInfo");
|
||||
replyMsgToWatch(builder, music);
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
GB.toast(getContext(), "Error setting music state and info: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -345,14 +343,12 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
System.arraycopy(songtitle.getBytes(StandardCharsets.UTF_8), 0, music, 6, songtitle.getBytes(StandardCharsets.UTF_8).length);
|
||||
music[music.length - 1] = ZeTimeConstants.CMD_END;
|
||||
if (music != null) {
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("setMusicStateInfo");
|
||||
replyMsgToWatch(builder, music);
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
GB.toast(getContext(), "Error setting music state and info: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||
}
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("setMusicStateInfo");
|
||||
replyMsgToWatch(builder, music);
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
GB.toast(getContext(), "Error setting music state and info: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -379,15 +375,12 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
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);
|
||||
CalendarEvent[CalendarEvent.length-1] = ZeTimeConstants.CMD_END;
|
||||
if(CalendarEvent != null)
|
||||
{
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("sendCalendarEvenr");
|
||||
sendMsgToWatch(builder, CalendarEvent);
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
GB.toast(getContext(), "Error sending calendar event: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||
}
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("sendCalendarEvenr");
|
||||
sendMsgToWatch(builder, CalendarEvent);
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
GB.toast(getContext(), "Error sending calendar event: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@ -449,15 +442,12 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
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;
|
||||
if(weather != null)
|
||||
{
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("sendWeahter");
|
||||
sendMsgToWatch(builder, weather);
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
GB.toast(getContext(), "Error sending weather: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||
}
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("sendWeahter");
|
||||
sendMsgToWatch(builder, weather);
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
GB.toast(getContext(), "Error sending weather: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@ -620,8 +610,6 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
notification[5] = ZeTimeConstants.NOTIFICATION_SOCIAL;
|
||||
break;
|
||||
}
|
||||
if(notification != null)
|
||||
{
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("sendNotification");
|
||||
sendMsgToWatch(builder, notification);
|
||||
@ -629,7 +617,6 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
} catch (IOException e) {
|
||||
GB.toast(getContext(), "Error sending notification: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user