use of com.abewy.android.apps.klyph.core.fql.Stream in project Klyph by jonathangerbaud.
the class StreamAdapter method manageAttachment.
private void manageAttachment(View view, StreamHolder holder, Stream stream) {
Attachment attachment = stream.getAttachment();
Media media = attachment.getMedia().size() > 0 ? attachment.getMedia().get(0) : null;
int type = stream.getType();
if ((type == 245 || type == 257) && stream.getParent_stream() != null) {
final Stream parentStream = stream.getParent_stream();
headerAdapter.mergeData(holder, parentStream, true);
messageAdapter.mergeData(holder, parentStream);
buttonBarAdapter.mergeData(holder, stream);
}
if (type == 161 && stream.getDescription_tags().size() > 0 && stream.getLiked_pages().size() > 0) {
linkAdapter.manageLikedPage(holder, stream);
}
if (stream.isStatus()) {
statusAdapter.mergeData(holder, stream);
} else if (stream.isPhoto()) {
photoAdapter.mergeData(holder, stream, stream.getPhoto());
} else if (stream.isVideo()) {
photoAdapter.mergeData(holder, stream, stream.getVideo());
} else if (attachment.isPhoto() || ((media != null && media.isFydv()))) {
photoAdapter.mergeData(holder, stream);
buttonBarAdapter.mergeData(holder, stream);
} else if (attachment.isAlbum()) {
albumAdapter.mergeData(holder, stream);
buttonBarAdapter.mergeData(holder, stream);
} else if (attachment.isCheckin()) {
manageAttachmentCheckin(view, holder, stream);
buttonBarAdapter.mergeData(holder, stream);
} else if (stream.getLink().isEventLink()) {
linkAdapter.mergeData(holder, stream, stream.getLink());
} else if (type == 161 || attachment.getMedia().size() > 0) {
linkAdapter.mergeData(holder, stream);
buttonBarAdapter.mergeData(holder, stream);
} else if (stream.isLink()) {
linkAdapter.mergeData(holder, stream, stream.getLink());
} else {
buttonBarAdapter.mergeData(holder, stream);
}
}
use of com.abewy.android.apps.klyph.core.fql.Stream 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.Stream in project Klyph by jonathangerbaud.
the class NewsfeedAdapter method add.
@Override
public void add(GraphObject object) {
if (object instanceof Stream) {
final int size = getCount();
if (size - lastAdPosition >= AD_INTERVAL) {
lastAdPosition = size;
super.add(new AdItem());
}
}
super.add(object);
}
use of com.abewy.android.apps.klyph.core.fql.Stream in project Klyph by jonathangerbaud.
the class StreamDeserializer method deserializeObject.
@Override
public GraphObject deserializeObject(JSONObject data) {
Stream stream = new Stream();
deserializePrimitives(stream, data);
stream.setAttachment((Attachment) new AttachmentDeserializer().deserializeObject(getJsonObject(data, "attachment")));
stream.setLike_info((LikeInfo) new LikesDeserializer().deserializeObject(getJsonObject(data, "like_info")));
stream.setPrivacy((Privacy) new PrivacyDeserializer().deserializeObject(getJsonObject(data, "privacy")));
stream.setComment_info((CommentInfo) new CommentsDeserializer().deserializeObject(getJsonObject(data, "comment_info")));
stream.setLiked_pages(new PageDeserializer().deserializeArray(getJsonArray(data, "liked_pages"), Page.class));
stream.setEvent((Event) new EventDeserializer().deserializeObject(getJsonObject(data, "event")));
stream.setLink((Link) new LinkDeserializer().deserializeObject(getJsonObject(data, "link")));
stream.setPhoto((Photo) new PhotoDeserializer().deserializeObject(getJsonObject(data, "photo")));
stream.setVideo((Video) new VideoDeserializer().deserializeObject(getJsonObject(data, "video")));
stream.setStatus((Status) new StatusDeserializer().deserializeObject(getJsonObject(data, "status")));
stream.setApplication((Application) new ApplicationDeserializer().deserializeObject(getJsonObject(data, "application")));
if (data.optJSONObject("parent_stream") != null)
stream.setParent_stream((Stream) new StreamDeserializer().deserializeObject(getJsonObject(data, "parent_stream")));
if (data.optJSONArray("message_tags") != null)
stream.setMessage_tags(new TagDeserializer().deserializeMap(getJsonArray(data, "message_tags")));
else
stream.setMessage_tags(new TagDeserializer().deserializeMap(getJsonObject(data, "message_tags")));
if (data.optJSONArray("description_tags") != null)
stream.setDescription_tags(new TagDeserializer().deserializeMap(getJsonArray(data, "description_tags")));
else
stream.setDescription_tags(new TagDeserializer().deserializeMap(getJsonObject(data, "description_tags")));
if (data.optJSONArray("tagged_tags") != null) {
stream.setTagged_tags(new TagDeserializer().deserializeArray(getJsonArray(data, "tagged_tags"), Tag.class));
} else
stream.setTagged_tags(new ArrayList<Tag>());
return stream;
}
use of com.abewy.android.apps.klyph.core.fql.Stream in project Klyph by jonathangerbaud.
the class StreamSerializer method serializeObject.
@Override
public JSONObject serializeObject(GraphObject object) {
JSONObject json = new JSONObject();
serializePrimitives(object, json);
Stream stream = (Stream) object;
TagSerializer ts = new TagSerializer();
ts.serializeMap(stream.getMessage_tags(), json, "message_tags");
ts.serializeMap(stream.getDescription_tags(), json, "description_tags");
AttachmentSerializer as = new AttachmentSerializer();
LikesSerializer ls = new LikesSerializer();
PrivacySerializer ps = new PrivacySerializer();
CommentsSerializer cs = new CommentsSerializer();
EventSerializer es = new EventSerializer();
PageSerializer pas = new PageSerializer();
LinkSerializer lis = new LinkSerializer();
PhotoSerializer phs = new PhotoSerializer();
VideoSerializer vs = new VideoSerializer();
StatusSerializer ss = new StatusSerializer();
ApplicationSerializer aps = new ApplicationSerializer();
StreamSerializer sts = new StreamSerializer();
try {
json.put("attachment", as.serializeObject(stream.getAttachment()));
json.put("privacy", ps.serializeObject(stream.getPrivacy()));
json.put("like_info", ls.serializeObject(stream.getLike_info()));
json.put("comment_info", cs.serializeObject(stream.getComment_info()));
json.put("event", es.serializeObject(stream.getEvent()));
json.put("liked_pages", pas.serializeArray(stream.getLiked_pages()));
json.put("link", lis.serializeObject(stream.getLink()));
json.put("photo", phs.serializeObject(stream.getPhoto()));
json.put("video", vs.serializeObject(stream.getVideo()));
json.put("status", ss.serializeObject(stream.getStatus()));
json.put("application", aps.serializeObject(stream.getApplication()));
if (stream.getParent_stream() != null)
json.put("parent_stream", sts.serializeObject(stream.getParent_stream()));
} catch (JSONException e) {
Log.d("StreamSerializer", "JSONException " + e.getMessage());
}
return json;
}
Aggregations