Example usage for android.webkit WebView loadData

List of usage examples for android.webkit WebView loadData

Introduction

In this page you can find the example usage for android.webkit WebView loadData.

Prototype

public void loadData(String data, @Nullable String mimeType, @Nullable String encoding) 

Source Link

Document

Loads the given data into this WebView using a 'data' scheme URL.

Usage

From source file:weathernotificationservice.wns.activities.MainActivity.java

private void aboutDialog() {
    AlertDialog.Builder alert = new AlertDialog.Builder(this);
    alert.setTitle("Weather Pop");
    final WebView webView = new WebView(this);
    String about = "<p>A weather app, created for you, that provides the functionality of secure mobile notifications connecting you with your family and friends at the touch of your fingertips.</p>"
            + "<p>Based on Forecatie developed by <a href='mailto:t.martykan@gmail.com'>Tomas Martykan</a></p>"
            + "<p>Data provided by <a href='http://openweathermap.org/'>OpenWeatherMap</a>, under the <a href='http://creativecommons.org/licenses/by-sa/2.0/'>Creative Commons license</a>"
            + "<p>Icons are <a href='https://erikflowers.github.io/weather-icons/'>Weather Icons</a>, by <a href='http://www.twitter.com/artill'>Lukas Bischoff</a> and <a href='http://www.twitter.com/Erik_UX'>Erik Flowers</a>, under the <a href='http://scripts.sil.org/OFL'>SIL OFL 1.1</a> licence.";
    ;/*from   w  w  w .  ja v  a  2s. c  o m*/
    TypedArray ta = obtainStyledAttributes(new int[] { android.R.attr.textColorPrimary, R.attr.colorAccent });
    String textColor = String.format("#%06X", (0xFFFFFF & ta.getColor(0, Color.BLACK)));
    String accentColor = String.format("#%06X", (0xFFFFFF & ta.getColor(1, Color.BLUE)));
    ta.recycle();
    about = "<style media=\"screen\" type=\"text/css\">" + "body {\n" + "    color:" + textColor + ";\n" + "}\n"
            + "a:link {color:" + accentColor + "}\n" + "</style>" + about;
    webView.setBackgroundColor(Color.TRANSPARENT);
    webView.loadData(about, "text/html", "UTF-8");
    alert.setView(webView, 32, 0, 32, 0);
    alert.setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {

        }
    });
    alert.show();
}

From source file:com.doge.dyjw.AboutFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    WebView webView = (WebView) getActivity().findViewById(R.id.webView);
    String html = "<html><head><title></title></head><body style='margin:16px; background:#efefef;'>\n"
            + "<h1> Android App</h1>\n" + "<hr />\n" + "<p>\n"
            + "An Android application for students of NEPU to use the JiaoWuGuanLi system on Android.<br />\n"
            + "??\n" + "</p>\n" + "<p>\n"
            + "?" + getString(R.string.versionName)
            + "??<a href='http://weibo.com/hiy0u'>?</a>"
            + "APP<a href='http://dyjw.fly-kite.com/'>http://dyjw.fly-kite.com/</a><br />\n"
            + "APK<a href='http://dyjw.fly-kite.com/download/'>http://dyjw.fly-kite.com/download/</a><br />\n"
            + "??GPLv3???\n" + "</p>\n" + "<h1>?</h1>\n" + "<hr />\n" + "<p>\n"
            + "APPJsoup?????????\n"
            + "</p>\n" + "<h1></h1>\n" + "<hr />\n" + "<p>\n"
            + "??????<br />\n"
            + "??????????\n"
            + "</p>\n" + "<h1>??</h1>\n" + "<hr />\n" + "<p>\n"
            + "?<br />\n"
            + "APP????DogeFlyKite@gmail.com\n" + "</p>\n"
            + "<h1>??</h1>\n" + "<hr />\n" + "<p style='background:#dfdfdf;'>\n"
            + "GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007<br />\n" + "<br />\n"
            + "Copyright (C) 2015 Doge Studio<br />\n" + "<br />\n"
            + "This program comes with ABSOLUTELY NO WARRANTY.<br />\n"
            + "This is free software, and you are welcome to redistribute it under certain conditions.\n"
            + "</p>\n" + "<br />\n" + "</body>\n" + "</html>";
    Log.d("", html);
    webView.getSettings().setDefaultTextEncodingName("utf-8");
    webView.loadData(html, "text/html; charset=utf-8;", null);
}

