Example usage for android.view InflateException getLocalizedMessage

List of usage examples for android.view InflateException getLocalizedMessage

Introduction

In this page you can find the example usage for android.view InflateException getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:com.xiaoxin.apktools.view.CustomWebViewDialog.java

@NonNull
@Override/*from   w  w w.j  av  a 2s .c o  m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final View customView;
    try {
        customView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_webview, null);
    } catch (InflateException e) {
        throw new IllegalStateException("This device does not support Web Views.");
    }

    String dialogTitle = getArguments().getString("dialogTitle");
    AlertDialog dialog = new AlertDialog.Builder(getActivity()).setTitle(dialogTitle).setView(customView)
            .setPositiveButton(android.R.string.ok, null).show();

    final WebView webView = (WebView) customView.findViewById(R.id.webview);
    webView.getSettings().setDefaultTextEncodingName("utf-8");
    try {
        String htmlFileName = getArguments().getString("htmlFileName");
        StringBuilder buf = new StringBuilder();
        InputStream json = getActivity().getAssets().open(htmlFileName);
        BufferedReader in = new BufferedReader(new InputStreamReader(json, "UTF-8"));
        String str;
        while ((str = in.readLine()) != null)
            buf.append(str);
        in.close();

        final int accentColor = getArguments().getInt("accentColor");
        String formatLodString = buf.toString()
                .replace("{style-placeholder}", "body { background-color: #ffffff; color: #000; }")
                .replace("{link-color}", colorToHex(shiftColor(accentColor, true)))
                .replace("{link-color-active}", colorToHex(accentColor));
        webView.loadDataWithBaseURL(null, formatLodString, "text/html", "UTF-8", null);
    } catch (Throwable e) {
        webView.loadData("<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", "UTF-8");
    }
    return dialog;
}

From source file:name.gudong.translate.widget.WebDialog.java

@NonNull
@Override//  w ww .ja v a2 s . c  o m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final View customView;
    try {
        customView = LayoutInflater.from(getActivity()).inflate(R.layout.layout_about_dialog, null);
    } catch (InflateException e) {
        throw new IllegalStateException("This device does not support Web Views.");
    }

    String dialogTitle = getArguments().getString("dialogTitle");
    String neutralText = getArguments().getString("neutralText");
    String positiveText = getArguments().getString("positiveText");
    neutralText = TextUtils.isEmpty(neutralText) ? "" : neutralText;
    positiveText = TextUtils.isEmpty(neutralText) ? getString(android.R.string.ok) : positiveText;
    AlertDialog dialog = new AlertDialog.Builder(getActivity()).setTitle(dialogTitle).setView(customView)
            .setNeutralButton(neutralText, mNeutralClickCallback)
            .setPositiveButton(positiveText, mPositiveClickCallback).show();

    final WebView webView = (WebView) customView.findViewById(R.id.webview);
    webView.getSettings().setDefaultTextEncodingName("utf-8");
    try {
        String htmlFileName = getArguments().getString("htmlFileName");
        StringBuilder buf = new StringBuilder();
        InputStream json = getActivity().getAssets().open(htmlFileName);
        BufferedReader in = new BufferedReader(new InputStreamReader(json, "UTF-8"));
        String str;
        while ((str = in.readLine()) != null)
            buf.append(str);
        in.close();

        final int accentColor = getArguments().getInt("accentColor");
        String formatLodString = buf.toString()
                .replace("{style-placeholder}", "body { background-color: #ffffff; color: #000; }")
                .replace("{link-color}", colorToHex(shiftColor(accentColor, true)))
                .replace("{link-color-active}", colorToHex(accentColor));
        webView.loadDataWithBaseURL(null, formatLodString, "text/html", "UTF-8", null);
    } catch (Throwable e) {
        webView.loadData("<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", "UTF-8");
    }
    return dialog;
}

From source file:com.gudong.appkit.ui.fragment.CustomWebViewDialog.java

@NonNull
@Override//from  www.  j  a v  a2  s . c  om
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final View customView;
    try {
        customView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_webview, null);
    } catch (InflateException e) {
        throw new IllegalStateException("This device does not support Web Views.");
    }

    String dialogTitle = getArguments().getString("dialogTitle");
    String neutralText = getArguments().getString("neutralText");
    String positiveText = getArguments().getString("positiveText");
    neutralText = TextUtils.isEmpty(neutralText) ? "" : neutralText;
    positiveText = TextUtils.isEmpty(neutralText) ? getString(android.R.string.ok) : positiveText;
    AlertDialog dialog = new AlertDialog.Builder(getActivity()).setTitle(dialogTitle).setView(customView)
            .setNeutralButton(neutralText, mNeutralClickCallback)
            .setPositiveButton(positiveText, mPositiveClickCallback).show();

    final WebView webView = (WebView) customView.findViewById(R.id.webview);
    webView.getSettings().setDefaultTextEncodingName("utf-8");
    try {
        String htmlFileName = getArguments().getString("htmlFileName");
        StringBuilder buf = new StringBuilder();
        InputStream json = getActivity().getAssets().open(htmlFileName);
        BufferedReader in = new BufferedReader(new InputStreamReader(json, "UTF-8"));
        String str;
        while ((str = in.readLine()) != null)
            buf.append(str);
        in.close();

        final int accentColor = getArguments().getInt("accentColor");
        String formatLodString = buf.toString()
                .replace("{style-placeholder}", "body { background-color: #ffffff; color: #000; }")
                .replace("{link-color}", colorToHex(shiftColor(accentColor, true)))
                .replace("{link-color-active}", colorToHex(accentColor));
        webView.loadDataWithBaseURL(null, formatLodString, "text/html", "UTF-8", null);
    } catch (Throwable e) {
        webView.loadData("<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", "UTF-8");
    }
    return dialog;
}

From source file:com.yang.bruce.mumuxi.util.WebDialog.java

@NonNull
@Override//from   w  w  w  .j  a v  a 2  s  . c  om
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final View customView;
    try {
        customView = LayoutInflater.from(getActivity()).inflate(R.layout.layout_about_dialog, null);
    } catch (InflateException e) {
        throw new IllegalStateException("This device does not support Web Views.");
    }

    String dialogTitle = getArguments().getString("dialogTitle");
    String neutralText = getArguments().getString("neutralText");
    String positiveText = getArguments().getString("positiveText");
    neutralText = TextUtils.isEmpty(neutralText) ? "" : neutralText;
    positiveText = TextUtils.isEmpty(neutralText) ? getString(android.R.string.ok) : positiveText;
    AlertDialog dialog = new AlertDialog.Builder(getActivity()).setTitle(dialogTitle).setView(customView)
            .setNeutralButton(neutralText, mNeutralClickCallback)
            .setPositiveButton(positiveText, mPositiveClickCallback).show();

    final WebView webView = (WebView) customView.findViewById(R.id.webview);
    setWebView(webView, customView.getContext());
    try {
        String htmlFileName = getArguments().getString("htmlFileName");
        StringBuilder buf = new StringBuilder();
        InputStream json = getActivity().getAssets().open(htmlFileName);
        BufferedReader in = new BufferedReader(new InputStreamReader(json, "UTF-8"));
        String str;
        while ((str = in.readLine()) != null)
            buf.append(str);
        in.close();

        final int accentColor = getArguments().getInt("accentColor");
        String formatLodString = buf.toString()
                .replace("{style-placeholder}", "body { background-color: #ffffff; color: #000; }")
                .replace("{link-color}", colorToHex(shiftColor(accentColor, true)))
                .replace("{link-color-active}", colorToHex(accentColor));
        webView.loadDataWithBaseURL(null, formatLodString, "text/html", "UTF-8", null);
    } catch (Throwable e) {
        webView.loadData("<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", "UTF-8");
    }
    return dialog;
}