Search in sources :

Example 21 with Friend

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);
}
Also used : Friend(com.abewy.android.apps.klyph.core.fql.Friend) Education(com.abewy.android.apps.klyph.core.fql.User.Education) Work(com.abewy.android.apps.klyph.core.fql.User.Work) PicturePrimarySecondaryTextHolder(com.abewy.android.apps.klyph.adapter.holder.PicturePrimarySecondaryTextHolder)

Example 22 with Friend

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()));
}
Also used : Friend(com.abewy.android.apps.klyph.core.fql.Friend) ThreadHolder(com.abewy.android.apps.klyph.adapter.holder.ThreadHolder) ArrayList(java.util.ArrayList) MessageThread(com.abewy.android.apps.klyph.core.fql.MessageThread) Resources(android.content.res.Resources)

Example 23 with Friend

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;
}
Also used : PageActivity(com.abewy.android.apps.klyph.app.PageActivity) Group(com.abewy.android.apps.klyph.core.fql.Group) Relative(com.abewy.android.apps.klyph.core.fql.User.Relative) User(com.abewy.android.apps.klyph.core.fql.User) Intent(android.content.Intent) Page(com.abewy.android.apps.klyph.core.fql.Page) FriendRequest(com.abewy.android.apps.klyph.core.fql.FriendRequest) UserActivity(com.abewy.android.apps.klyph.app.UserActivity) EventActivity(com.abewy.android.apps.klyph.app.EventActivity) GroupActivity(com.abewy.android.apps.klyph.app.GroupActivity) Friend(com.abewy.android.apps.klyph.core.fql.Friend) Event(com.abewy.android.apps.klyph.core.fql.Event) Stream(com.abewy.android.apps.klyph.core.fql.Stream) Tag(com.abewy.android.apps.klyph.core.fql.Tag)

Example 24 with Friend

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));
}
Also used : Friend(com.abewy.android.apps.klyph.core.fql.Friend)

Aggregations

Friend (com.abewy.android.apps.klyph.core.fql.Friend)24 ArrayList (java.util.ArrayList)5 Intent (android.content.Intent)3 GraphObject (com.abewy.android.apps.klyph.core.graph.GraphObject)3 Filter (android.widget.Filter)2 MultiObjectAdapter (com.abewy.android.apps.klyph.adapter.MultiObjectAdapter)2 PicturePrimarySecondaryTextHolder (com.abewy.android.apps.klyph.adapter.holder.PicturePrimarySecondaryTextHolder)2 Stream (com.abewy.android.apps.klyph.core.fql.Stream)2 Tag (com.abewy.android.apps.klyph.core.fql.Tag)2 Education (com.abewy.android.apps.klyph.core.fql.User.Education)2 Work (com.abewy.android.apps.klyph.core.fql.User.Work)2 List (java.util.List)2 Resources (android.content.res.Resources)1 ViewGroup (android.view.ViewGroup)1 Checkable (android.widget.Checkable)1 FriendPickerHolder (com.abewy.android.apps.klyph.adapter.holder.FriendPickerHolder)1 PicturePrimaryTextHolder (com.abewy.android.apps.klyph.adapter.holder.PicturePrimaryTextHolder)1 ThreadHolder (com.abewy.android.apps.klyph.adapter.holder.ThreadHolder)1 EventActivity (com.abewy.android.apps.klyph.app.EventActivity)1 GroupActivity (com.abewy.android.apps.klyph.app.GroupActivity)1