From source file:ir.actfun.toofan.activities.MainActivity.java

private void aboutDialog() {
    AlertDialog.Builder alert = new AlertDialog.Builder(this);
    alert.setTitle("Toofan");
    alert.setIcon(R.mipmap.ic_launcher);
    final WebView webView = new WebView(this);
    String about = "<p>A lightweight, Materialized and Precise weather app.</p>"
            + "<p>Developed by <a href='mailto:aligholami7596@gmail.com'>Ali Gholami</a></p>"
            + "Graphical Design and Support by <a href='http://www.mtabatabaei.com/'>Mohamad Tabatabaei</a></p>"
            + "co-developers: <a href='mailto:khajavi_mohamad@yahoo.com'>Mohamad Khajavi</a></p>  <a href='mailto:faezehsalmanfar@gmail.com'>Faezeh Salmanfar</a></p>"
            + "<p>Data provided by <a href='http://openweathermap.org/'>OpenWeatherMap</a>, under the <a href='http://creativecommons.org/licenses/by-sa/2.0/'>Creative Commons license</a>"
            + "<p>Icons are <a href='https://erikflowers.github.io/weather-icons/'>Weather Icons</a>, by <a href='http://www.twitter.com/artill'>Lukas Bischoff</a> and <a href='http://www.twitter.com/Erik_UX'>Erik Flowers</a>, under the <a href='http://scripts.sil.org/OFL'>SIL OFL 1.1</a> licence.";
    if (darkTheme) {
        // Style text color for dark theme
        about = "<style media=\"screen\" type=\"text/css\">" + "body {\n" + "    color:white;\n" + "}\n"
                + "a:link {color:cyan}\n" + "</style>" + about;
    }//from   w  w  w  .  j av  a2s.  c  o  m
    webView.setBackgroundColor(Color.TRANSPARENT);
    webView.loadData(about, "text/html", "UTF-8");
    alert.setView(webView, 32, 0, 32, 0);
    alert.setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {

        }
    });
    alert.show();
}

From source file:jvm.ncatz.netbour.ActivityAbout.java

