public class

ArticleWebView

extends WebView
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.AbsoluteLayout
         ↳ android.webkit.WebView
           ↳ com.salesforce.android.knowledge.ui.ArticleWebView

Class Overview

A View that displays ArticleDetails as web pages. See WebView for details on the underlying implementation.

Can be used to view KnowledgeArticles directly without having to navigate through the knowledge tree.

NOTE Be sure to cleanup the WebView after you no longer need it to prevent memory leaks by calling cleanup().

Summary

Nested Classes
interface ArticleWebView.OnLinkSelectedListener Interface for handling events when a user selects a link within an article web view. 
interface ArticleWebView.WebResourceErrorListener Callback triggered on WebResourceErrors while loading the webview. 
[Expand]
Inherited Constants
From class android.webkit.WebView
From class android.view.ViewGroup
From class android.view.View
Fields
protected ArticleWebViewConfiguration mArticleConfiguration
protected ArticleWebView.OnLinkSelectedListener mOnLinkSelectedListener
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
ArticleWebView(Context context)
Constructs a new WebView with a Context object.
ArticleWebView(Context context, AttributeSet attrs)
Constructs a new WebView with layout parameters.
ArticleWebView(Context context, AttributeSet attrs, int defStyleAttr)
Constructs a new WebView with layout parameters and a default style.
Public Methods
void cleanup()
Detaches the WebView from it's parent and destroys it to prevent memory leaks.
ArticleWebViewConfiguration getArticleConfiguration()
Returns the current ArticleWebViewConfiguration used in presenting the article.
ArticleDetails getArticleDetails()
Returns the current article details being displayed.
boolean onTouchEvent(MotionEvent ev)
Overridden to support scrolling as a child of CoordinatorLayout and behave appropriately with com.salesforce.android.knowledge.ui.internal.views.TintedCollapsingToolbarLayout

The scrolling math was adopted from https://github.com/takahirom/webview-in-coordinatorlayout/blob/master/app/src/main/java/com/github/takahirom/webview_in_coodinator_layout/NestedWebView.java

void setOnLinkSelectedListener(ArticleWebView.OnLinkSelectedListener onLinkSelectedListener)
Assigns the OnLinkSelectedListener.
Async<Void> showArticle(ArticleDetails details, ArticleWebViewConfiguration configuration)
Displays the given ArticleDetails in the Webview
Protected Methods
void onDetachedFromWindow()
This is called when the view is detached from a window.
[Expand]
Inherited Methods
From class android.webkit.WebView
From class android.widget.AbsoluteLayout
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.ViewGroup.OnHierarchyChangeListener
From interface android.view.ViewManager
From interface android.view.ViewParent
From interface android.view.ViewTreeObserver.OnGlobalFocusChangeListener
From interface android.view.accessibility.AccessibilityEventSource

Fields

protected ArticleWebViewConfiguration mArticleConfiguration

protected ArticleWebView.OnLinkSelectedListener mOnLinkSelectedListener

Public Constructors

public ArticleWebView (Context context)

Constructs a new WebView with a Context object.

Parameters
context a Context object used to access application assets

public ArticleWebView (Context context, AttributeSet attrs)

Constructs a new WebView with layout parameters.

Parameters
context a Context object used to access application assets
attrs an AttributeSet passed to our parent

public ArticleWebView (Context context, AttributeSet attrs, int defStyleAttr)

Constructs a new WebView with layout parameters and a default style.

Parameters
context a Context object used to access application assets
attrs an AttributeSet passed to our parent
defStyleAttr an attribute in the current theme that contains a reference to a style resource that supplies default values for the view. Can be 0 to not look for defaults.

Public Methods

public void cleanup ()

Detaches the WebView from it's parent and destroys it to prevent memory leaks.

public ArticleWebViewConfiguration getArticleConfiguration ()

Returns the current ArticleWebViewConfiguration used in presenting the article.

Returns
  • ArticleWebViewConfiguration currently used.

public ArticleDetails getArticleDetails ()

Returns the current article details being displayed.

Returns
  • ArticleDetails being displayed.

public boolean onTouchEvent (MotionEvent ev)

Overridden to support scrolling as a child of CoordinatorLayout and behave appropriately with com.salesforce.android.knowledge.ui.internal.views.TintedCollapsingToolbarLayout

The scrolling math was adopted from https://github.com/takahirom/webview-in-coordinatorlayout/blob/master/app/src/main/java/com/github/takahirom/webview_in_coodinator_layout/NestedWebView.java

public void setOnLinkSelectedListener (ArticleWebView.OnLinkSelectedListener onLinkSelectedListener)

Assigns the OnLinkSelectedListener.

Parameters
onLinkSelectedListener Listener to assign.

public Async<Void> showArticle (ArticleDetails details, ArticleWebViewConfiguration configuration)

Displays the given ArticleDetails in the Webview

Parameters
details The article details to display in the webview.
configuration Input to the webview and configuration options for controlling the behavior.
Returns
  • An Async used to report completion status and errors.

Protected Methods

protected void onDetachedFromWindow ()

This is called when the view is detached from a window. At this point it no longer has a surface for drawing.