Search in sources :

Example 1 with FriendRequest

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

the class FriendRequestAdapter method mergeViewWithData.

@Override
protected void mergeViewWithData(View view, GraphObject data) {
    super.mergeViewWithData(view, data);
    PicturePrimarySecondaryTextHolder holder = (PicturePrimarySecondaryTextHolder) getHolder(view);
    //holder.getPicture().setImageDrawable(null);
    FriendRequest friendRequest = (FriendRequest) data;
    holder.getPrimaryText().setText(friendRequest.getUid_from_name());
    if (friendRequest.getMessage().length() > 0) {
        holder.getSecondaryText().setText(DateUtil.timeAgoInWords(getContext(view), friendRequest.getMessage()));
        holder.getSecondaryText().setVisibility(View.VISIBLE);
    } else {
        holder.getSecondaryText().setVisibility(View.GONE);
    }
    loadImage(holder.getPicture(), friendRequest.getUid_from_pic(), data);
}
Also used : FriendRequest(com.abewy.android.apps.klyph.core.fql.FriendRequest) PicturePrimarySecondaryTextHolder(com.abewy.android.apps.klyph.adapter.holder.PicturePrimarySecondaryTextHolder)

Example 2 with FriendRequest

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

the class UserActivity method initComponentsOnRequestSucces.

@Override
protected void initComponentsOnRequestSucces(List<GraphObject> result) {
    user = (User) result.get(0);
    if (result.size() > 1) {
        FriendRequest fr = (FriendRequest) result.get(1);
        setFriendButtonState(user.isFriend(), fr.getUid_to().equals(KlyphSession.getSessionUserId()), fr.getUid_from().equals(KlyphSession.getSessionUserId()));
    } else {
        setFriendButtonState(user.isFriend(), hasReceivedFriendRequest, hasSentFriendRequest);
    }
    headerName.setText(user.getName());
    // ImageLoader.display((ImageView) mHeaderPicture, ImageLoader.FAKE_URI, true, KlyphUtil.getPlaceHolder(this));
    ImageLoader.display(getHeaderPicture(), user.getPic_cover().getSource(), true, R.drawable.cover_place_holder, new SimpleListener() {

        @Override
        public void onSuccess() {
            super.onSuccess();
            // that would destroy the view
            if (getHeaderPicture() != null)
                ((UserCoverImageView) getHeaderPicture()).setOffset(user.getPic_cover().getOffset_y());
        }
    });
    ImageLoader.display(getHeaderLogo(), user.getPic(), true, KlyphUtil.getProfilePlaceHolder(this));
    Log.d("UserActivity", "initComponentsOnRequestSucces: " + listGridHeaderHeight);
    ((TabsAdapter) getPagerAdapter()).setUser(user);
    ((TabsAdapter) getPagerAdapter()).init(listGridHeaderHeight);
    ;
    ((TabsAdapter) getPagerAdapter()).setInitialPositionAndShow();
}
Also used : FriendRequest(com.abewy.android.apps.klyph.core.fql.FriendRequest) SimpleListener(com.abewy.android.apps.klyph.core.imageloader.SimpleListener) UserCoverImageView(com.abewy.android.apps.klyph.widget.coverImage.UserCoverImageView)

Example 3 with FriendRequest

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

the class Notifications method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.menu_dismiss) {
        List<GraphObject> list = new ArrayList<GraphObject>();
        List<List<AsyncRequest>> batchs = new ArrayList<List<AsyncRequest>>();
        List<AsyncRequest> requests = new ArrayList<AsyncRequest>();
        batchs.add(requests);
        for (GraphObject o : getAdapter().getItems()) {
            if (o instanceof Notification || o instanceof FriendRequest) {
                if (o instanceof Notification) {
                    Notification n = (Notification) o;
                    if (requests.size() == 40) {
                        requests = new ArrayList<AsyncRequest>();
                        batchs.add(requests);
                    }
                    requests.add(new AsyncRequest(Query.POST_READ_NOTIFICATION, n.getNotification_id(), "", null));
                    n.setIs_unread(false);
                }
                list.add(o);
            }
        }
        populate(list);
        unreadCount = 0;
        getActivity().invalidateOptionsMenu();
        for (List<AsyncRequest> batch : batchs) {
            if (batch.size() > 0)
                AsyncRequest.executeBatch(batch);
        }
        ((NotificationsListener) getActivity()).onNewNotifications();
        return true;
    } else if (item.getItemId() == R.id.menu_refresh) {
        onRefreshClicked();
        return true;
    }
    return super.onOptionsItemSelected(item);
}
Also used : AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) FriendRequest(com.abewy.android.apps.klyph.core.fql.FriendRequest) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject) Notification(com.abewy.android.apps.klyph.core.fql.Notification) KlyphNotification(com.abewy.android.apps.klyph.KlyphNotification)