@NonNull
@Override//from   w  w  w  .  j  a  va  2  s  .co m
protected MaterialAboutList getMaterialAboutList(@NonNull Context context) {
    count = 0;

    MaterialAboutCard.Builder builderCardApp = new MaterialAboutCard.Builder();
    builderCardApp.title(R.string.aboutApp);
    MaterialAboutCard.Builder builderCardAuthor = new MaterialAboutCard.Builder();
    builderCardAuthor.title(R.string.aboutAuthor);
    MaterialAboutCard.Builder builderCardSocial = new MaterialAboutCard.Builder();
    builderCardSocial.title(R.string.aboutSocial);
    MaterialAboutCard.Builder builderCardOther = new MaterialAboutCard.Builder();
    builderCardOther.title(R.string.aboutOther);

    IconicsDrawable iconAppVersion = new IconicsDrawable(this).icon(MaterialDesignIconic.Icon.gmi_info_outline)
            .color(ContextCompat.getColor(this, R.color.grey_800)).sizeDp(20);
    IconicsDrawable iconAppRepository = new IconicsDrawable(this).icon(MaterialDesignIconic.Icon.gmi_github_box)
            .color(ContextCompat.getColor(this, R.color.grey_800)).sizeDp(20);
    IconicsDrawable iconAppLicenses = new IconicsDrawable(this).icon(MaterialDesignIconic.Icon.gmi_file)
            .color(ContextCompat.getColor(this, R.color.grey_800)).sizeDp(20);
    IconicsDrawable iconAuthorEmail = new IconicsDrawable(this).icon(MaterialDesignIconic.Icon.gmi_email)
            .color(ContextCompat.getColor(this, R.color.grey_800)).sizeDp(20);
    IconicsDrawable iconAuthorWeb = new IconicsDrawable(this).icon(MaterialDesignIconic.Icon.gmi_view_web)
            .color(ContextCompat.getColor(this, R.color.grey_800)).sizeDp(20);
    IconicsDrawable iconSocialGithub = new IconicsDrawable(this).icon(MaterialDesignIconic.Icon.gmi_github_alt)
            .color(ContextCompat.getColor(this, R.color.grey_800)).sizeDp(20);
    IconicsDrawable iconSocialLinkedin = new IconicsDrawable(this).icon(MaterialDesignIconic.Icon.gmi_linkedin)
            .color(ContextCompat.getColor(this, R.color.grey_800)).sizeDp(20);
    IconicsDrawable iconSocialStack = new IconicsDrawable(this)
            .icon(MaterialDesignIconic.Icon.gmi_stackoverflow)
            .color(ContextCompat.getColor(this, R.color.grey_800)).sizeDp(20);
    IconicsDrawable iconSocialTwitter = new IconicsDrawable(this).icon(MaterialDesignIconic.Icon.gmi_twitter)
            .color(ContextCompat.getColor(this, R.color.grey_800)).sizeDp(20);
    IconicsDrawable iconOtherBugs = new IconicsDrawable(this).icon(MaterialDesignIconic.Icon.gmi_bug)
            .color(ContextCompat.getColor(this, R.color.grey_800)).sizeDp(20);

    MaterialAboutTitleItem itemAppName = new MaterialAboutTitleItem(getString(R.string.app_name),
            ContextCompat.getDrawable(this, R.drawable.logo160));
    MaterialAboutActionItem itemAppVersion = new MaterialAboutActionItem(getString(R.string.app_version_title),
            getString(R.string.app_version_sub), iconAppVersion, new MaterialAboutItemOnClickListener() {
                @Override
                public void onClick(boolean b) {
                    count++;
                    if (count == 7) {
                        try {
                            stopPlaying();
                            player = MediaPlayer.create(ActivityAbout.this, R.raw.easteregg);
                            player.start();
                            count = 0;
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
            });
    MaterialAboutActionItem itemAppRepository = new MaterialAboutActionItem(
            getString(R.string.app_repository_title), getString(R.string.app_repository_sub), iconAppRepository,
            new MaterialAboutItemOnClickListener() {
                @Override
                public void onClick(boolean b) {
                    String url = "https://github.com/JMedinilla/Netbour";
                    openUrl(url);
                }
            });
    MaterialAboutActionItem itemAppLicenses = new MaterialAboutActionItem(
            getString(R.string.app_licenses_title), getString(R.string.app_licenses_sub), iconAppLicenses,
            new MaterialAboutItemOnClickListener() {
                @Override
                public void onClick(boolean b) {
                    DialogPlus dialogPlus = DialogPlus.newDialog(ActivityAbout.this).setGravity(Gravity.BOTTOM)
                            .setContentHolder(new ViewHolder(R.layout.licenses_dialog)).setCancelable(true)
                            .setExpanded(true, 600).create();

                    View view = dialogPlus.getHolderView();
                    FButton apacheButton = (FButton) view.findViewById(R.id.apacheButton);
                    FButton mitButton = (FButton) view.findViewById(R.id.mitButton);
                    WebView webView = (WebView) view.findViewById(R.id.licensesWeb);
                    apacheButton.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            try {
                                AssetManager am = getAssets();
                                InputStream is = am.open("apache");

                                Scanner s = new Scanner(is).useDelimiter("\\A");
                                String apache = s.hasNext() ? s.next() : "";

                                AlertDialog.Builder builder = new AlertDialog.Builder(ActivityAbout.this);
                                builder.setTitle(R.string.apache_title);
                                builder.setMessage(apache);
                                builder.create().show();
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                        }
                    });
                    mitButton.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            try {
                                AssetManager am = getAssets();
                                InputStream is = am.open("mit");

                                Scanner s = new Scanner(is).useDelimiter("\\A");
                                String mit = s.hasNext() ? s.next() : "";

                                AlertDialog.Builder builder = new AlertDialog.Builder(ActivityAbout.this);
                                builder.setTitle(R.string.mit_title);
                                builder.setMessage(mit);
                                builder.create().show();
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                        }
                    });
                    try {
                        AssetManager am = getAssets();
                        InputStream is = am.open("licenses.html");

                        webView.loadData(inputStreamToString(is), "text/html", "UTF-8");
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    dialogPlus.show();
                }
            });
    MaterialAboutTitleItem itemAuthorName = new MaterialAboutTitleItem(getString(R.string.author_name),
            ContextCompat.getDrawable(this, R.drawable.favicon));
    MaterialAboutActionItem itemAuthorEmail = new MaterialAboutActionItem(
            getString(R.string.author_email_title), getString(R.string.author_email_sub), iconAuthorEmail,
            new MaterialAboutItemOnClickListener() {
                @Override
                public void onClick(boolean b) {
                    sendEmail(getString(R.string.author_email_subject));
                }
            });
    MaterialAboutActionItem itemAuthorWeb = new MaterialAboutActionItem(getString(R.string.author_web_title),
            getString(R.string.author_web_sub), iconAuthorWeb, new MaterialAboutItemOnClickListener() {
                @Override
                public void onClick(boolean b) {
                    String url = "https://jvmedinilla.ncatz.com/";
                    openUrl(url);
                }
            });
    MaterialAboutActionItem itemSocialGithub = new MaterialAboutActionItem(
            getString(R.string.social_github_title), getString(R.string.social_github_sub), iconSocialGithub,
            new MaterialAboutItemOnClickListener() {
                @Override
                public void onClick(boolean b) {
                    String url = "https://github.com/JMedinilla";
                    openUrl(url);
                }
            });
    MaterialAboutActionItem itemSocialLinkedin = new MaterialAboutActionItem(
            getString(R.string.social_linkedin_title), getString(R.string.social_linkedin_sub),
            iconSocialLinkedin, new MaterialAboutItemOnClickListener() {
                @Override
                public void onClick(boolean b) {
                    String url = "https://www.linkedin.com/in/javier-medinilla-ag%C3%BCera-951749121/";
                    openUrl(url);
                }
            });
    MaterialAboutActionItem itemSocialStackoverflow = new MaterialAboutActionItem(
            getString(R.string.social_stack_title), getString(R.string.social_stack_sub), iconSocialStack,
            new MaterialAboutItemOnClickListener() {
                @Override
                public void onClick(boolean b) {
                    String url = "http://stackoverflow.com/users/7426526/jmedinilla?tab=profile";
                    openUrl(url);
                }
            });
    MaterialAboutActionItem itemSocialTwitter = new MaterialAboutActionItem(
            getString(R.string.social_twitter_title), getString(R.string.social_twitter_sub), iconSocialTwitter,
            new MaterialAboutItemOnClickListener() {
                @Override
                public void onClick(boolean b) {
                    String url = "https://twitter.com/JMedinillaDev";
                    openUrl(url);
                }
            });
    MaterialAboutActionItem itemOtherBugs = new MaterialAboutActionItem(getString(R.string.other_bug_title),
            getString(R.string.other_bug_sub), iconOtherBugs, new MaterialAboutItemOnClickListener() {
                @Override
                public void onClick(boolean b) {
                    sendEmail(getString(R.string.other_bug_subject));
                }
            });

    builderCardApp.addItem(itemAppName);
    builderCardApp.addItem(itemAppVersion);
    builderCardApp.addItem(itemAppRepository);
    builderCardApp.addItem(itemAppLicenses);
    builderCardAuthor.addItem(itemAuthorName);
    builderCardAuthor.addItem(itemAuthorEmail);
    builderCardAuthor.addItem(itemAuthorWeb);
    builderCardSocial.addItem(itemSocialGithub);
    builderCardSocial.addItem(itemSocialLinkedin);
    builderCardSocial.addItem(itemSocialStackoverflow);
    builderCardSocial.addItem(itemSocialTwitter);
    builderCardOther.addItem(itemOtherBugs);

    MaterialAboutList.Builder builderList = new MaterialAboutList.Builder();
    builderList.addCard(builderCardApp.build());
    builderList.addCard(builderCardAuthor.build());
    builderList.addCard(builderCardSocial.build());
    builderList.addCard(builderCardOther.build());

    return builderList.build();
}

