Temporary restoration of reading tag data members as JSON in EditPeopleControlSet

pull/14/head
Sam Bosley 12 years ago
parent 16abc83b12
commit b1d32f61b4

@ -65,6 +65,7 @@ import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.service.TagDataService; import com.todoroo.astrid.service.TagDataService;
import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.service.abtesting.ABChooser; import com.todoroo.astrid.service.abtesting.ABChooser;
import com.todoroo.astrid.tags.TagService;
import com.todoroo.astrid.ui.PeopleContainer; import com.todoroo.astrid.ui.PeopleContainer;
import com.todoroo.astrid.ui.PeopleContainer.ParseSharedException; import com.todoroo.astrid.ui.PeopleContainer.ParseSharedException;
import com.todoroo.astrid.ui.PopupControlSet; import com.todoroo.astrid.ui.PopupControlSet;
@ -180,35 +181,35 @@ public class EditPeopleControlSet extends PopupControlSet {
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
// ArrayList<JSONObject> collaborators = new ArrayList<JSONObject>(); ArrayList<JSONObject> sharedPeople = new ArrayList<JSONObject>();
// TodorooCursor<TagData> tags = TagService.getInstance().getTagDataForTask(task.getId(), true, TagData.NAME, TagData.MEMBER_COUNT, TagData.MEMBERS, TagData.USER); TodorooCursor<TagData> tags = TagService.getInstance().getTagDataForTask(task.getId(), true, TagData.NAME, TagData.MEMBER_COUNT, TagData.MEMBERS, TagData.USER);
try { try {
// TagData tagData = new TagData(); TagData tagData = new TagData();
// for(tags.moveToFirst(); !tags.isAfterLast(); tags.moveToNext()) { for(tags.moveToFirst(); !tags.isAfterLast(); tags.moveToNext()) {
// tagData.readFromCursor(tags); tagData.readFromCursor(tags);
// final String tag = tagData.getValue(TagData.NAME); final String tag = tagData.getValue(TagData.NAME);
// if(tagData.getValue(TagData.MEMBER_COUNT) > 0) { if(tagData.getValue(TagData.MEMBER_COUNT) > 0) {
// try { try {
// addMembersFromTagData(tagData, tag, sharedPeople, collaborators); addMembersFromTagData(tagData, tag, sharedPeople);
// } catch (JSONException e) { } catch (JSONException e) {
// exceptionService.reportError("json-reading-data", e); exceptionService.reportError("json-reading-data", e);
// } }
// } }
// } }
//
// if (includeTag != null && tags.getCount() == 0) { if (includeTag != null && tags.getCount() == 0) {
// try { try {
// addMembersFromTagData(includeTag, null, sharedPeople, collaborators); addMembersFromTagData(includeTag, null, sharedPeople);
// } catch (JSONException e) { } catch (JSONException e) {
// exceptionService.reportError("json-reading-data", e); exceptionService.reportError("json-reading-data", e);
// } }
// } }
// if(collaborators.size() > 0) // if(collaborators.size() > 0)
// buildCollaborators(collaborators); // buildCollaborators(collaborators);
buildAssignedToSpinner(task); buildAssignedToSpinner(task, sharedPeople);
} finally { } finally {
// tags.close(); tags.close();
loadedUI = true; loadedUI = true;
} }
} }
@ -216,7 +217,7 @@ public class EditPeopleControlSet extends PopupControlSet {
} }
@SuppressWarnings("nls") @SuppressWarnings("nls")
private static void addMembersFromTagData(TagData tagData, String tag, ArrayList<JSONObject> sharedPeople, ArrayList<JSONObject> collaborators) throws JSONException { private static void addMembersFromTagData(TagData tagData, String tag, ArrayList<JSONObject> sharedPeople) throws JSONException {
JSONArray members = new JSONArray(tagData.getValue(TagData.MEMBERS)); JSONArray members = new JSONArray(tagData.getValue(TagData.MEMBERS));
if (tag == null) if (tag == null)
tag = tagData.getValue(TagData.NAME); tag = tagData.getValue(TagData.NAME);
@ -224,17 +225,15 @@ public class EditPeopleControlSet extends PopupControlSet {
JSONObject user = members.getJSONObject(i); JSONObject user = members.getJSONObject(i);
user.put("tag", tag); user.put("tag", tag);
sharedPeople.add(user); sharedPeople.add(user);
collaborators.add(user);
} }
if(!TextUtils.isEmpty(tagData.getValue(TagData.USER))) { if(!TextUtils.isEmpty(tagData.getValue(TagData.USER))) {
JSONObject user = new JSONObject(tagData.getValue(TagData.USER)); JSONObject user = new JSONObject(tagData.getValue(TagData.USER));
user.put("tag", tag); user.put("tag", tag);
sharedPeople.add(user); sharedPeople.add(user);
collaborators.add(user);
} }
} }
@SuppressWarnings("nls") // @SuppressWarnings("nls")
// private void buildCollaborators(final ArrayList<JSONObject> sharedPeople) { // private void buildCollaborators(final ArrayList<JSONObject> sharedPeople) {
// //
// activity.runOnUiThread(new Runnable() { // activity.runOnUiThread(new Runnable() {
@ -284,7 +283,7 @@ public class EditPeopleControlSet extends PopupControlSet {
} }
@SuppressWarnings("nls") @SuppressWarnings("nls")
private void buildAssignedToSpinner(Task t) { private void buildAssignedToSpinner(Task t, ArrayList<JSONObject> sharedWith) {
HashSet<String> userIds = new HashSet<String>(); HashSet<String> userIds = new HashSet<String>();
HashSet<String> emails = new HashSet<String>(); HashSet<String> emails = new HashSet<String>();
HashMap<String, AssignedToUser> names = new HashMap<String, AssignedToUser>(); HashMap<String, AssignedToUser> names = new HashMap<String, AssignedToUser>();
@ -320,6 +319,7 @@ public class EditPeopleControlSet extends PopupControlSet {
// de-duplicate by user id and/or email // de-duplicate by user id and/or email
coreUsers = convertJsonUsersToAssignedUsers(coreUsersJson, userIds, emails, names); coreUsers = convertJsonUsersToAssignedUsers(coreUsersJson, userIds, emails, names);
listUsers = convertJsonUsersToAssignedUsers(sharedWith, userIds, emails, names);
astridUsers = convertJsonUsersToAssignedUsers(astridFriends, userIds, emails, names); astridUsers = convertJsonUsersToAssignedUsers(astridFriends, userIds, emails, names);
contactPickerUser = new AssignedToUser(activity.getString(R.string.actfm_EPA_choose_contact), contactPickerUser = new AssignedToUser(activity.getString(R.string.actfm_EPA_choose_contact),

Loading…
Cancel
Save