use of com.abewy.android.apps.klyph.core.fql.Friend in project Klyph by jonathangerbaud.
the class MemberAdapter method mergeViewWithData.
@Override
protected void mergeViewWithData(View view, GraphObject data) {
super.mergeViewWithData(view, data);
PicturePrimarySecondaryTextHolder holder = (PicturePrimarySecondaryTextHolder) getHolder(view);
// holder.getPicture().setImageDrawable(null);
Friend friend = (Friend) data;
holder.getPrimaryText().setText(friend.getName());
if (friend.getWork().size() > 0) {
Work work = friend.getWork().get(0);
StringBuilder str = new StringBuilder(work.getEmployer().getName());
if (work.getPosition().getName().length() > 0)
str.append(", ").append(work.getPosition().getName());
holder.getSecondaryText().setText(str);
holder.getSecondaryText().setVisibility(View.VISIBLE);
} else if (friend.getEducation().size() > 0) {
Education education = friend.getEducation().get(0);
StringBuilder str = new StringBuilder(education.getSchool().getName());
if (education.getYear().getName().length() > 0)
str.append(", ").append(education.getYear().getName());
if (education.getConcentration().getName().length() > 0)
str.append(", ").append(education.getConcentration().getName());
holder.getSecondaryText().setText(str);
holder.getSecondaryText().setVisibility(View.VISIBLE);
} else {
holder.getSecondaryText().setVisibility(View.GONE);
}
// FacebookUtil.getProfilePictureURLForId(friend.getUid());
String url = friend.getPic();
loadImage(holder.getPicture(), url, AttrUtil.getResourceId(getContext(view), R.attr.squarePlaceHolderIcon), data);
}
use of com.abewy.android.apps.klyph.core.fql.Friend in project Klyph by jonathangerbaud.
the class ThreadAdapter method bindData.
@Override
public void bindData(View view, GraphObject data) {
ThreadHolder holder = (ThreadHolder) getHolder(view);
MessageThread thread = (MessageThread) data;
List<Friend> friends = new ArrayList<Friend>();
friends.addAll(thread.getRecipients_friends());
String pic = null;
if (friends.size() > 0) {
for (int i = 0; i < friends.size(); i++) {
Friend friend = friends.get(i);
if (friend.getUid().equals(KlyphSession.getSessionUserId())) {
friends.remove(friend);
i--;
} else {
if (pic == null) {
pic = friend.getPic();
}
}
}
}
if (pic == null) {
pic = "";
}
Resources res = getContext(view).getResources();
holder.getAuthorName().setText("");
int n = friends.size();
Friend friend = null;
if (n > 0) {
friend = friends.get(0);
} else {
n = 1;
friend = thread.getRecipients_friends().get(0);
pic = friend.getPic();
}
String friendName = friend.getFirst_name().length() > 0 ? friend.getFirst_name() : friend.getName();
if (n == 1) {
holder.getAuthorName().setText(String.format(res.getString(R.string.thread_one_user), friend.getName()));
} else if (n > 1) {
Friend friend2 = friends.get(1);
String friendName2 = friend2.getFirst_name().length() > 0 ? friend2.getFirst_name() : friend2.getName();
if (n == 2) {
holder.getAuthorName().setText(String.format(res.getString(R.string.thread_two_users), friendName, friendName2));
} else if (n > 2) {
holder.getAuthorName().setText(String.format(res.getString(R.string.thread_many_users), friendName, friendName2, n - 2));
}
}
String message = "";
if (thread.getSnippet_author().equals(KlyphSession.getSessionUserId())) {
message = view.getContext().getString(R.string.my_last_message, thread.getSnippet());
} else if (thread.isMultiUserConversation()) {
for (Friend friend2 : thread.getRecipients_friends()) {
if (friend2.getUid().equals(thread.getSnippet_author())) {
message = view.getContext().getString(R.string.friend_last_message, friend2.getFirst_name(), thread.getSnippet());
break;
}
}
} else {
message = thread.getSnippet();
}
holder.getMessageTextView().setText(message);
EmojiUtil.convertTextToEmoji(holder.getMessageTextView(), false);
holder.getDateTextView().setText(DateUtil.getShortDate(thread.getUpdated_time()));
int unreadCount = thread.getUnread();
if (unreadCount > 0) {
if (unreadCount <= 99)
holder.getUnreadCountTextView().setText(thread.getUnread() + "");
else
holder.getUnreadCountTextView().setText("99+");
holder.getUnreadCountTextView().setVisibility(View.VISIBLE);
holder.getAuthorName().setTypeface(null, Typeface.BOLD);
holder.getMessageTextView().setTypeface(null, Typeface.BOLD);
holder.getDateTextView().setTypeface(null, Typeface.BOLD);
} else {
holder.getUnreadCountTextView().setVisibility(View.GONE);
holder.getAuthorName().setTypeface(null, Typeface.NORMAL);
holder.getMessageTextView().setTypeface(null, Typeface.NORMAL);
holder.getDateTextView().setTypeface(null, Typeface.NORMAL);
}
ImageLoader.display(holder.getAuthorPicture(), pic, KlyphUtil.getPlaceHolder(holder.getAuthorName().getContext()));
}
use of com.abewy.android.apps.klyph.core.fql.Friend in project Klyph by jonathangerbaud.
the class Klyph method getIntentForGraphObject.
public static Intent getIntentForGraphObject(Context context, GraphObject object) {
Intent intent = null;
if (object instanceof User) {
User user = (User) object;
if (user.getUid().length() == 0) {
return null;
}
intent = new Intent();
intent.setClass(context, UserActivity.class);
intent.putExtra(KlyphBundleExtras.USER_ID, user.getUid());
intent.putExtra(KlyphBundleExtras.USER_NAME, user.getName());
} else if (object instanceof Friend) {
Friend friend = (Friend) object;
if (friend.getUid().length() == 0) {
return null;
}
intent = new Intent();
intent.setClass(context, UserActivity.class);
intent.putExtra(KlyphBundleExtras.USER_ID, friend.getUid());
intent.putExtra(KlyphBundleExtras.USER_NAME, friend.getName());
} else if (object instanceof Page) {
Page page = (Page) object;
intent = new Intent();
intent.setClass(context, PageActivity.class);
intent.putExtra(KlyphBundleExtras.PAGE_ID, page.getPage_id());
intent.putExtra(KlyphBundleExtras.PAGE_NAME, page.getName());
} else if (object instanceof Event) {
Event event = (Event) object;
intent = new Intent();
intent.setClass(context, EventActivity.class);
intent.putExtra(KlyphBundleExtras.EVENT_ID, event.getEid());
intent.putExtra(KlyphBundleExtras.EVENT_NAME, event.getName());
} else if (object instanceof Stream) {
Stream stream = (Stream) object;
intent = new Intent();
intent.setClass(context, StreamActivity.class);
// intent.putExtra(KlyphBundleExtras.STREAM_ID, stream.getPost_id());
intent.putExtra(KlyphBundleExtras.STREAM_PARCELABLE, stream);
// intent.putExtra(CkoobafeBundleExtras.EVENT_NAME,
// event.getName());
} else if (object instanceof Group) {
Group group = (Group) object;
intent = new Intent();
intent.setClass(context, GroupActivity.class);
intent.putExtra(KlyphBundleExtras.GROUP_ID, group.getGid());
intent.putExtra(KlyphBundleExtras.GROUP_NAME, group.getName());
} else if (object instanceof Tag) {
Tag tag = (Tag) object;
if (tag.getType().equals("user") || tag.getType().equals(GraphType.FQL_USER.toString())) {
intent = new Intent();
intent.setClass(context, UserActivity.class);
intent.putExtra(KlyphBundleExtras.USER_ID, tag.getId());
intent.putExtra(KlyphBundleExtras.USER_NAME, tag.getName());
} else if (tag.getType().equals("page") || tag.getType().equals(GraphType.FQL_PAGE.toString())) {
intent = new Intent();
intent.setClass(context, PageActivity.class);
intent.putExtra(KlyphBundleExtras.PAGE_ID, tag.getId());
intent.putExtra(KlyphBundleExtras.PAGE_NAME, tag.getName());
}
} else if (object instanceof Relative) {
Relative user = (Relative) object;
if (user.getUid().length() == 0) {
return null;
}
intent = new Intent();
intent.setClass(context, UserActivity.class);
intent.putExtra(KlyphBundleExtras.USER_ID, user.getUid());
intent.putExtra(KlyphBundleExtras.USER_NAME, user.getName());
} else if (object instanceof FriendRequest) {
FriendRequest fr = (FriendRequest) object;
if (fr.getUid_from().length() == 0) {
return null;
}
intent = new Intent();
intent.setClass(context, UserActivity.class);
intent.putExtra(KlyphBundleExtras.USER_ID, fr.getUid_from());
intent.putExtra(KlyphBundleExtras.USER_NAME, fr.getUid_from_name());
}
return intent;
}
use of com.abewy.android.apps.klyph.core.fql.Friend in project Klyph by jonathangerbaud.
the class Birthdays method onGridItemClick.
@Override
public void onGridItemClick(KlyphGridView l, View v, int position, long id) {
Friend friend = (Friend) l.getItemAtPosition(position);
startActivity(Klyph.getIntentForGraphObject(getActivity(), friend));
}
Aggregations