Example 4 with FriendRequest

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

the class Notifications method onResume.

@Override
public void onResume() {
    super.onResume();
    getActivity().registerReceiver(mMessageReceiver, new IntentFilter(KlyphBundleExtras.NOTIFICATION_EVENT));
    getActivity().registerReceiver(mMessageReceiver, new IntentFilter("com.abewy.android.apps.klyph.action.NOTIFICATION_STATUS_CHANGE"));
    // Update list in case some items have been read
    if (getAdapter() != null) {
        List<GraphObject> list = new ArrayList<GraphObject>();
        for (GraphObject o : getAdapter().getItems()) {
            if (o instanceof Notification || o instanceof FriendRequest)
                list.add(o);
        }
        populate(list);
    }
    // If last update greater than 1 min, do an update
    if ((new Date().getTime() - lastUpdateTime > 1 * 60 * 1000) || KlyphPreferences.hasNotificationReadStatusChanged()) {
        KlyphPreferences.setNotificationReadStatusChanged(false);
        if (hasPermissions() && loggedIn == true) {
            loadNotifications();
        }
    }
}
Also used : IntentFilter(android.content.IntentFilter) ArrayList(java.util.ArrayList) FriendRequest(com.abewy.android.apps.klyph.core.fql.FriendRequest) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject) Notification(com.abewy.android.apps.klyph.core.fql.Notification) KlyphNotification(com.abewy.android.apps.klyph.KlyphNotification) Date(java.util.Date)

Example 5 with FriendRequest

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

the class FriendRequestDeserializer method deserializeObject.

@Override
public GraphObject deserializeObject(JSONObject data) {
    FriendRequest fq = new FriendRequest();
    deserializePrimitives(fq, data);
    return fq;
}
Also used : FriendRequest(com.abewy.android.apps.klyph.core.fql.FriendRequest)

Aggregations

FriendRequest (com.abewy.android.apps.klyph.core.fql.FriendRequest)7 KlyphNotification (com.abewy.android.apps.klyph.KlyphNotification)3 Notification (com.abewy.android.apps.klyph.core.fql.Notification)3 GraphObject (com.abewy.android.apps.klyph.core.graph.GraphObject)3 Intent (android.content.Intent)2 ArrayList (java.util.ArrayList)2 IntentFilter (android.content.IntentFilter)1 PicturePrimarySecondaryTextHolder (com.abewy.android.apps.klyph.adapter.holder.PicturePrimarySecondaryTextHolder)1 EventActivity (com.abewy.android.apps.klyph.app.EventActivity)1 GroupActivity (com.abewy.android.apps.klyph.app.GroupActivity)1 PageActivity (com.abewy.android.apps.klyph.app.PageActivity)1 UserActivity (com.abewy.android.apps.klyph.app.UserActivity)1 Event (com.abewy.android.apps.klyph.core.fql.Event)1 Friend (com.abewy.android.apps.klyph.core.fql.Friend)1 Group (com.abewy.android.apps.klyph.core.fql.Group)1 Page (com.abewy.android.apps.klyph.core.fql.Page)1 Stream (com.abewy.android.apps.klyph.core.fql.Stream)1 Tag (com.abewy.android.apps.klyph.core.fql.Tag)1 User (com.abewy.android.apps.klyph.core.fql.User)1 Relative (com.abewy.android.apps.klyph.core.fql.User.Relative)1