use of com.abewy.android.apps.klyph.core.fql.Attachment 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.Attachment 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