Skip to content

Commit

Permalink
fix(battery): manage exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelje authored and Hector Rondon committed Jan 18, 2018
1 parent 57d8aac commit c10e644
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions inventory/src/main/java/org/flyve/inventory/categories/Battery.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import android.content.IntentFilter;
import android.os.BatteryManager;

import org.flyve.inventory.FILog;

/**
* This class get all the information of the baterry like level, voltage, temperature, status, health, technology
* The constructor of the class trigger a BroadcastReceiver with the information
Expand Down Expand Up @@ -162,17 +164,21 @@ public void onReceive(Context context, Intent intent) {
health = "Unknown";
}

if(!level.equals("0%")) {
// Load the information
Category c = new Category("BATTERIES", "batteries");
c.put("CHEMISTRY", new CategoryValue(technology, "CHEMISTRY","chemistry"));
c.put("TEMPERATURE", new CategoryValue(temperature, "TEMPERATURE","temperature"));
c.put("VOLTAGE", new CategoryValue(voltage, "VOLTAGE","voltage"));
c.put("LEVEL", new CategoryValue(level, "LEVEL","level"));
c.put("HEALTH", new CategoryValue(health, "HEALTH","health"));
c.put("STATUS", new CategoryValue(status, "STATUS","status"));
Battery.this.add(c);
}
try {
if (!level.equals("0%")) {
// Load the information
Category c = new Category("BATTERIES", "batteries");
c.put("CHEMISTRY", new CategoryValue(technology, "CHEMISTRY", "chemistry"));
c.put("TEMPERATURE", new CategoryValue(temperature, "TEMPERATURE", "temperature"));
c.put("VOLTAGE", new CategoryValue(voltage, "VOLTAGE", "voltage"));
c.put("LEVEL", new CategoryValue(level, "LEVEL", "level"));
c.put("HEALTH", new CategoryValue(health, "HEALTH", "health"));
c.put("STATUS", new CategoryValue(status, "STATUS", "status"));
Battery.this.add(c);
}
} catch (Exception ex) {
FILog.e(ex.getMessage());
}

}
}
Expand Down

0 comments on commit c10e644

Please sign in to comment.