Example usage for android.webkit WebViewFragment getWebView

List of usage examples for android.webkit WebViewFragment getWebView

Introduction

In this page you can find the example usage for android.webkit WebViewFragment getWebView.

Prototype

public WebView getWebView() 

Source Link

Document

Gets the WebView.

Usage

From source file:com.ohso.omgubuntu.CommentsActivity.java

@SuppressLint("SetJavaScriptEnabled")
@Override/*from  ww  w  .  j  a v a  2s  .  c o  m*/
public void onCreate(Bundle instance) {
    super.onCreate(instance);
    setContentView(R.layout.fragment_comments);
    setTitle("Comments");
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    mArticlePath = getIntent().getStringExtra(COMMENTS_URL);
    mIdentifier = getIntent().getStringExtra(COMMENTS_IDENTIFIER);
    if (mArticlePath == null)
        finish();
    mFragmentManager = getSupportFragmentManager();

    // Setting up the default Disqus WebView

    WebViewFragment commentsFragment;

    if (instance != null) {
        commentsFragment = (WebViewFragment) getSupportFragmentManager().findFragmentByTag("comments");
        commentView = commentsFragment.getWebView();
    } else {
        commentsFragment = new WebViewFragment();
        mFragmentManager.beginTransaction()
                .replace(R.id.comments_fragment_container, commentsFragment, "comments").commit();
        commentView = new WebView(this);
        commentsFragment.setWebView(commentView);
    }
    if (commentView == null)
        commentView = new WebView(this);
    commentView.getSettings().setJavaScriptEnabled(true);
    commentView.getSettings().setSupportMultipleWindows(true);
    commentView.setWebChromeClient(new WebFragmentClient(this));
    commentView.setWebViewClient(new WebClient(this));
    if (instance == null)
        setContents(mArticlePath);
}