1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2025-01-15 04:07:32 +01:00

Remove redundant null checks

This commit is contained in:
cpfeiffer 2018-09-16 13:58:01 +02:00
parent 100ed9f50c
commit c1de677448

View File

@ -636,7 +636,6 @@ public class PebbleProtocol extends GBDeviceProtocol {
byte attributes_count = 0;
int length = 21 + 10 + actions_length;
if (parts != null) {
for (String s : parts) {
if (s == null || s.equals("")) {
continue;
@ -644,7 +643,6 @@ public class PebbleProtocol extends GBDeviceProtocol {
attributes_count++;
length += (3 + s.getBytes().length);
}
}
// Encode Prefix
ByteBuffer buf = ByteBuffer.allocate(length + LENGTH_PREFIX);
@ -667,7 +665,6 @@ public class PebbleProtocol extends GBDeviceProtocol {
byte attribute_id = 0;
// Encode Pascal-Style Strings
if (parts != null) {
for (String s : parts) {
attribute_id++;
if (s == null || s.equals("")) {
@ -680,7 +677,6 @@ public class PebbleProtocol extends GBDeviceProtocol {
buf.putShort((short) partlength);
buf.put(s.getBytes(), 0, partlength);
}
}
// dismiss action
@ -981,7 +977,6 @@ public class PebbleProtocol extends GBDeviceProtocol {
byte attributes_count = 2; // icon
short attributes_length = (short) (11 + actions_length);
if (parts != null) {
for (String s : parts) {
if (s == null || s.equals("")) {
continue;
@ -989,7 +984,6 @@ public class PebbleProtocol extends GBDeviceProtocol {
attributes_count++;
attributes_length += (3 + s.getBytes().length);
}
}
short pin_length = (short) (NOTIFICATION_PIN_LENGTH + attributes_length);
@ -1013,7 +1007,6 @@ public class PebbleProtocol extends GBDeviceProtocol {
byte attribute_id = 0;
// Encode Pascal-Style Strings
if (parts != null) {
for (String s : parts) {
attribute_id++;
if (s == null || s.equals("")) {
@ -1026,7 +1019,6 @@ public class PebbleProtocol extends GBDeviceProtocol {
buf.putShort((short) partlength);
buf.put(s.getBytes(), 0, partlength);
}
}
buf.put((byte) 4); // icon
buf.putShort((short) 4); // length of int
@ -1116,7 +1108,6 @@ public class PebbleProtocol extends GBDeviceProtocol {
byte attributes_count = 3;
short attributes_length = (short) (21 + actions_length);
if (parts != null) {
for (String s : parts) {
if (s == null || s.equals("")) {
continue;
@ -1124,7 +1115,6 @@ public class PebbleProtocol extends GBDeviceProtocol {
attributes_count++;
attributes_length += (3 + s.getBytes().length);
}
}
UUID uuid = UUID.fromString("61b22bc8-1e29-460d-a236-3fe409a43901");
@ -1150,7 +1140,6 @@ public class PebbleProtocol extends GBDeviceProtocol {
byte attribute_id = 0;
// Encode Pascal-Style Strings
if (parts != null) {
for (String s : parts) {
attribute_id++;
if (s == null || s.equals("")) {
@ -1171,7 +1160,6 @@ public class PebbleProtocol extends GBDeviceProtocol {
buf.putShort((short) partlength);
buf.put(s.getBytes(), 0, partlength);
}
}
buf.put((byte) 4); // icon
buf.putShort((short) 4); // length of int
@ -1254,14 +1242,12 @@ public class PebbleProtocol extends GBDeviceProtocol {
// Calculate length first
short attributes_length = 0;
if (parts != null) {
for (String s : parts) {
if (s == null || s.equals("")) {
continue;
}
attributes_length += (2 + s.getBytes().length);
}
}
short pin_length = (short) (WEATHER_FORECAST_LENGTH + attributes_length);
@ -1280,7 +1266,6 @@ public class PebbleProtocol extends GBDeviceProtocol {
buf.putShort(attributes_length);
// Encode Pascal-Style Strings
if (parts != null) {
for (String s : parts) {
if (s == null || s.equals("")) {
continue;
@ -1291,7 +1276,6 @@ public class PebbleProtocol extends GBDeviceProtocol {
buf.putShort((short) partlength);
buf.put(s.getBytes(), 0, partlength);
}
}
return encodeBlobdb(UUID_LOCATION, BLOBDB_INSERT, BLOBDB_WEATHER, buf.array());
}
@ -1434,7 +1418,6 @@ public class PebbleProtocol extends GBDeviceProtocol {
} else {
// Calculate length first
int length = LENGTH_PREFIX + 9;
if (parts != null) {
for (String s : parts) {
if (s == null || s.equals("")) {
length++; // encode null or empty strings as 0x00 later
@ -1442,7 +1425,6 @@ public class PebbleProtocol extends GBDeviceProtocol {
}
length += (1 + s.getBytes().length);
}
}
// Encode Prefix
ByteBuffer buf = ByteBuffer.allocate(length);