Search in sources :

Example 16 with Friend

use of com.abewy.android.apps.klyph.core.fql.Friend in project Klyph by jonathangerbaud.

the class BirthdayAdapter 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());
    String birthday = friend.getBirthday();
    Date birthdayDate = null;
    String format = "MM/dd/y";
    try {
        birthdayDate = new SimpleDateFormat(format).parse(friend.getBirthday_date());
    } catch (ParseException e) {
    // e.printStackTrace();
    }
    if (birthdayDate != null) {
        Calendar dobDate = Calendar.getInstance();
        dobDate.setTime(birthdayDate);
        int year = dobDate.get(Calendar.YEAR);
        int month = dobDate.get(Calendar.MONTH);
        int day = dobDate.get(Calendar.DAY_OF_MONTH);
        Calendar today = Calendar.getInstance();
        today.set(Calendar.DAY_OF_MONTH, day);
        today.set(Calendar.MONTH, month);
        int curYear = today.get(Calendar.YEAR);
        int curMonth = today.get(Calendar.MONTH);
        int curDay = today.get(Calendar.DAY_OF_MONTH);
        int age = curYear - year;
        if (curMonth < month || (month == curMonth && curDay < day)) {
            age--;
        }
        birthday += " - " + getContext(holder.getPrimaryText()).getString(R.string.birthday_age, age);
    }
    holder.getSecondaryText().setText(birthday);
    loadImage(holder.getPicture(), friend.getPic(), AttrUtil.getResourceId(getContext(holder.getPrimaryText()), R.attr.squarePlaceHolderIcon), data);
}
Also used : Friend(com.abewy.android.apps.klyph.core.fql.Friend) Calendar(java.util.Calendar) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) PicturePrimarySecondaryTextHolder(com.abewy.android.apps.klyph.adapter.holder.PicturePrimarySecondaryTextHolder)

Example 17 with Friend

use of com.abewy.android.apps.klyph.core.fql.Friend in project Klyph by jonathangerbaud.

the class PostShare method initWithIntent.

public void initWithIntent(Intent intent) {
    String photoId = intent.getStringExtra(KlyphBundleExtras.SHARE_PHOTO_ID);
    String videoId = intent.getStringExtra(KlyphBundleExtras.SHARE_VIDEO_ID);
    String albumId = intent.getStringExtra(KlyphBundleExtras.SHARE_ALBUM_ID);
    Stream post = intent.getParcelableExtra(KlyphBundleExtras.SHARE_POST_ID);
    String linkUrl = intent.getStringExtra(KlyphBundleExtras.SHARE_LINK_URL);
    if (photoId != null) {
        url = PHOTO + photoId;
        new AsyncRequest(Query.PHOTO, photoId, "", new AsyncRequest.Callback() {

            @Override
            public void onComplete(Response response) {
                onPhotoRequestComplete(response);
            }
        }).execute();
    } else if (videoId != null) {
        url = VIDEO + videoId;
        new AsyncRequest(Query.VIDEO, videoId, "", new AsyncRequest.Callback() {

            @Override
            public void onComplete(Response response) {
                onVideoRequestComplete(response);
            }
        }).execute();
    } else if (albumId != null) {
        url = ALBUM + albumId;
        new AsyncRequest(Query.ALBUM, albumId, "", new AsyncRequest.Callback() {

            @Override
            public void onComplete(Response response) {
                onAlbumRequestComplete(response);
            }
        }).execute();
    } else if (post != null) {
        url = post.getPermalink();
        if (post.isStatus()) {
            fillViews(post.getActor_name(), post.getMessage(), post.getActor_pic());
            getActivity().setTitle(R.string.post_share_status);
        } else {
            Attachment att = post.getAttachment();
            if (att.isPhoto() || att.isVideo() || att.isAlbum()) {
                Media media = att.getMedia().get(0);
                if (att.isAlbum()) {
                    fillViews(post.getActor_name(), att.getName(), media.getSrc());
                } else {
                    fillViews(post.getActor_name(), media.getAlt(), media.getSrc());
                }
                if (att.isPhoto())
                    getActivity().setTitle(R.string.post_share_photo);
                else if (att.isVideo())
                    getActivity().setTitle(R.string.post_share_video);
                else
                    getActivity().setTitle(R.string.post_share_album);
            } else {
                getActivity().setTitle(R.string.post_share_status);
                fillViews(post.getActor_name(), post.getMessage(), post.getActor_pic());
            }
        }
    } else if (linkUrl != null) {
        isLink = true;
        url = linkUrl;
        imageUrl = intent.getStringExtra(KlyphBundleExtras.SHARE_LINK_IMAGE_URL);
        String linkName = intent.getStringExtra(KlyphBundleExtras.SHARE_LINK_NAME);
        String linkDesc = intent.getStringExtra(KlyphBundleExtras.SHARE_LINK_DESC);
        fillViews(linkName, linkDesc, imageUrl);
        getActivity().setTitle(R.string.post_share_link);
    } else {
        Log.d("PostShare", "All null");
    }
    if (isLink == false) {
        ((ViewGroup) spinner.getParent()).setVisibility(View.GONE);
    } else {
        SpinnerAdapter adapter = new SpinnerAdapter(getActivity());
        spinner.setAdapter(adapter);
        Friend friend = new Friend();
        friend.setName(getString(R.string.post_share_on_my_wall));
        adapter.add(friend);
        friend = new Friend();
        friend.setName(getString(R.string.post_share_on_friend_wall));
        adapter.add(friend);
        adapter.notifyDataSetChanged();
        spinner.setSelection(0);
        spinner.setOnItemSelectedListener(this);
        previousPosition = 0;
    }
}
Also used : Response(com.abewy.android.apps.klyph.core.request.Response) AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) Friend(com.abewy.android.apps.klyph.core.fql.Friend) ViewGroup(android.view.ViewGroup) Media(com.abewy.android.apps.klyph.core.fql.Media) Stream(com.abewy.android.apps.klyph.core.fql.Stream) Attachment(com.abewy.android.apps.klyph.core.fql.Attachment)