From source file:net.idlesoft.android.apps.github.activities.CommitChangeViewer.java

@Override
public void onCreate(final Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.commit_view);

    mPrefs = getSharedPreferences(Hubroid.PREFS_NAME, 0);
    mEditor = mPrefs.edit();//from ww w.  ja va 2 s  . c o m

    mUsername = mPrefs.getString("username", "");
    mPassword = mPrefs.getString("password", "");

    mGapi.authenticate(mUsername, mPassword);

    ((ImageButton) findViewById(R.id.btn_search)).setOnClickListener(new OnClickListener() {
        public void onClick(final View v) {
            startActivity(new Intent(CommitChangeViewer.this, Search.class));
        }
    });

    final TextView title = (TextView) findViewById(R.id.tv_page_title);
    title.setText("Commit Diff");

    final Bundle extras = getIntent().getExtras();
    if (extras != null) {
        mRepositoryName = extras.getString("repo_name");
        mRepositoryOwner = extras.getString("repo_owner");
        try {
            mJson = new JSONObject(extras.getString("json"));

            /*
             * This new method of displaying file diffs was inspired by
             * iOctocat's approach. Thanks to Dennis Bloete (dbloete on
             * GitHub) for creating iOctocat and making me realize Android
             * needed some GitHub love too. ;-)
             */
            final WebView webView = (WebView) findViewById(R.id.wv_commitView_diff);

            /*
             * Prepare CSS for diff: Added lines are green, removed lines
             * are red, and the special lines that specify how many lines
             * were affected in the chunk are a light blue.
             */
            String content = "<style type=\"text/css\">" + "div {" + "margin-right: 100%25;"
                    + "font-family: monospace;" + "white-space: nowrap;" + "display: inline-block;" + "}"
                    + ".lines {" + "background-color: #EAF2F5;" + "}" + ".added {"
                    + "background-color: #DDFFDD;" + "}" + ".removed {" + "background-color: #FFDDDD;" + "}"
                    + "</style>";

            final String[] splitDiff = mJson.getString("diff").split("\n");
            for (int i = 0; i < splitDiff.length; i++) {
                // HTML encode any elements, else any diff containing
                // "<div>" or any HTML element will be interpreted as one by
                // the browser
                splitDiff[i] = TextUtils.htmlEncode(splitDiff[i]);

                // Replace all tabs with four non-breaking spaces (most
                // browsers truncate "\t+" to " ").
                splitDiff[i] = splitDiff[i].replaceAll("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");

                // Replace any sequence of two or more spaces with &nbsps
                // (most browsers truncate " +" to " ").
                splitDiff[i] = splitDiff[i].replaceAll("(?<= ) ", "&nbsp;");

                if (splitDiff[i].startsWith("@@")) {
                    splitDiff[i] = "<div class=\"lines\">".concat(splitDiff[i].concat("</div>"));
                } else if (splitDiff[i].startsWith("+")) {
                    splitDiff[i] = "<div class=\"added\">".concat(splitDiff[i].concat("</div>"));
                } else if (splitDiff[i].startsWith("-")) {
                    splitDiff[i] = "<div class=\"removed\">".concat(splitDiff[i].concat("</div>"));
                } else {
                    // Add an extra space before lines not beginning with
                    // "+" or "-" to make them line up properly
                    if (splitDiff[i].length() > 0) {
                        splitDiff[i] = "<div>&nbsp;".concat(splitDiff[i].substring(1).concat("</div>"));
                    }
                }
                content += splitDiff[i];
            }
            webView.loadData(content, "text/html", "UTF-8");

        } catch (final JSONException e) {
            e.printStackTrace();
        }
    }
}

