Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
6635e0cc39
4 changed files with 8 additions and 7 deletions
|
@ -33,7 +33,6 @@ public class OsMoControlDevice implements OsMoReactor {
|
|||
this.plugin = plugin;
|
||||
this.service = service;
|
||||
this.tracker = tracker;
|
||||
service.registerReactor(this);
|
||||
}
|
||||
|
||||
public JSONObject getBatteryLevel() throws JSONException {
|
||||
|
|
|
@ -26,6 +26,7 @@ import android.text.TextUtils;
|
|||
public class OsMoGroups implements OsMoReactor, OsmoTrackerListener {
|
||||
|
||||
private static final String GROUP_NAME = "name";
|
||||
private static final String ACTIVE = "active";
|
||||
private static final String GROUP_ID = "group_id";
|
||||
private static final String EXPIRE_TIME = "expireTime";
|
||||
private static final String DESCRIPTION = "description";
|
||||
|
@ -250,14 +251,14 @@ public class OsMoGroups implements OsMoReactor, OsmoTrackerListener {
|
|||
JSONArray arr = new JSONArray(data);
|
||||
int arrLength = arr.length();
|
||||
if (arrLength > 0) {
|
||||
Map<String, OsMoGroup> resivedGroups = new HashMap<String, OsMoGroupsStorage.OsMoGroup>();
|
||||
Map<String, OsMoGroup> receivedGroups = new HashMap<String, OsMoGroupsStorage.OsMoGroup>();
|
||||
for (int i = 0; i < arrLength; i++) {
|
||||
JSONObject o = arr.getJSONObject(i);
|
||||
OsMoGroup parsedGroup = parseGroup(o);
|
||||
resivedGroups.put(parsedGroup.getGroupId(), parsedGroup);
|
||||
receivedGroups.put(parsedGroup.getGroupId(), parsedGroup);
|
||||
}
|
||||
|
||||
storage.mergeGroups(resivedGroups);
|
||||
storage.mergeGroups(receivedGroups);
|
||||
storage.save();
|
||||
}
|
||||
processed = true;
|
||||
|
@ -360,7 +361,8 @@ public class OsMoGroups implements OsMoReactor, OsmoTrackerListener {
|
|||
|
||||
private OsMoGroup parseGroup(JSONObject obj) throws JSONException {
|
||||
OsMoGroup groupe = new OsMoGroup();
|
||||
groupe.enabled = true;
|
||||
groupe.enabled = !(obj.has(ACTIVE) && ("0".equals(obj.getString(ACTIVE)) ||
|
||||
"false".equals(obj.getString(ACTIVE))));
|
||||
groupe.name = obj.optString(GROUP_NAME);
|
||||
groupe.groupId = obj.getString(GROUP_ID);
|
||||
groupe.description = obj.optString(DESCRIPTION);
|
||||
|
|
|
@ -73,7 +73,6 @@ public class OsMoGroupsStorage {
|
|||
public void load() {
|
||||
String grp = pref.get();
|
||||
try {
|
||||
System.out.println("DEBUG : OsMo groups load info " + grp);
|
||||
JSONObject obj = new JSONObject(grp);
|
||||
parseGroupUsers(mainGroup, obj);
|
||||
if(!obj.has(GROUPS)) {
|
||||
|
|
|
@ -62,6 +62,7 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
|
|||
private OsMoPositionLayer olayer;
|
||||
protected MapActivity mapActivity;
|
||||
protected OsMoGroupsActivity groupsActivity;
|
||||
protected OsMoControlDevice deviceControl;
|
||||
|
||||
private final static Log log = PlatformUtil.getLog(OsMoPlugin.class);
|
||||
|
||||
|
@ -71,7 +72,7 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
|
|||
service = new OsMoService(app, this);
|
||||
tracker = new OsMoTracker(service, app.getSettings().OSMO_SAVE_TRACK_INTERVAL,
|
||||
app.getSettings().OSMO_AUTO_SEND_LOCATIONS);
|
||||
new OsMoControlDevice(app, this, service, tracker);
|
||||
deviceControl = new OsMoControlDevice(app, this, service, tracker);
|
||||
groups = new OsMoGroups(this, service, tracker, app);
|
||||
ApplicationMode.regWidget("osmo_control", (ApplicationMode[])null);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue