Example usage for android.text Html fromHtml

List of usage examples for android.text Html fromHtml

Introduction

In this page you can find the example usage for android.text Html fromHtml.

Prototype

@Deprecated
public static Spanned fromHtml(String source) 

Source Link

Document

Returns displayable styled text from the provided HTML string with the legacy flags #FROM_HTML_MODE_LEGACY .

Usage

From source file:com.hybris.mobile.adapter.CartAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    Object cartItem = items.get(position);
    View rowView = null;//w  w w  .  j av  a 2s. c  o m

    if (cartItem instanceof CartEntry) {
        CartEntry cartEntry = (CartEntry) cartItem;

        rowView = inflater.inflate(R.layout.cart_row, parent, false);

        TextView lblProductTitle = (TextView) rowView.findViewById(R.id.lbl_product_title);
        TextView lblProductPrice = (TextView) rowView.findViewById(R.id.lbl_price_quantity);
        TextView lblManufacturer = (TextView) rowView.findViewById(R.id.lbl_productManufacturer);
        TextView lblTotal = (TextView) rowView.findViewById(R.id.lbl_total);
        ImageView productImage = (ImageView) rowView.findViewById(R.id.img_product);

        if (StringUtils.isEmpty(cartEntry.getProduct().getManufacturer())) {
            lblManufacturer.setHeight(0);
        } else {
            lblManufacturer.setText(cartEntry.getProduct().getManufacturer());
        }
        lblProductTitle.setText(cartEntry.getProduct().getName());
        lblProductPrice.setText(cartEntry.getBasePrice().getFormattedValue() + " - "
                + this.getContext().getString(R.string.cartentry_quantity_placeholder)
                + cartEntry.getQuantity().toString());
        lblManufacturer.setText(cartEntry.getProduct().getManufacturer());

        lblTotal.setText(cartEntry.getTotalPrice().getFormattedValue());
        UrlImageViewHelper.setUrlDrawable(productImage, cartEntry.getProduct().getThumbnail(),
                R.drawable.loading_drawable);
    }
    // Promotions
    else if (cartItem instanceof CartPromotion) {
        CartPromotion cartPromotion = (CartPromotion) cartItem;

        rowView = inflater.inflate(R.layout.promotion_row, parent, false);

        // Update promotions section
        TextView promotionsTextView = (TextView) rowView.findViewById(R.id.textView);
        promotionsTextView.setMovementMethod(LinkMovementMethod.getInstance());

        promotionsTextView.setText(Html.fromHtml(Cart.generatePromotionString(cartPromotion)));
        StringUtil.removeUnderlines((Spannable) promotionsTextView.getText());
    }

    return rowView;
}

From source file:com.tassadar.multirommgr.installfragment.InstallCard.java

@Override
public View getCardContent(Context context) {
    m_view = LayoutInflater.from(context).inflate(R.layout.install_card, null);

    Resources res = m_view.getResources();

    CheckBox b = (CheckBox) m_view.findViewById(R.id.install_multirom);
    b.setText(res.getString(R.string.install_multirom, m_manifest.getMultiromVersion()));
    b.setChecked(m_manifest.hasMultiromUpdate());
    b.setOnCheckedChangeListener(this);

    b = (CheckBox) m_view.findViewById(R.id.install_recovery);
    if (m_manifest.getRecoveryFile() != null) {
        final Date rec_date = m_manifest.getRecoveryVersion();
        final String recovery_ver = Recovery.DISPLAY_FMT.format(rec_date);
        b.setText(res.getString(R.string.install_recovery, recovery_ver));
        b.setChecked(m_manifest.hasRecoveryUpdate());
        b.setOnCheckedChangeListener(this);

        // Force user to install recovery if not yet installed - it is needed to flash ZIPs
        if (m_manifest.hasRecoveryUpdate() && m_forceRecovery) {
            b.append(Html.fromHtml(res.getString(R.string.required)));
            b.setClickable(false);// www .  j a  v a2s .  c o m
        }
    } else {
        b.setChecked(false);
        b.setVisibility(View.GONE);
    }

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(context,
            android.R.layout.simple_spinner_dropdown_item);
    adapter.addAll(m_manifest.getKernels().keySet());
    Spinner s = (Spinner) m_view.findViewById(R.id.kernel_options);
    s.setAdapter(adapter);
    s.setEnabled(false);
    s.setSelection(getDefaultKernel());

    b = (CheckBox) m_view.findViewById(R.id.install_kernel);
    b.setOnCheckedChangeListener(this);
    b.setEnabled(!adapter.isEmpty());
    b.setChecked(!adapter.isEmpty() && m_manifest.hasKernelUpdate());

    Button install_btn = (Button) m_view.findViewById(R.id.install_btn);
    install_btn.setOnClickListener(this);

    ImageButton changelog_btn = (ImageButton) m_view.findViewById(R.id.changelog_btn);
    if (m_manifest.getChangelogs() == null || m_manifest.getChangelogs().length == 0)
        changelog_btn.setVisibility(View.GONE);
    else
        changelog_btn.setOnClickListener(this);

    if (m_savedState != null)
        restoreInstanceState();

    enableInstallBtn();
    return m_view;
}

From source file:com.alusorstroke.jjvm.SettingsFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.activity_settings);

    // open play store page
    Preference preferencerate = findPreference("rate");
    preferencerate.setOnPreferenceClickListener(new OnPreferenceClickListener() {
        @Override/*from w  ww  . j a  v  a2s . c  om*/
        public boolean onPreferenceClick(Preference preference) {
            Uri uri = Uri.parse("market://details?id=" + getActivity().getPackageName());
            Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
            try {
                startActivity(goToMarket);
            } catch (ActivityNotFoundException e) {
                Toast.makeText(getActivity(), "Could not open Play Store", Toast.LENGTH_SHORT).show();
                return true;
            }
            return true;
        }
    });

    final ServiceStarter alarm = new ServiceStarter();

    // open default page
    Preference preferenceservice = findPreference("switchRss");

    String push = getString(R.string.rss_push_url);
    if (null == push || push.equals("")) {
        PreferenceCategory general = (PreferenceCategory) findPreference("general");
        general.removePreference(preferenceservice);
    }

    preferenceservice.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @SuppressLint("CommitPrefEdits")
        @Override
        public boolean onPreferenceChange(Preference preference, Object newvalue) {
            boolean switched = ((SwitchPreference) preference).isChecked();

            if (switched == false) {
                alarm.setAlarm(getActivity());
            } else {
                alarm.cancelAlarm(getActivity());
            }
            return true;
        }

    });

    // open about dialog
    Preference preferenceabout = findPreference("about");
    preferenceabout.setOnPreferenceClickListener(new OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            AlertDialog.Builder ab = null;
            ab = new AlertDialog.Builder(getActivity());
            ab.setMessage(Html.fromHtml(getResources().getString(R.string.about_text)));
            ab.setPositiveButton(getResources().getString(R.string.ok), null);
            ab.setTitle(getResources().getString(R.string.about_header));
            ab.show();
            return true;
        }
    });

    // purchase
    preferencepurchase = findPreference("purchase");
    String license = getResources().getString(R.string.google_play_license);
    if (null != license && !license.equals("")) {
        bp = new BillingProcessor(getActivity(), license, this);
        bp.loadOwnedPurchasesFromGoogle();

        preferencepurchase.setOnPreferenceClickListener(new OnPreferenceClickListener() {
            @Override
            public boolean onPreferenceClick(Preference preference) {
                bp.purchase(getActivity(), PRODUCT_ID());
                return true;
            }
        });

        if (getIsPurchased(getActivity())) {
            preferencepurchase.setIcon(R.drawable.ic_action_action_done);
        }
    } else {
        PreferenceScreen preferenceScreen = (PreferenceScreen) findPreference("preferenceScreen");
        PreferenceCategory billing = (PreferenceCategory) findPreference("billing");
        preferenceScreen.removePreference(billing);
    }

    String[] extra = getArguments().getStringArray(MainActivity.FRAGMENT_DATA);
    if (null != extra && extra.length != 0 && extra[0].equals(SHOW_DIALOG)) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        // Add the buttons
        builder.setPositiveButton(R.string.settings_purchase, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                bp.purchase(getActivity(), PRODUCT_ID());
            }
        });
        builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                // User cancelled the dialog
            }
        });
        builder.setTitle(getResources().getString(R.string.dialog_purchase_title));
        builder.setMessage(getResources().getString(R.string.dialog_purchase));

        // Create the AlertDialog
        dialog = builder.create();
        dialog.show();
    }

    if (HIDE_RATE_MY_APP) {
        PreferenceCategory other = (PreferenceCategory) findPreference("other");
        Preference preference = (Preference) findPreference("rate");
        other.removePreference(preference);
    }

}

