mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-09-01 06:35:09 +00:00
Invert condition to avoid empty if block
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.kde.kdeconnect.Plugins.BatteryPlugin;
|
package org.kde.kdeconnect.Plugins.BatteryPlugin;
|
||||||
|
|
||||||
@@ -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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user