Forked from bichotll/load_disqus_comments_android.java
Last active
August 29, 2015 14:09
-
-
Save anugotta/6a616b14bb34764cb09c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_comments); | |
String htmlComments = getHtmlComment("yourId", "yourShortName"); | |
webDisqus = (WebView) findViewById(R.id.disqus); | |
// set up disqus | |
WebSettings webSettings2 = webDisqus.getSettings(); | |
webSettings2.setJavaScriptEnabled(true); | |
webSettings2.setBuiltInZoomControls(true); | |
webDisqus.requestFocusFromTouch(); | |
webDisqus.setWebViewClient(new WebViewClient()); | |
webDisqus.setWebChromeClient(new WebChromeClient()); | |
webDisqus.loadData(htmlComments, "text/html", null); | |
} | |
public String getHtmlComment(String idPost, String shortName) { | |
return "<div id='disqus_thread'></div>" | |
+ "<script type='text/javascript'>" | |
+ "var disqus_identifier = '" | |
+ idPost | |
+ "';" | |
+ "var disqus_shortname = '" | |
+ shortName | |
+ "';" | |
+ " (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;" | |
+ "dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';" | |
+ "(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();" | |
+ "</script>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment