@SuppressWarnings("nls") private void refreshMembersPage() { tagName.setText(tagData.getValue(TagData.NAME)); picture.setUrl(tagData.getValue(TagData.PICTURE)); TextView ownerLabel = (TextView) findViewById(R.id.tag_owner); try { if (tagData.getFlag(TagData.FLAGS, TagData.FLAG_EMERGENT)) { ownerLabel.setText(String.format("<%s>", getString(R.string.actfm_TVA_tag_owner_none))); } else if (tagData.getValue(TagData.USER_ID) == 0) { ownerLabel.setText(Preferences.getStringValue(ActFmPreferenceService.PREF_NAME)); } else { JSONObject owner = new JSONObject(tagData.getValue(TagData.USER)); ownerLabel.setText(owner.getString("name")); } } catch (JSONException e) { Log.e("tag-view-activity", "json error refresh owner", e); ownerLabel.setText("<error>"); System.err.println(tagData.getValue(TagData.USER)); } tagMembers.removeAllViews(); String peopleJson = tagData.getValue(TagData.MEMBERS); if (!TextUtils.isEmpty(peopleJson)) { try { JSONArray people = new JSONArray(peopleJson); for (int i = 0; i < people.length(); i++) { JSONObject person = people.getJSONObject(i); TextView textView = null; if (person.has("id") && person.getLong("id") == ActFmPreferenceService.userId()) textView = tagMembers.addPerson(Preferences.getStringValue(ActFmPreferenceService.PREF_NAME)); else if (!TextUtils.isEmpty(person.optString("name"))) textView = tagMembers.addPerson(person.getString("name")); else if (!TextUtils.isEmpty(person.optString("email"))) textView = tagMembers.addPerson(person.getString("email")); if (textView != null) { textView.setTag(person); textView.setEnabled(false); } } } catch (JSONException e) { System.err.println(peopleJson); Log.e("tag-view-activity", "json error refresh members", e); } } tagMembers.addPerson(""); // $NON-NLS-1$ }
public EditPeopleControlSet(Activity activity, int loginRequestCode) { DependencyInjectionService.getInstance().inject(this); this.activity = activity; this.loginRequestCode = loginRequestCode; sharedWithContainer = (PeopleContainer) activity.findViewById(R.id.share_container); assignedCustom = (EditText) activity.findViewById(R.id.assigned_custom); assignedSpinner = (Spinner) activity.findViewById(R.id.assigned_spinner); cbFacebook = (CheckBox) activity.findViewById(R.id.checkbox_facebook); cbTwitter = (CheckBox) activity.findViewById(R.id.checkbox_twitter); sharedWithContainer.addPerson(""); // $NON-NLS-1$ setUpListeners(); }
@SuppressWarnings("nls") private void setUpData() { try { JSONObject sharedWith; if (task.getValue(Task.SHARED_WITH).length() > 0) sharedWith = new JSONObject(task.getValue(Task.SHARED_WITH)); else sharedWith = new JSONObject(); cbFacebook.setChecked(sharedWith.optBoolean("fb", false)); cbTwitter.setChecked(sharedWith.optBoolean("tw", false)); final ArrayList<JSONObject> sharedPeople = new ArrayList<JSONObject>(); JSONArray people = sharedWith.optJSONArray("p"); if (people != null) { for (int i = 0; i < people.length(); i++) { String person = people.getString(i); TextView textView = sharedWithContainer.addPerson(person); textView.setEnabled(false); sharedPeople.add(PeopleContainer.createUserJson(textView)); } } new Thread( new Runnable() { @Override public void run() { ArrayList<JSONObject> collaborators = new ArrayList<JSONObject>(); TodorooCursor<Metadata> tags = TagService.getInstance().getTags(task.getId()); try { Metadata metadata = new Metadata(); for (tags.moveToFirst(); !tags.isAfterLast(); tags.moveToNext()) { metadata.readFromCursor(tags); 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) { JSONArray members = new JSONArray(tagData.getValue(TagData.MEMBERS)); for (int i = 0; i < members.length(); i++) { JSONObject user = members.getJSONObject(i); user.put("tag", tag); sharedPeople.add(user); collaborators.add(user); } if (!TextUtils.isEmpty(tagData.getValue(TagData.USER))) { JSONObject user = new JSONObject(tagData.getValue(TagData.USER)); user.put("tag", tag); sharedPeople.add(user); collaborators.add(user); } } else { nonSharedTags.add((Metadata) metadata.clone()); } } if (collaborators.size() > 0) buildCollaborators(collaborators); buildAssignedToSpinner(sharedPeople); } catch (JSONException e) { exceptionService.reportError("json-reading-data", e); } finally { tags.close(); } } }) .start(); } catch (JSONException e) { exceptionService.reportError("json-reading-data", e); } }