From source file:com.max2idea.android.limbo.main.LimboActivity.java

public static void UIAlertHtml(String title, String html, Activity activity) {

    AlertDialog alertDialog;/*from   w  w  w . j  a  va2 s. c  o m*/
    alertDialog = new AlertDialog.Builder(activity).create();
    alertDialog.setTitle(title);
    WebView webview = new WebView(activity);
    webview.setBackgroundColor(Color.BLACK);
    webview.loadData("<font color=\"FFFFFF\">" + html + " </font>", "text/html", "UTF-8");
    alertDialog.setView(webview);
    alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            return;
        }
    });
    alertDialog.show();
}

From source file:com.max2idea.android.limbo.main.LimboActivity.java

public static void UIAlertLicense(String title, String html, final Activity activity) {

    AlertDialog alertDialog;/* w  w  w .  j ava 2  s. c  om*/
    alertDialog = new AlertDialog.Builder(activity).create();
    alertDialog.setTitle(title);
    WebView webview = new WebView(activity);
    webview.setBackgroundColor(Color.BLACK);
    webview.loadData("<font color=\"FFFFFF\">" + html + " </font>", "text/html", "UTF-8");
    alertDialog.setView(webview);

    alertDialog.setButton("I Acknowledge", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            if (isFirstLaunch()) {
                install();
                onHelp();
                onChangeLog();
            }
            setFirstLaunch();
            return;
        }
    });
    alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            if (isFirstLaunch()) {
                if (activity.getParent() != null) {
                    activity.getParent().finish();
                } else {
                    activity.finish();
                }
            }
        }
    });
    alertDialog.show();
}

