Fix issue not remember state of group (small issue on server left)

This commit is contained in:
Victor Shcherb 2014-11-23 17:05:58 +01:00
parent 9963f41ccc
commit c6d6897a88
2 changed files with 6 additions and 5 deletions

View file

@ -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);

View file

@ -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)) {