Cleaned up final references to Task.USER

pull/14/head
Sam Bosley 13 years ago
parent 6b458a501b
commit b8476ca5b8

@ -280,8 +280,21 @@ public class EditPeopleControlSet extends PopupControlSet {
} }
if(Task.isRealUserId(t.getValue(Task.USER_ID))) { if(Task.isRealUserId(t.getValue(Task.USER_ID))) {
try {
JSONObject user = new JSONObject(t.getValue(Task.USER)); JSONObject user = new JSONObject(t.getValue(Task.USER));
coreUsersJson.add(0, user); coreUsersJson.add(0, user);
} catch (JSONException e) {
User user = userDao.fetch(t.getValue(Task.USER_ID), User.PROPERTIES);
if (user != null) {
try {
JSONObject assignedUser = new JSONObject();
ActFmSyncService.JsonHelper.jsonFromUser(assignedUser, user);
coreUsersJson.add(0, assignedUser);
} catch (JSONException e2) {
//
}
}
}
} }
ArrayList<JSONObject> astridFriends = getAstridFriends(); ArrayList<JSONObject> astridFriends = getAstridFriends();
@ -400,12 +413,27 @@ public class EditPeopleControlSet extends PopupControlSet {
} }
@SuppressWarnings("nls") @SuppressWarnings("nls")
private int findAssignedIndex(Task t, ArrayList<AssignedToUser>... userLists) throws JSONException { private int findAssignedIndex(Task t, ArrayList<AssignedToUser>... userLists) {
String assignedStr = t.getValue(Task.USER); String assignedStr = t.getValue(Task.USER);
if (!TextUtils.isEmpty(assignedStr)) { long assignedId = -2;
String assignedEmail = t.getValue(Task.USER_EMAIL);
try {
JSONObject assigned = new JSONObject(assignedStr); JSONObject assigned = new JSONObject(assignedStr);
long assignedId = assigned.optLong("id", -2); assignedId = assigned.optLong("id", -2);
String assignedEmail = assigned.optString("email"); assignedEmail = assigned.optString("email");
} catch (JSONException e) {
User assignedUser = userDao.fetch(t.getValue(Task.USER_ID), User.PROPERTIES);
JSONObject assigned = new JSONObject();
try {
if (assignedUser != null) {
ActFmSyncService.JsonHelper.jsonFromUser(assigned, assignedUser);
assignedId = assigned.optLong("id", -2);
assignedEmail = assigned.optString("email");
}
} catch (JSONException e2) {
//
}
}
int index = 0; int index = 0;
for (ArrayList<AssignedToUser> userList : userLists) { for (ArrayList<AssignedToUser> userList : userLists) {
@ -421,7 +449,6 @@ public class EditPeopleControlSet extends PopupControlSet {
} }
index++; // Add one for headers separating user lists index++; // Add one for headers separating user lists
} }
}
return 0; return 0;
} }

@ -37,7 +37,6 @@ import android.text.Spanned;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.TextUtils.TruncateAt; import android.text.TextUtils.TruncateAt;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
@ -1131,7 +1130,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
// image view // image view
final AsyncImageView pictureView = viewHolder.picture; { final AsyncImageView pictureView = viewHolder.picture; {
if (pictureView != null) { if (pictureView != null) {
if(task.getValue(Task.USER_ID) == Task.USER_ID_SELF && !viewHolder.isTaskRabbit) { if(Task.USER_ID_SELF.equals(task.getValue(Task.USER_ID)) && !viewHolder.isTaskRabbit) {
pictureView.setVisibility(View.GONE); pictureView.setVisibility(View.GONE);
if (viewHolder.pictureBorder != null) if (viewHolder.pictureBorder != null)
viewHolder.pictureBorder.setVisibility(View.GONE); viewHolder.pictureBorder.setVisibility(View.GONE);
@ -1142,16 +1141,17 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
pictureView.setUrl(null); pictureView.setUrl(null);
if (viewHolder.isTaskRabbit) { if (viewHolder.isTaskRabbit) {
pictureView.setDefaultImageResource(R.drawable.task_rabbit_image); pictureView.setDefaultImageResource(R.drawable.task_rabbit_image);
} else if(task.getValue(Task.USER_ID) == Task.USER_ID_UNASSIGNED) } else if(Task.USER_ID_UNASSIGNED.equals(task.getValue(Task.USER_ID)))
pictureView.setDefaultImageResource(R.drawable.icn_anyone_transparent); pictureView.setDefaultImageResource(R.drawable.icn_anyone_transparent);
else { else {
pictureView.setDefaultImageResource(R.drawable.icn_default_person_image); pictureView.setDefaultImageResource(R.drawable.icn_default_person_image);
// TODO: Implement a join here
try { try {
JSONObject user = new JSONObject(task.getValue(Task.USER)); JSONObject user = new JSONObject(task.getValue(Task.USER));
pictureView.setUrl(user.optString("picture")); //$NON-NLS-1$ pictureView.setUrl(user.optString("picture")); //$NON-NLS-1$
} catch (JSONException e) { } catch (JSONException e) {
Log.w("astrid", "task-adapter-image", e); //$NON-NLS-1$ //$NON-NLS-2$ if (Task.isRealUserId(task.getValue(Task.USER_ID))) {
// TODO: Implement a join here
}
} }
} }
} }

Loading…
Cancel
Save