From source file:com.openerp.support.listview.OEListViewAdapter.java

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    viewRow = convertView;/*from www  .  java 2s .  c om*/
    parentView = parent;
    LayoutInflater inflater = ((MainActivity) context).getLayoutInflater();
    if (viewRow == null) {
        viewRow = inflater.inflate(this.resource_id, parent, false);
    }
    row = this.rows.get(position);
    rowdata = row.getRow_data();
    for (final Integer control_id : controlClickHandler.keySet()) {
        viewRow.findViewById(control_id).setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                controlClickHandler.get(control_id).controlClicked(position, rows.get(position), viewRow);
            }
        });
    }

    for (int i = 0; i < this.to.length; i++) {
        final String key = from[i];
        if (booleanEvents.contains(from[i])) {
            handleBinaryBackground(row.getRow_id(), key, to[i], viewRow, position);
        } else if (backgroundChange.containsKey(key)) {
            String backFlag = rowdata.get(key).toString();
            if (!backFlag.equals("false")) {
                backFlag = "true";
            }
            int color = backgroundChange.get(key).get(backFlag);
            viewRow.findViewById(this.to[i]).setBackgroundColor(color);
            continue;
        } else if (imageCols.contains(from[i])) {
            String data = rowdata.get(from[i]).toString();
            if (!data.equals("false")) {
                ImageView imgView = (ImageView) viewRow.findViewById(this.to[i]);
                imgView.setImageBitmap(Base64Helper.getBitmapImage(context, data));
            }
        } else {
            TextView txvObj = null;
            WebView webview = null;
            if (!webViewControls.containsKey(this.from[i])) {
                txvObj = (TextView) viewRow.findViewById(this.to[i]);
            } else {
                if (webViewControls.get(this.from[i])) {
                    webview = (WebView) viewRow.findViewById(this.to[i]);
                    webview.getSettings().setJavaScriptEnabled(true);
                    webview.getSettings().setBuiltInZoomControls(true);
                } else {
                    txvObj = (TextView) viewRow.findViewById(this.to[i]);
                }
            }

            String key_col = this.from[i];
            String alt_key_col = key_col;
            if (key_col.contains("|")) {
                String[] splits = key_col.split("\\|");
                key_col = splits[0];
                alt_key_col = splits[1];
            }
            String data = rowdata.get(key_col).toString();
            if (data.equals("false") || TextUtils.isEmpty(data)) {
                data = rowdata.get(alt_key_col).toString();
            }
            if (this.cleanColumn.contains(key_col)) {
                data = HTMLHelper.htmlToString(data);
            }

            if (datecols.contains(key_col)) {
                if (date_format != null) {
                    data = OEDate.getDate(data, TimeZone.getDefault().getID(), date_format);
                } else {
                    data = OEDate.getDate(data, TimeZone.getDefault().getID());
                }
            }

            if (!data.equals("false")) {
                try {
                    StringBuffer inputdata = new StringBuffer();
                    JSONArray tmpData = new JSONArray(data);
                    for (int k = 0; k < tmpData.length(); k++) {
                        if (tmpData.get(k) instanceof JSONArray) {
                            if (tmpData.getJSONArray(k).length() == 2) {
                                inputdata.append(tmpData.getJSONArray(k).getString(1));
                                inputdata.append(",");
                            }
                        } else {
                            inputdata.append(tmpData.getString(0));
                            inputdata.append(",");
                        }
                    }
                    int index = inputdata.lastIndexOf(",");
                    if (index > 0) {
                        inputdata.deleteCharAt(index);
                    }
                    txvObj.setText(inputdata.toString());
                } catch (Exception e) {
                    if (this.toHtml.contains(key_col)) {
                        if (webViewControls.get(this.from[i])) {
                            String customHtml = data;
                            webview.loadData(customHtml, "text/html", "UTF-8");
                        } else {
                            txvObj.setText(HTMLHelper.stringToHtml(data));
                        }
                    } else {
                        txvObj.setText(data);
                    }

                }

            } else {
                txvObj.setText("");
            }
        }
    }
    if (this.canChangeBackground && !viewRow.isSelected()) {
        boolean flag = Boolean.parseBoolean(rowdata.get(conditionKey).toString());
        if (flag) {
            viewRow.setBackgroundResource(colors[1]);

        } else {
            viewRow.setBackgroundResource(colors[0]);
        }
    }
    if (viewListener != null) {
        viewRow = viewListener.listViewOnCreateListener(position, viewRow, this.rows.get(position));
    }

    return viewRow;
}