From source file:com.android.settings.aicp.AicpSettings.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case MENU_HELP:
        showDialogInner(MENU_HELP);/*from ww w. j  a  v  a  2  s.  c o  m*/
        Toast.makeText(getActivity(), (Html.fromHtml("READ THE WHOLE THING!!")), Toast.LENGTH_LONG).show();
        return true;
    default:
        return false;
    }
}

From source file:ca.uwaterloo.magic.goodhikes.LoginActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    if (getIntent().getBooleanExtra("EXIT", false)) {
        finish();//  ww  w .  ja  v a  2s  . c  o m
    }

    /** Define variables **/
    session = new UserManager(getApplicationContext());
    user_email = (EditText) findViewById(R.id.user_email);
    user_password = (EditText) findViewById(R.id.user_password);
    btn_login = (Button) findViewById(R.id.btn_login);
    link_register = (TextView) findViewById(R.id.link_register);
    link_map = (TextView) findViewById(R.id.link_map);

    /** Check if user is logged in already **/
    if (session.checkLogin()) {
        startActivity(new Intent(getApplicationContext(), MapsActivity.class));
        finish();
    }

    /** Login button **/
    btn_login.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String email = user_email.getText().toString();
            String password = user_password.getText().toString();
            if (!email.isEmpty() && !password.isEmpty()) {
                try {
                    String input = "email=";
                    input += URLEncoder.encode(email, "UTF-8");
                    input += "&password=";
                    input += URLEncoder.encode(password, "UTF-8");
                    Log.d("Input for AsyncTask", input);
                    new checkLogin().execute(input);
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }

            } else {
                Toast.makeText(getApplicationContext(), "Please fill in all credentials!", Toast.LENGTH_SHORT)
                        .show();
            }
        }
    });

    /** Register button **/
    link_register.setText(Html.fromHtml("New to Goodhikes? <u>Create account</u>"));

    link_register.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(getApplicationContext(), RegisterActivity.class));
            finish();
        }
    });

    /** Procede to map **/
    link_map.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(getApplicationContext(), MapsActivity.class));
            finish();
        }
    });

}

From source file:it.sasabz.android.sasabus.InfoActivity.java

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() {

        @Override//w w  w.j av a2  s  .c o m
        public void onClick(DialogInterface dialogInterface, int i) {
            dialogInterface.dismiss();
        }
    });
    Information information = (Information) list.get(position);
    builder.setTitle(Html.fromHtml(information.getTitel()));
    builder.setMessage(Html.fromHtml("<pre>" + information.getNachricht() + "</pre>"));
    builder.create().show();
}

From source file:com.liato.bankdroid.banking.banks.TestBank.java

