I’m trying to show all the twitter blockquotes in a webview. The tweets are rendering properly. But, Twitter videos are not showing properly. Sometimes, it shows with the text along with a huge space and sometimes just the space. Below is my code used to load twitter blockquotes in a webview:
public static void showTweetsinWebview(String embedUrl, TweetViewContainer tweetContainer, LinearLayout container, BaseFragment.OnInlinelinkClickListner listener, Activity activity, Fragment fragment) {
if (activity != null && container != null && fragment != null && embedUrl != null) {
if (tweetContainer == null) {
tweetContainer = new TweetViewContainer(activity);
container.addView(tweetContainer);
}
VideoEnabledWebview vWebview = initWebview(activity, fragment);
ProgressBar progressBar = createDynamicLoader(activity, container);
if (embedUrl != null) {
String html = "<!DOCTYPE html><html> <head> \n" +
"\n" +
"<script async src =\"https://platform.twitter.com/widgets.js\" \n" +
"charset=\"utf-8\"></script></head>" +
" <body>" + embedUrl + "</body> </html> ";
vWebview.setWebUrl(html);
initWebviewListeners(vWebview, listener, progressBar, activity);
// vWebview.loadDataWithBaseURL("https://twitter.com", html, "text/html", "utf-8", null);
vWebview.loadData(html, "text/html", "UTF-8");
tweetContainer.setBackgroundResource(0);
tweetContainer.addView(vWebview);
tweetContainer.setTag(embedUrl);
}
}
}
Also, I tried testing the html content in W3Schools and even in this site, it is rendering properly. When the same code displays tweets properly, why videos aren’t rendering properly.