From source file:net.idlesoft.android.apps.github.activities.SingleActivityItem.java

@Override
public void onCreate(final Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.single_activity_item);

    mPrefs = getSharedPreferences(Hubroid.PREFS_NAME, 0);
    mEditor = mPrefs.edit();/*from   ww w . j a  v a  2 s  . co m*/

    ((ImageButton) findViewById(R.id.btn_search)).setOnClickListener(new OnClickListener() {
        public void onClick(final View v) {
            startActivity(new Intent(SingleActivityItem.this, Search.class));
        }
    });

    final Bundle extras = getIntent().getExtras();
    if (extras != null) {
        try {
            mJson = new JSONObject(extras.getString("item_json"));
            loadActivityItemBox();
            final WebView content = (WebView) findViewById(R.id.wv_single_activity_item_content);
            content.setWebViewClient(new WebViewClient() {
                public boolean shouldOverrideUrlLoading(final WebView view, final String url) {
                    if (url.startsWith("hubroid://")) {
                        final String parts[] = url.substring(10).split("/");
                        if (parts[0].equals("showCommit")) {
                            final Intent intent = new Intent(SingleActivityItem.this, Commit.class);
                            intent.putExtra("repo_owner", parts[1]);
                            intent.putExtra("repo_name", parts[2]);
                            intent.putExtra("commit_sha", parts[3]);
                            startActivity(intent);
                        } else if (parts[0].equals("showRepo")) {
                            final Intent intent = new Intent(SingleActivityItem.this, Repository.class);
                            intent.putExtra("repo_owner", parts[1]);
                            intent.putExtra("repo_name", parts[2]);
                            startActivity(intent);
                        } else if (parts[0].equals("showUser")) {
                            final Intent intent = new Intent(SingleActivityItem.this, Profile.class);
                            intent.putExtra("username", parts[1]);
                            startActivity(intent);
                        } else if (parts[0].equals("showIssues")) {
                            final Intent intent = new Intent(SingleActivityItem.this, Issues.class);
                            intent.putExtra("repo_owner", parts[1]);
                            intent.putExtra("repo_name", parts[2]);
                            startActivity(intent);
                        }
                        return true;
                    }
                    return false;
                }
            });
            String html = "";
            final String eventType = mJson.getString("type");
            if (eventType.equals("PushEvent")) {
                html = NewsFeedHelpers.linkifyPushItem(mJson);
            } else if (eventType.equals("CreateEvent")) {
                final String object = mJson.getJSONObject("payload").getString("object");
                if (object.equals("branch")) {
                    html = NewsFeedHelpers.linkifyCreateBranchItem(mJson);
                } else if (object.equals("repository")) {
                    html = NewsFeedHelpers.linkifyCreateRepoItem(mJson);
                }
            } else if (eventType.equals("CommitCommentEvent")) {
                html = NewsFeedHelpers.linkifyCommitCommentItem(mJson);
            } else if (eventType.equals("FollowEvent")) {
                html = NewsFeedHelpers.linkifyFollowItem(mJson);
            } else if (eventType.equals("ForkEvent")) {
                html = NewsFeedHelpers.linkifyForkItem(mJson);
            } else if (eventType.equals("IssuesEvent")) {
                html = NewsFeedHelpers.linkifyIssueItem(mJson);
            } else if (eventType.equals("WatchEvent")) {
                html = NewsFeedHelpers.linkifyWatchItem(mJson);
            }
            final String out = CSS + html;
            content.loadData(out, "text/html", "UTF-8");
        } catch (final JSONException e) {
            e.printStackTrace();
        }
    }
}