@Override
public void update() throws BankException, LoginException, BankChoiceException {
    super.update();
    if (username == null || password == null || username.length() == 0 || password.length() == 0) {
        throw new LoginException(res.getText(R.string.invalid_username_password).toString());
    }//  w  ww .j av  a  2s.  com
    urlopen = login();
    String response = null;
    Matcher matcher;
    try {

        response = urlopen.open("http://www.nullbyte.eu/bankdroid/tests/testbank/accounts.htm");
        matcher = reAccounts.matcher(response);
        while (matcher.find()) {
            /*
             * Capture groups:
             * GROUP                EXAMPLE DATA
             * 1: Name              Sparkonto
             * 2: Amount            83553,70
             * 3: ID                1
             * 4: Type              trans|fund
             *  
             */
            Account acc = new Account(Html.fromHtml(matcher.group(1)).toString().trim(),
                    Helpers.parseBalance(matcher.group(2)),
                    ("fund".equals(matcher.group(4)) ? "f:" : "") + matcher.group(3).trim());
            if ("fund".equals(matcher.group(4))) {
                acc.setType(Account.FUNDS);
            } else {
                balance = balance.add(Helpers.parseBalance(matcher.group(3)));
            }
            accounts.add(acc);
        }

        if (accounts.isEmpty()) {
            throw new BankException(res.getText(R.string.no_accounts_found).toString());
        }
    } catch (ClientProtocolException e) {
        throw new BankException(e.getMessage());
    } catch (IOException e) {
        throw new BankException(e.getMessage());
    } finally {
        super.updateComplete();
    }
}

From source file:org.npr.android.news.StationListAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View line = super.getView(position, convertView, parent);
    Station station = getItem(position);

    TextView name = (TextView) line.findViewById(R.id.StationItemNameText);
    name.setText(Html.fromHtml(station.getName()));

    TextView location = (TextView) line.findViewById(R.id.StationItemLocationText);
    location.setText(Html.fromHtml(station.getMarketCity()));

    TextView frequency = (TextView) line.findViewById(R.id.StationItemFrequencyText);

    if (station.getFrequency() != null && station.getBand() != null) {
        frequency.setText(Html.fromHtml(String.format("%s %s", station.getFrequency(), station.getBand())));
    } else {/*from  ww w.  jav a  2 s  .com*/
        frequency.setText("");
    }

    if (favoriteStationsRepository != null) {
        TextView preset = (TextView) line.findViewById(R.id.StationPresetView);
        FavoriteStationEntry favoriteStationEntry = favoriteStationsRepository
                .getFavoriteStationForStationId(station.getId());
        if (favoriteStationEntry != null && favoriteStationEntry.preset != null) {
            preset.setText(favoriteStationEntry.preset);
            preset.setVisibility(View.VISIBLE);
        } else {
            preset.setVisibility(View.INVISIBLE);
        }
    }

    return line;
}

From source file:com.liato.bankdroid.banking.banks.TrustBuddy.java

public Urllib login() throws LoginException, BankException {
    try {/* w  w w  .j av a  2s  .c om*/
        LoginPackage lp = preLogin();
        String response = urlopen.open(lp.getLoginTarget(), lp.getPostData());
        Matcher matcher = reError.matcher(response);
        if (matcher.find()) {
            String errormsg = Html.fromHtml(matcher.group(1).trim()).toString();
            if (errormsg.contains("Felaktigt")) {
                throw new LoginException(errormsg);
            } else {
                throw new BankException(errormsg);
            }
        }
    } catch (ClientProtocolException e) {
        Log.e(TAG, "ClientProtocolException: " + e.getMessage());
        throw new BankException(e.getMessage());
    } catch (IOException e) {
        Log.e(TAG, "IOException: " + e.getMessage());
        throw new BankException(e.getMessage());
    }
    return urlopen;
}

From source file:com.speedtong.example.ui.account.LoginActivity.java

private void initResourceRefs() {

    loginView = (LinearLayout) findViewById(R.id.experience_login_id);
    registView = (LinearLayout) findViewById(R.id.experience_regist_id);
    registButton = (Button) findViewById(R.id.switch_regist_view);
    registButton.setOnClickListener(this);
    loginButton = (Button) findViewById(R.id.switch_login_view);
    loginButton.setOnClickListener(this);
    mAccountInputView = (CCPFormInputView) findViewById(R.id.login_account_auto);
    mAccountEdt = mAccountInputView.getFormInputEditView();
    mPwdInputView = (CCPFormInputView) findViewById(R.id.login_password_et);
    mPasswordEdt = mPwdInputView.getFormInputEditView();
    tv_regist_tip1 = (TextView) findViewById(R.id.tv_regist_tip1);
    tv_regist_tip1.setText(Html.fromHtml(getString(R.string.tips_regist_1)));
}