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);
}
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();
}
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);
}
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();
}
}
}
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;
}
Aggregations