urbanairship-core/src/main/java/com/urbanairship/messagecenter/MessageFragment.java
private void ensureView(View view) {
        if (webView != null) {
            return;
        }

        progressBar = view.findViewById(android.R.id.progress);
        if (progressBar == null) {
            throw new RuntimeException("Your content must have a progress View whose id attribute is 'android.R.id.progress'");
        }

        webView = view.findViewById(android.R.id.message);
        if (webView == null) {
            throw new RuntimeException("Your content must have a UAWebView whose id attribute is 'android.R.id.message'");
        }

        errorPage = view.findViewById(R.id.error);

        webView.setAlpha(0);

        // Set a custom RichPushWebViewClient view client to listen for the page finish
        // Note: UAWebViewClient is required to load the proper auth and to
        // inject the Urban Airship Javascript interface.  When overriding any methods
        // make sure to call through to the super's implementation.
        webView.setWebViewClient(new UAWebViewClient() {
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);

                if (error != null) {
                    showErrorPage(ERROR_DISPLAYING_MESSAGE);
                } else if (message != null) {
                    message.markRead();
                    showMessage();
                }
            }

            @Override
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                if (message != null && failingUrl != null && failingUrl.equals(message.getMessageBodyUrl())) {
                    error = errorCode;
                }
            }
        });

        webView.setWebChromeClient(new UAWebChromeClient(getActivity()) {
            @Override
            public Bitmap getDefaultVideoPoster() {

                // Re-enable hardware rending if we detect a video in the message
                if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
                    webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
                }

                return super.getDefaultVideoPoster();
            }
        });

        // Workaround render issue with older android devices
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        }


        retryButton = view.findViewById(R.id.retry_button);
        if (retryButton != null) {
            retryButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    retry();
                }
            });
        }

        errorMessage = view.findViewById(R.id.error_message);
    }
/**
     * Ensures that the view contains a web view, progress view, and a error page.
     *
     * @param view The content view.
     */
Ensures that the view contains a web view, progress view, and a error page.
@param view The content view.
Ensures that the view contains a web view progress view and a error page . @param view The content view .
private void ensureView(View view) {
        if (webView != null) {
            return;
        }
        progressBar = view.findViewById(android.R.id.progress);
        if (progressBar == null) {
            throw new RuntimeException("Your content must have a progress View whose id attribute is 'android.R.id.progress'");
        }
        webView = view.findViewById(android.R.id.message);
        if (webView == null) {
            throw new RuntimeException("Your content must have a UAWebView whose id attribute is 'android.R.id.message'");
        }
        errorPage = view.findViewById(R.id.error);
        webView.setAlpha(0);
        webView.setWebViewClient(new UAWebViewClient() {
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                if (error != null) {
                    showErrorPage(ERROR_DISPLAYING_MESSAGE);
                } else if (message != null) {
                    message.markRead();
                    showMessage();
                }
            }
            @Override
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                if (message != null && failingUrl != null && failingUrl.equals(message.getMessageBodyUrl())) {
                    error = errorCode;
                }
            }
        });
        webView.setWebChromeClient(new UAWebChromeClient(getActivity()) {
            @Override
            public Bitmap getDefaultVideoPoster() {
                if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
                    webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
                }
                return super.getDefaultVideoPoster();
            }
        });
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        }
        retryButton = view.findViewById(R.id.retry_button);
        if (retryButton != null) {
            retryButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    retry();
                }
            });
        }
        errorMessage = view.findViewById(R.id.error_message);
    }
private void ensureView ( View view ) { if ( webView != null ) { return ; } progressBar = view . findViewById ( android . R . id . progress ) ; if ( progressBar == null ) { throw new RuntimeException ( "Your content must have a progress View whose id attribute is 'android.R.id.progress'" ) ; } webView = view . findViewById ( android . R . id . message ) ; if ( webView == null ) { throw new RuntimeException ( "Your content must have a UAWebView whose id attribute is 'android.R.id.message'" ) ; } errorPage = view . findViewById ( R . id . error ) ; webView . setAlpha ( 0 ) ; webView . setWebViewClient ( new UAWebViewClient ( ) { @ Override public void onPageFinished ( WebView view , String url ) { super . onPageFinished ( view , url ) ; if ( error != null ) { showErrorPage ( ERROR_DISPLAYING_MESSAGE ) ; } else if ( message != null ) { message . markRead ( ) ; showMessage ( ) ; } } @ Override public void onReceivedError ( WebView view , int errorCode , String description , String failingUrl ) { if ( message != null && failingUrl != null && failingUrl . equals ( message . getMessageBodyUrl ( ) ) ) { error = errorCode ; } } } ) ; webView . setWebChromeClient ( new UAWebChromeClient ( getActivity ( ) ) { @ Override public Bitmap getDefaultVideoPoster ( ) { if ( Build . VERSION . SDK_INT < Build . VERSION_CODES . LOLLIPOP ) { webView . setLayerType ( View . LAYER_TYPE_HARDWARE , null ) ; } return super . getDefaultVideoPoster ( ) ; } } ) ; if ( Build . VERSION . SDK_INT < Build . VERSION_CODES . LOLLIPOP ) { webView . setLayerType ( View . LAYER_TYPE_SOFTWARE , null ) ; } retryButton = view . findViewById ( R . id . retry_button ) ; if ( retryButton != null ) { retryButton . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { retry ( ) ; } } ) ; } errorMessage = view . findViewById ( R . id . error_message ) ; }
Ensures that the view contains a web view, progress view, and a error page.
Ensures that the view contains a web view progress view and a error page .
// Set a custom RichPushWebViewClient view client to listen for the page finish // Note: UAWebViewClient is required to load the proper auth and to // inject the Urban Airship Javascript interface.  When overriding any methods // make sure to call through to the super's implementation. // Re-enable hardware rending if we detect a video in the message // Workaround render issue with older android devices