From source file:eu.vranckaert.worktime.utils.donations.DonationsFragment.java

/**
 * Build view for Flattr. see Flattr API for more information:
 * http://developers.flattr.net/button//*w  ww.ja  va2 s.  c om*/
 */
@SuppressLint("SetJavaScriptEnabled")
@TargetApi(11)
private void buildFlattrView() {
    final FrameLayout mLoadingFrame;
    final WebView mFlattrWebview;

    mFlattrWebview = (WebView) getActivity().findViewById(R.id.donations__flattr_webview);
    mLoadingFrame = (FrameLayout) getActivity().findViewById(R.id.donations__loading_frame);

    // disable hardware acceleration for this webview to get transparent background working
    if (Build.VERSION.SDK_INT >= 11) {
        mFlattrWebview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }

    // define own webview client to override loading behaviour
    mFlattrWebview.setWebViewClient(new WebViewClient() {
        /**
         * Open all links in browser, not in webview
         */
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String urlNewString) {
            view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(urlNewString)));

            return false;
        }

        /**
         * Links in the flattr iframe should load in the browser not in the iframe itself,
         * http:/
         * /stackoverflow.com/questions/5641626/how-to-get-webview-iframe-link-to-launch-the
         * -browser
         */
        @Override
        public void onLoadResource(WebView view, String url) {
            if (url.contains("flattr")) {
                HitTestResult result = view.getHitTestResult();
                if (result != null && result.getType() > 0) {
                    view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
                    view.stopLoading();
                }
            }
        }

        /**
         * After loading is done, remove frame with progress circle
         */
        @Override
        public void onPageFinished(WebView view, String url) {
            // remove loading frame, show webview
            if (mLoadingFrame.getVisibility() == View.VISIBLE) {
                mLoadingFrame.setVisibility(View.GONE);
                mFlattrWebview.setVisibility(View.VISIBLE);
            }
        }
    });

    // get flattr values from xml config
    String projectUrl = DonationsUtils.getResourceString(getActivity(), "donations__flattr_project_url");
    String flattrUrl = DonationsUtils.getResourceString(getActivity(), "donations__flattr_url");

    // make text white and background transparent
    String htmlStart = "<html> <head><style type='text/css'>*{color: #FFFFFF; background-color: transparent;}</style>";

    // https is not working in android 2.1 and 2.2
    String flattrScheme;
    if (Build.VERSION.SDK_INT >= 9) {
        flattrScheme = "https://";
    } else {
        flattrScheme = "http://";
    }

    // set url of flattr link
    mFlattrUrl = (TextView) getActivity().findViewById(R.id.donations__flattr_url);
    mFlattrUrl.setText(flattrScheme + flattrUrl);

    String flattrJavascript = "<script type='text/javascript'>" + "/* <![CDATA[ */" + "(function() {"
            + "var s = document.createElement('script'), t = document.getElementsByTagName('script')[0];"
            + "s.type = 'text/javascript';" + "s.async = true;" + "s.src = '" + flattrScheme
            + "api.flattr.com/js/0.6/load.js?mode=auto';" + "t.parentNode.insertBefore(s, t);" + "})();"
            + "/* ]]> */" + "</script>";
    String htmlMiddle = "</head> <body> <div align='center'>";
    String flattrHtml = "<a class='FlattrButton' style='display:none;' href='" + projectUrl
            + "' target='_blank'></a> <noscript><a href='" + flattrScheme + flattrUrl
            + "' target='_blank'> <img src='" + flattrScheme
            + "api.flattr.com/button/flattr-badge-large.png' alt='Flattr this' title='Flattr this' border='0' /></a></noscript>";
    String htmlEnd = "</div> </body> </html>";

    String flattrCode = htmlStart + flattrJavascript + htmlMiddle + flattrHtml + htmlEnd;

    mFlattrWebview.getSettings().setJavaScriptEnabled(true);

    mFlattrWebview.loadData(flattrCode, "text/html", "utf-8");

    // make background of webview transparent
    // has to be called AFTER loadData
    // http://stackoverflow.com/questions/5003156/android-webview-style-background-colortransparent-ignored-on-android-2-2
    mFlattrWebview.setBackgroundColor(0x00000000);
}