Example 18 with Friend

use of com.abewy.android.apps.klyph.core.fql.Friend in project Klyph by jonathangerbaud.

the class UserLikeDialog method onItemClick.

@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
    Friend friend = (Friend) arg0.getItemAtPosition(arg2);
    startActivity(Klyph.getIntentForGraphObject(getActivity(), friend));
}
Also used : Friend(com.abewy.android.apps.klyph.core.fql.Friend)

Example 19 with Friend

use of com.abewy.android.apps.klyph.core.fql.Friend in project Klyph by jonathangerbaud.

the class FriendPickerActivity method populate.

@Override
protected void populate(List<GraphObject> data) {
    super.populate(data);
    setNoMoreData(true);
    FRIEND_LIST = data;
    friends = data;
    boolean friendsSelected = false;
    if (initialIds != null) {
        int n = data.size();
        for (int i = 0; i < n; i++) {
            Friend friend = (Friend) data.get(i);
            for (int j = 0; j < initialIds.size(); j++) {
                if (friend.getUid().equals(initialIds.get(j))) {
                    friendsSelected = true;
                    friend.setSelected(true);
                    getListView().setItemChecked(i, true);
                    initialIds.remove(j);
                    j--;
                    break;
                }
            }
        }
    }
    if (friendsSelected == true) {
        startActionMode();
        refreshCheckedViews();
        refreshActionModeTitle();
    }
    searchText.setVisibility(View.VISIBLE);
}
Also used : Friend(com.abewy.android.apps.klyph.core.fql.Friend)

Example 20 with Friend

use of com.abewy.android.apps.klyph.core.fql.Friend in project Klyph by jonathangerbaud.

the class FriendAdapter method mergeViewWithData.

@Override
protected void mergeViewWithData(View view, GraphObject data) {
    super.mergeViewWithData(view, data);
    PicturePrimaryTextHolder holder = (PicturePrimaryTextHolder) getHolder(view);
    // holder.getPicture().setImageDrawable(null);
    Friend friend = (Friend) data;
    holder.getPrimaryText().setText(friend.getName());
    // 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) PicturePrimaryTextHolder(com.abewy.android.apps.klyph.adapter.holder.PicturePrimaryTextHolder)

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