Merge pull request #155 from sbosley/120227_sb_edit_people_bugs

EditPeopleControlSet bugs
pull/14/head
sbosley 13 years ago
commit 96c087793d

@ -110,6 +110,8 @@ public class EditPeopleControlSet extends PopupControlSet {
private AssignedToUser taskRabbitUser = null;
private boolean loadedUI = false;
private final List<AssignedChangedListener> listeners = new LinkedList<AssignedChangedListener>();
public interface AssignedChangedListener {
@ -223,23 +225,30 @@ public class EditPeopleControlSet extends PopupControlSet {
final String tag = metadata.getValue(TagService.TAG);
TagData tagData = tagDataService.getTag(tag, TagData.MEMBER_COUNT, TagData.MEMBERS, TagData.USER);
if(tagData != null && tagData.getValue(TagData.MEMBER_COUNT) > 0) {
try {
addMembersFromTagData(tagData, tag, sharedPeople, collaborators);
} catch (JSONException e) {
exceptionService.reportError("json-reading-data", e);
}
} else {
nonSharedTags.add((Metadata) metadata.clone());
}
}
if (includeTag != null && tags.getCount() == 0) {
try {
addMembersFromTagData(includeTag, null, sharedPeople, collaborators);
} catch (JSONException e) {
exceptionService.reportError("json-reading-data", e);
}
}
if(collaborators.size() > 0)
buildCollaborators(collaborators);
buildAssignedToSpinner(task, sharedPeople);
} catch (JSONException e) {
exceptionService.reportError("json-reading-data", e);
} finally {
tags.close();
loadedUI = true;
}
}
}).start();
@ -269,7 +278,7 @@ public class EditPeopleControlSet extends PopupControlSet {
}
@SuppressWarnings("nls")
private void buildCollaborators(final ArrayList<JSONObject> sharedPeople) throws JSONException {
private void buildCollaborators(final ArrayList<JSONObject> sharedPeople) {
activity.runOnUiThread(new Runnable() {
@Override
@ -318,11 +327,13 @@ public class EditPeopleControlSet extends PopupControlSet {
}
@SuppressWarnings("nls")
private void buildAssignedToSpinner(Task t, ArrayList<JSONObject> sharedPeople) throws JSONException {
private void buildAssignedToSpinner(Task t, ArrayList<JSONObject> sharedPeople) {
HashSet<Long> userIds = new HashSet<Long>();
HashSet<String> emails = new HashSet<String>();
HashMap<String, AssignedToUser> names = new HashMap<String, AssignedToUser>();
int assignedIndex = 0;
try {
if(t.getValue(Task.USER_ID) > 0) {
JSONObject user = new JSONObject(t.getValue(Task.USER));
sharedPeople.add(0, user);
@ -382,7 +393,6 @@ public class EditPeopleControlSet extends PopupControlSet {
}
String assignedStr = t.getValue(Task.USER);
int assignedIndex = 0;
if (!TextUtils.isEmpty(assignedStr)) {
JSONObject assigned = new JSONObject(assignedStr);
long assignedId = assigned.optLong("id", -2);
@ -407,6 +417,9 @@ public class EditPeopleControlSet extends PopupControlSet {
}
}
}
} catch (JSONException e) {
exceptionService.reportError("json-reading-data", e);
}
selected = assignedIndex;
@ -543,6 +556,10 @@ public class EditPeopleControlSet extends PopupControlSet {
// Nothing, we don't lazy load this control set yet
}
public boolean hasLoadedUI() {
return loadedUI;
}
/**
* Save sharing settings
* @param toast toast to show after saving is finished
@ -562,6 +579,8 @@ public class EditPeopleControlSet extends PopupControlSet {
userJson = PeopleContainer.createUserJson(assignedCustom);
assignedView = assignedCustom;
} else {
if (!loadedUI || assignedList.getCheckedItemPosition() == ListView.INVALID_POSITION)
return true;
AssignedToUser item = (AssignedToUser) assignedList.getAdapter().getItem(assignedList.getCheckedItemPosition());
if (item != null) {
if (item.equals(taskRabbitUser)) { //don't want to ever set the user as the task rabbit user

@ -859,7 +859,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
public boolean onKeyDown(int keyCode) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (title.getText().length() == 0)
if (title.getText().length() == 0 || !peopleControlSet.hasLoadedUI())
discardButtonClick();
else
saveButtonClick();

Loading…
Cancel
Save