2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-09-01 22:55:10 +00:00

Invert condition to avoid empty if block

This commit is contained in:
Nicolas Fella
2018-09-29 21:12:11 +02:00
parent b97ad28456
commit 49df6ddba6

View File

@@ -65,22 +65,17 @@ public class BatteryPlugin extends Plugin {
boolean lowBattery = Intent.ACTION_BATTERY_LOW.equals(batteryIntent.getAction()); boolean lowBattery = Intent.ACTION_BATTERY_LOW.equals(batteryIntent.getAction());
int thresholdEvent = lowBattery ? THRESHOLD_EVENT_BATTERY_LOW : THRESHOLD_EVENT_NONE; int thresholdEvent = lowBattery ? THRESHOLD_EVENT_BATTERY_LOW : THRESHOLD_EVENT_NONE;
if (isCharging == batteryInfo.getBoolean("isCharging") if (isCharging != batteryInfo.getBoolean("isCharging")
&& currentCharge == batteryInfo.getInt("currentCharge") || currentCharge != batteryInfo.getInt("currentCharge")
&& thresholdEvent == batteryInfo.getInt("thresholdEvent") || thresholdEvent != batteryInfo.getInt("thresholdEvent")
) { ) {
//Do not send again if nothing has changed
} else {
batteryInfo.set("currentCharge", currentCharge); batteryInfo.set("currentCharge", currentCharge);
batteryInfo.set("isCharging", isCharging); batteryInfo.set("isCharging", isCharging);
batteryInfo.set("thresholdEvent", thresholdEvent); batteryInfo.set("thresholdEvent", thresholdEvent);
device.sendPacket(batteryInfo); device.sendPacket(batteryInfo);
} }
} }
}; };