use of com.abewy.android.apps.klyph.core.fql.Media in project Klyph by jonathangerbaud.
the class StreamAlbum method mergeData.
public void mergeData(StreamHolder holder, Stream stream) {
Attachment attachment = stream.getAttachment();
final List<Media> medias = attachment.getMedia();
int n = medias.size();
final ArrayList<String> imageIds = new ArrayList<String>();
for (int i = 0; i < n; i++) {
String pid = medias.get(i).getPhoto().getPid();
if (pid != null && pid.length() > 0) {
imageIds.add(pid);
}
}
PhotoAdapter adapter = new PhotoAdapter(medias, maxHeight);
holder.getStreamAlbum().setAdapter(adapter);
holder.getStreamAlbum().setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> list, View view, int position, long arg3) {
Intent intent = new Intent(view.getContext(), AlbumActivity.class);
intent.putExtra(KlyphBundleExtras.PHOTO_ID, medias.get(position).getPhoto().getPid());
intent.putStringArrayListExtra(KlyphBundleExtras.PHOTO_LIST_ID, imageIds);
view.getContext().startActivity(intent);
}
});
holder.getStreamAlbum().setVisibility(View.VISIBLE);
}
use of com.abewy.android.apps.klyph.core.fql.Media in project Klyph by jonathangerbaud.
the class StreamButtonBar method handleShareWithAction.
private void handleShareWithAction(final IStreamHolder holder, final Stream stream) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
Attachment att = stream.getAttachment();
if (stream.isLink()) {
Link link = stream.getLink();
intent.putExtra(Intent.EXTRA_TEXT, link.getUrl());
intent.putExtra(Intent.EXTRA_SUBJECT, link.getTitle());
intent.setType("text/plain");
} else if (stream.isPhoto()) /* || att.isPhoto() */
{
Photo photo = stream.getPhoto();
intent.putExtra(Intent.EXTRA_TEXT, photo.getLargestImageURL());
if (photo.getCaption().length() > 0)
intent.putExtra(Intent.EXTRA_SUBJECT, photo.getCaption());
else if (stream.getMessage().length() > 0)
intent.putExtra(Intent.EXTRA_SUBJECT, stream.getMessage());
intent.setType("text/plain");
// intent.putExtra(KlyphBundleExtras.SHARE_PHOTO_ID, stream.isPhoto() ? photo.getObject_id() : att.getFb_object_id());
} else if (stream.isVideo()) /* || att.isVideo() */
{
Video video = stream.getVideo();
intent.putExtra(Intent.EXTRA_TEXT, video.getSrc_hq());
if (video.getTitle().length() > 0)
intent.putExtra(Intent.EXTRA_SUBJECT, video.getTitle());
else if (stream.getMessage().length() > 0)
intent.putExtra(Intent.EXTRA_SUBJECT, stream.getMessage());
intent.setType("text/plain");
// intent.putExtra(KlyphBundleExtras.SHARE_VIDEO_ID, stream.isVideo() ? video.getVid() : att.getFb_object_id());
} else /*
* else if (att.isAlbum())
* {
* intent.putExtra(KlyphBundleExtras.SHARE_ALBUM_ID, att.getFb_object_id());
* }
*/
if (att.getMedia().size() == 1) {
Media m = att.getMedia().get(0);
intent.putExtra(Intent.EXTRA_TEXT, m.getSrc());
intent.putExtra(Intent.EXTRA_SUBJECT, m.getAlt());
intent.setType("text/plain");
} else {
if (stream.getMessage().length() > 0) {
intent.putExtra(Intent.EXTRA_TEXT, stream.getMessage());
intent.setType("text/plain");
} else if (stream.getDescription().length() > 0) {
intent.putExtra(Intent.EXTRA_TEXT, stream.getDescription());
intent.setType("text/plain");
}
}
try {
getContext(holder.getShareButton()).startActivity(intent);
} catch (ActivityNotFoundException e) {
}
}
use of com.abewy.android.apps.klyph.core.fql.Media 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.Media in project Klyph by jonathangerbaud.
the class StreamPhoto method mergeData.
public void mergeData(StreamHolder holder, final Stream stream) {
/*
* holder.getPostPicture().setOnClickListener(new OnClickListener() {
*
* @Override public void onClick(View v) {
* PhoneUtil.openURL(getContext(),
* stream.getAttachment().getMedia().get(0).getHref()); } });
*/
final Attachment attachment = stream.getAttachment();
if (attachment.getMedia().size() > 0) {
final Media media = attachment.getMedia().get(0);
holder.getPostPhoto().setScaleType(ScaleType.FIT_XY);
loadMedia(holder.getPostPhoto(), media, stream, true);
holder.getPostPhoto().setVisibility(View.VISIBLE);
((ViewGroup) holder.getPostPhoto().getParent()).setVisibility(View.VISIBLE);
final View view = holder.getAuthorProfileImage();
if (attachment.isPhoto()) {
holder.getPostPhoto().setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getContext(view), ImageActivity.class);
String id = media.getPhoto().getFbid();
if (id.length() == 0)
id = media.getPhoto().getPid();
intent.putExtra(KlyphBundleExtras.PHOTO_ID, id);
intent.putExtra(KlyphBundleExtras.URL_IF_NOT_FOUND, getSource(media.getSrc()));
getContext(view).startActivity(intent);
}
});
} else {
holder.getPostPhoto().setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String href = media.isSwf() == false ? media.getHref() : attachment.getHref();
Log.d("StreamPhoto", "isYoutubeVideo " + media.getHref());
Log.d("StreamPhoto", "isYoutubeVideo " + attachment.getHref());
Log.d("StreamPhoto", "isYoutubeVideo " + YoutubeUtil.getVideoIdFromUrl(href));
String url = media.isSwf() ? media.getSwf().getSource_url() : media.getVideo().getSource_url();
Log.d("StreamPhoto", "isYoutubeVideo " + url);
if (media.isYoutubeVideo() && YoutubeUtil.getVideoIdFromUrl(url).length() > 0) {
Log.d("StreamPhoto", "isYoutubeVideo");
try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + YoutubeUtil.getVideoIdFromUrl(url)));
getContext(view).startActivity(intent);
} catch (ActivityNotFoundException ex) {
Log.d("StreamPhoto", "ActivityNotFoundException");
PhoneUtil.openURL(getContext(view), href);
}
} else {
Log.d("StreamPhoto", "not YoutubeVideo");
PhoneUtil.openURL(getContext(view), href);
}
}
});
if (attachment.getName().length() > 0) {
holder.getVideoTitle().setText(attachment.getName());
holder.getVideoTitle().setVisibility(View.VISIBLE);
((ViewGroup) holder.getVideoTitle().getParent()).setVisibility(View.VISIBLE);
}
if (attachment.getDescription().length() > 0) {
holder.getVideoUrl().setText(attachment.getDescription());
holder.getVideoUrl().setVisibility(View.VISIBLE);
((ViewGroup) holder.getVideoTitle().getParent()).setVisibility(View.VISIBLE);
}
holder.getPostVideoPlay().setVisibility(View.VISIBLE);
}
if (stream.getMessage().length() == 0 && media.getAlt().length() > 0) {
holder.getMessage().setText(media.getAlt());
holder.getMessage().setVisibility(View.VISIBLE);
} else if (stream.getMessage().length() == 0 && stream.getAttachment().getCaption().length() > 0) {
holder.getMessage().setText(stream.getAttachment().getCaption());
holder.getMessage().setVisibility(View.VISIBLE);
}
}
}
use of com.abewy.android.apps.klyph.core.fql.Media 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;
}
}
Aggregations