use of com.abewy.android.apps.klyph.core.fql.Tag 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.Tag in project Klyph by jonathangerbaud.
the class TagSerializer method serializeMap.
public void serializeMap(Map<String, List<Tag>> tags, JSONObject json, String field) {
JSONObject tagObject = new JSONObject();
for (Iterator<String> iterator = tags.keySet().iterator(); iterator.hasNext(); ) {
String key = (String) iterator.next();
List<Tag> tag = tags.get(key);
try {
tagObject.put(key, super.serializeArray(tag));
} catch (JSONException e) {
Log.d("TagSerializer", "JsonException " + e.getMessage());
}
}
try {
json.put(field, tagObject);
} catch (JSONException e) {
Log.d("TagSerializer", "JsonException " + e.getMessage());
}
}
use of com.abewy.android.apps.klyph.core.fql.Tag in project Klyph by jonathangerbaud.
the class StreamAdapter2 method manageAttachmentCheckin.
private void manageAttachmentCheckin(StreamHolder holder, Stream stream) {
Attachment attachment = stream.getAttachment();
Tag tag = new Tag();
tag.setName(attachment.getName());
tag.setId(attachment.getFb_checkin().getPage_id());
tag.setOffset(attachment.getCaption().indexOf(attachment.getName()));
tag.setLength(attachment.getName().length());
ArrayList<Tag> tags = new ArrayList<Tag>();
tags.add(tag);
// addClickableTextForTags(getContext(), holder.getStory(),
// attachment.getCaption(),
// tags);
}
use of com.abewy.android.apps.klyph.core.fql.Tag in project Klyph by jonathangerbaud.
the class StreamMessage method mergeData.
public void mergeData(IStreamHolder holder, Stream stream) {
final View view = holder.getAuthorProfileImage();
if (stream.getMessage().length() > 0) {
holder.getMessage().setText(stream.getMessage());
if (linksEnabled && stream.getMessage_tags().size() > 0) {
TextViewUtil.setTextClickableForTags(getContext(view), holder.getMessage(), stream.getMessage_tags(), linksEnabled);
}
holder.getMessage().setVisibility(View.VISIBLE);
// manage place
}
if (stream.getMessage_tags().size() == 0 && stream.getTagged_tags().size() > 0) {
List<Tag> tags = stream.getTagged_tags();
switch(tags.size()) {
case 1:
{
Tag tag = tags.get(0);
holder.getMessage().append(getContext(view).getString(R.string.post_with_one_friend, tag.getName()));
TextViewUtil.setElementClickable(getContext(view), holder.getMessage(), tag.getName(), tag.getId(), tag.getType(), linksEnabled);
break;
}
case 2:
{
Tag tag = tags.get(0);
Tag tag2 = tags.get(1);
holder.getMessage().append(getContext(view).getString(R.string.post_with_two_friends, tag.getName(), tag2.getName()));
TextViewUtil.setElementClickable(getContext(view), holder.getMessage(), tag.getName(), tag.getId(), tag.getType(), linksEnabled);
TextViewUtil.setElementClickable(getContext(view), holder.getMessage(), tag2.getName(), tag2.getId(), tag2.getType(), linksEnabled);
break;
}
default:
{
Tag tag = tags.get(0);
holder.getMessage().append(getContext(view).getString(R.string.post_with_several_friends, tag.getName(), tags.size()));
TextViewUtil.setElementClickable(getContext(view), holder.getMessage(), tag.getName(), tag.getId(), tag.getType(), linksEnabled);
TextViewUtil.setElementClickable(getContext(view), holder.getMessage(), getContext(view).getString(R.string.with_several_friends, tags.size()), tags, linksEnabled);
break;
}
}
}
manageCheckin(holder, stream);
}
use of com.abewy.android.apps.klyph.core.fql.Tag 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;
}
Aggregations