use of chat.rocket.core.models.WebContentParsedUrl in project Rocket.Chat.Android by RocketChat.
the class RocketChatMessageUrlsLayout method appendUrlView.
private void appendUrlView(WebContent webContent, boolean autoloadImages) {
final String url = webContent.getUrl();
addMessageInlineImage(webContent, autoloadImages, url);
// see Rocket.Chat:packages/rocketchat-oembed/client/oembedUrlWidget.coffee
final Map<WebContentMeta.Type, WebContentMeta> webContentMetaMap = webContent.getMetaMap();
if (webContentMetaMap == null || webContentMetaMap.size() == 0) {
return;
}
final String imageURL = webContent.getMetaImage();
WebContentParsedUrl parsedUrl = webContent.getParsedUrl();
String host = parsedUrl != null ? parsedUrl.getHost() : null;
View embedUrl = inflater.inflate(R.layout.message_inline_embed_url, this, false);
((TextView) embedUrl.findViewById(R.id.hostname)).setText(host);
((TextView) embedUrl.findViewById(R.id.title)).setText(webContent.getMetaTitle());
((TextView) embedUrl.findViewById(R.id.description)).setText(removeQuote(webContent.getMetaDescription()));
final SimpleDraweeView image = (SimpleDraweeView) embedUrl.findViewById(R.id.image);
if (TextUtils.isEmpty(imageURL)) {
image.setVisibility(View.GONE);
} else {
FrescoHelper.setupDraweeAndLoadImage(imageURL, image);
image.setVisibility(View.VISIBLE);
}
embedUrl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getContext().startActivity(intent);
}
});
addView(embedUrl);
}
Aggregations