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.yahala.ui.LoginActivitySmsView.java

@Override
public void setParams(Bundle params) {
    codeField.setText("");
    OSUtilities.setWaitingForSms(true);//  w ww .j a va 2 s . co  m
    NotificationCenter.getInstance().addObserver(this, 998);
    currentParams = params;
    waitingForSms = true;
    String phone = params.getString("phone");
    requestPhone = params.getString("phoneFormated");
    phoneHash = params.getString("phoneHash");

    registered = params.getString("registered");
    FileLog.e("yahala",
            requestPhone + "  phoneHash:" + phoneHash + "registered" + params.getString("registered"));
    time = params.getInt("calltime");

    String number = PhoneFormat.getInstance().format(phone);
    confirmTextView.setText(Html.fromHtml(String.format(
            ApplicationLoader.applicationContext.getResources().getString(R.string.SentSmsCode) + " <b>%s</b>",
            number)));

    OSUtilities.showKeyboard(codeField);
    codeField.requestFocus();

    try {
        synchronized (timerSync) {
            if (timeTimer != null) {
                timeTimer.cancel();
                timeTimer = null;
            }
        }
    } catch (Exception e) {
        FileLog.e("yahala", e);
    }
    timeText.setText(String.format("%s 1:00",
            ApplicationLoader.applicationContext.getResources().getString(R.string.CallText)));
    lastCurrentTime = System.currentTimeMillis();
    timeTimer = new Timer();
    timeTimer.schedule(new TimerTask() {
        @Override
        public void run() {
            double currentTime = System.currentTimeMillis();
            double diff = currentTime - lastCurrentTime;
            time -= diff;
            lastCurrentTime = currentTime;
            Utilities.RunOnUIThread(new Runnable() {
                @Override
                public void run() {
                    if (time >= 1000) {
                        int minutes = time / 1000 / 60;
                        int seconds = time / 1000 - minutes * 60;
                        timeText.setText(String.format("%s %d:%02d", ApplicationLoader.applicationContext
                                .getResources().getString(R.string.CallText), minutes, seconds));
                    } else {
                        timeText.setText(ApplicationLoader.applicationContext.getResources()
                                .getString(R.string.Calling));
                        synchronized (timerSync) {
                            if (timeTimer != null) {
                                timeTimer.cancel();
                                timeTimer = null;
                            }
                        }
                        TLRPC.TL_auth_sendCall req = new TLRPC.TL_auth_sendCall();
                        req.phone_number = requestPhone;
                        req.phone_code_hash = phoneHash;
                    }
                }
            });
        }
    }, 0, 1000);
    sendSmsRequest();
}

From source file:com.liato.bankdroid.banking.banks.Osuuspankki.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());
    }/*ww w  .  j ava2s.co  m*/

    urlopen = login();
    Matcher matcher;
    matcher = reAccounts.matcher(response);
    while (matcher.find()) {
        /*
         * Capture groups:
         * GROUP                    EXAMPLE DATA
         * 1: Account type          12401 | 12701
         * 2: Account id            ecb_5f0e0dfcbc1e8aabe4f5ab85e3382266
         * 3: Account name          FI91 5553 5140 0165 27
         * 4: Amount                +882,35
         * 5: Currency              &nbsp;&euro;
         * 
         */
        String currency = Helpers.parseCurrency(Html.fromHtml(matcher.group(5)).toString().trim(), "EUR");
        Account account = new Account(Html.fromHtml(matcher.group(3)).toString().trim(),
                Helpers.parseBalance(matcher.group(4)), matcher.group(2).trim());
        account.setCurrency(currency);
        //Bonuskonto
        if ("12701".equals(matcher.group(1))) {
            account.setType(Account.OTHER);
        }
        this.setCurrency(currency);
        accounts.add(account);
        balance = balance.add(Helpers.parseBalance(matcher.group(4)));
    }

    if (accounts.isEmpty()) {
        throw new BankException(res.getText(R.string.no_accounts_found).toString());
    }
    super.updateComplete();
}

From source file:com.rei.lolchat.ui.Login.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == LOGIN_REQUEST_CODE) {
        mIsResult = true;// w ww .  j  av  a2 s . co  m
        if (resultCode == Activity.RESULT_OK) {
            startActivity(new Intent(this, ContactList.class));
            finish();
        } else if (resultCode == Activity.RESULT_CANCELED) {
            if (data != null) {
                String tmp = data.getExtras().getString("message");
                Toast.makeText(Login.this, tmp, Toast.LENGTH_SHORT).show();
                mTextView.setText(tmp);

                SharedPreferences mSettings = PreferenceManager.getDefaultSharedPreferences(this);
                String server = mSettings.getString(BeemApplication.LEVEL_KEY, "");

                tv_na = (TextView) findViewById(R.id.status_na);
                tv_eune = (TextView) findViewById(R.id.status_eune);
                tv_euw = (TextView) findViewById(R.id.status_euw);

                String text = "";

                text = "<font color='#0099FF'>[US]</font> Checking...";
                tv_na.setText(Html.fromHtml(text));

                text = "<font color='#0099FF'>[EU-NE]</font> Checking...";
                tv_eune.setText(Html.fromHtml(text));

                text = "<font color='#0099FF'>[EU-W]</font> Checking...";
                tv_euw.setText(Html.fromHtml(text));

                loadServerStatusTask task = new loadServerStatusTask();
                task.execute("na");

                loadServerStatusTask task2 = new loadServerStatusTask();
                task2.execute("eune");

                loadServerStatusTask task3 = new loadServerStatusTask();
                task3.execute("euw");

            }
        }
    }
}

From source file:com.liato.bankdroid.banking.banks.TrustBuddy.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 a v a2  s .co  m

    urlopen = login();
    String response = null;
    Matcher matcher;
    try {
        response = urlopen.open("https://trustbuddy.com/se/din_sida/");
        matcher = reAccounts.matcher(response);

        while (matcher.find()) {
            /*
             * 1: Land
             * 2: Saldo
             * 3: Valuta
             */
            Account temp = new Account(Html.fromHtml(matcher.group(1)).toString().trim(),
                    Helpers.parseBalance(matcher.group(2).trim()), matcher.group(1).toLowerCase());
            temp.setCurrency(matcher.group(3));
            accounts.add(temp);

            balance = balance.add(Helpers.parseBalance(matcher.group(2)));
        }
        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());
    }
}

From source file:org.thomasamsler.android.flashcards.fragment.CardSetsFragment.java

@Override
public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mActivity = (MainActivity) getActivity();
    mDataSource = mActivity.getDataSource();
    mMainApplication = (MainApplication) mActivity.getApplication();

    mMainApplication.registerAction(this, ACTION_DELETE_CARD_UPDATE_CARD_SET);

    registerForContextMenu(getListView());

    mProgressBar = (ProgressBar) mActivity.findViewById(R.id.progressBar);

    if (null == mCardSets) {

        mCardSets = mDataSource.getCardSets();
    }//ww  w  .  j a  va2s.  c  o  m

    if (0 == mCardSets.size()) {

        SharedPreferences sharedPreferences = mActivity.getSharedPreferences(AppConstants.PREFERENCE_NAME,
                Context.MODE_PRIVATE);
        boolean showSample = sharedPreferences.getBoolean(AppConstants.PREFERENCE_SHOW_SAMPLE,
                AppConstants.PREFERENCE_SHOW_SAMPLE_DEFAULT);

        if (showSample) {

            createDefaultCardSets();
            mCardSets = mDataSource.getCardSets();
        } else {

            Toast.makeText(mMainApplication, R.string.list_no_card_sets_message, Toast.LENGTH_SHORT).show();
        }
    }

    Collections.sort(mCardSets);

    mArrayAdapter = new ArrayAdapter<CardSet>(mActivity, android.R.layout.simple_list_item_1, mCardSets) {

        /*
         * Overwriting getView method to style the list item font. If it's a remote item
         * that hasn't been clicked on, we style it bold
         */
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {

            TextView textView = (TextView) super.getView(position, convertView, parent);
            CardSet cardSet = mCardSets.get(position);

            switch (cardSet.getCardCount()) {

            case 0:
                textView.setText(Html.fromHtml(
                        cardSet.getTitle() + "<br /><small><i><font color='#989898'>empty</font></i></small>"));
                break;
            case 1:
                textView.setText(Html.fromHtml(cardSet.getTitle() + "<br /><small><i><font color='#989898'>"
                        + cardSet.getCardCount() + " card</font></i></small>"));
                break;
            default:
                textView.setText(Html.fromHtml(cardSet.getTitle() + "<br /><small><i><font color='#989898'>"
                        + cardSet.getCardCount() + " cards</font></i></small>"));
                break;
            }

            if (mCardSets.get(position).isRemote()) {

                ((TextView) textView).setTypeface(Typeface.DEFAULT_BOLD);
            } else {

                ((TextView) textView).setTypeface(Typeface.DEFAULT);
            }

            return textView;
        }
    };

    setListAdapter(mArrayAdapter);

}

From source file:it.scoppelletti.mobilepower.app.HelpDialogFragment.java

/**
 * Crea il dialogo./*from  w w w  .  j  a v a 2s.  co  m*/
 * 
 * @param  savedInstanceState Stato dell&rsquo;istanza.
 * @return                    Dialogo.
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    int mode, resId;
    View contentView;
    AlertDialog dlg;
    AlertDialog.Builder builder;
    LayoutInflater inflater;
    TextView textControl;
    Bundle args = getArguments();

    builder = newAlertDialogBuilder();

    resId = args.getInt(HelpDialogFragment.ARG_TITLEID, 0);
    if (resId > 0) {
        builder.setTitle(resId);
    }

    inflater = getActivity().getLayoutInflater();
    contentView = inflater.inflate(R.layout.helpdialog, null);
    builder.setView(contentView);

    builder.setIcon(android.R.drawable.ic_dialog_info);

    mode = getArguments().getInt(HelpDialogFragment.ARG_MODE, HelpDialogFragment.MODE_HELP);
    switch (mode) {
    case HelpDialogFragment.MODE_CONFIRM:
        setCancelable(false);
        builder.setCancelable(false);
        builder.setPositiveButton(R.string.cmd_proceed, this);
        builder.setNegativeButton(android.R.string.cancel, this);
        break;

    default: // HelpDialogFragment.MODE_HELP
        builder.setNeutralButton(R.string.cmd_close, null);
        break;
    }

    dlg = builder.create();

    textControl = (TextView) contentView.findViewById(R.id.txt_help);
    textControl.setKeyListener(null);

    resId = args.getInt(HelpDialogFragment.ARG_TEXTID, 0);
    if (resId > 0) {
        textControl.setText(Html.fromHtml(getResources().getString(resId)));
    }

    return dlg;
}

From source file:com.liato.bankdroid.banking.banks.SevenDay.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 w  w  .  j  av a 2  s  . c  om*/
    urlopen = login();
    try {
        Matcher matcher;
        matcher = reAccounts.matcher(response);
        while (matcher.find()) {
            /*
             * Capture groups:
             * GROUP                EXAMPLE DATA
             * 1: Account id        JigBFAUETrrqVKY+V4Dm3tcoY1n6Usa21IuHxa1BV7MnJT3T6rrGChDcDK0RSuM731uAeB/f9rvPRXRFYCCBcQ
             * 2: Account name      Sparkonto: XXX
             * 3: Interest          2,55
             * 4: Amount            10&nbsp;kr
             *  
             */
            accounts.add(new Account(Html.fromHtml(matcher.group(2)).toString().trim(),
                    Helpers.parseBalance(matcher.group(4)), Html.fromHtml(matcher.group(1)).toString().trim()));
            balance = balance.add(Helpers.parseBalance(matcher.group(4)));
        }

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

From source file:com.liato.bankdroid.banking.banks.SEB.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());
    }//from  w w  w. j ava  2  s.c o m

    urlopen = login();
    Matcher matcher;
    try {
        response = urlopen.open("https://m.seb.se/cgi-bin/pts3/mps/1100/mps1101.aspx?X1=digipassAppl1");
        matcher = reAccounts.matcher(response);
        while (matcher.find()) {
            /*
             * Capture groups:
             * GROUP                    EXAMPLE DATA
             * 1: ID                    GJmQRqlrOPmM++1zf50d6Q==
             * 2: Name                  Personkonto
             * 3: Amount                2.208,03
             * 
             */
            accounts.add(new Account(Html.fromHtml(matcher.group(2)).toString().trim(),
                    Helpers.parseBalance(matcher.group(3)), matcher.group(1).trim()));
            balance = balance.add(Helpers.parseBalance(matcher.group(3)));
        }

        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:com.liato.bankdroid.banking.banks.Nordnet.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 w  w  . j  av a 2  s  .  c  o  m
    urlopen = login();
    try {
        Matcher matcher;
        matcher = reBalance.matcher(response);
        while (matcher.find()) {
            /*
             * Capture groups:
             * GROUP                EXAMPLE DATA
             * 1: Name              Efternamnet Frnamnet | Sparkonto
             * 2: Account name      Aktie- och fonddep   | Sparkonto
             * 3: Account number    1234567               | 1234 567890 1
             * 4: Amount            31 337                | 123
             *  
             */
            Account account = new Account(
                    Html.fromHtml(matcher.group(2)).toString().trim() + " "
                            + Html.fromHtml(matcher.group(3)).toString().trim(),
                    Helpers.parseBalance(matcher.group(4)),
                    Html.fromHtml(matcher.group(3)).toString().trim().replaceAll(" ", ""));

            // Saving accounts contain white space characters in the account number
            if (!matcher.group(3).trim().contains(" ")) {
                account.setType(Account.FUNDS);
            }
            accounts.add(account);
            balance = balance.add(Helpers.parseBalance(matcher.group(4)));
        }

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

From source file:org.n52.geoar.data.sos.SOSFeatureVisualization.java

@Override
public View getFeatureView(SpatialEntity2<? extends Geometry> entity, View convertView, ViewGroup parentView,
        Context activityContext) {
    ViewHolder viewHolder;/*  w w w  . j  a v a 2  s  . c  o m*/

    if (convertView == null) {
        convertView = LayoutInflater.from(activityContext).inflate(R.layout.sos_featureview, null);
        viewHolder = new ViewHolder();

        viewHolder.textViewServiceSensorId = (TextView) convertView.findViewById(R.id.textViewServiceSensorId);
        viewHolder.textViewDescription = (TextView) convertView.findViewById(R.id.textViewDescription);
        viewHolder.textViewName = (TextView) convertView.findViewById(R.id.textViewName);

        viewHolder.sosObservationView = (SOSObservationView) convertView.findViewById(R.id.sosObservationView);
        viewHolder.sosObservationView.setCapabilitiesCallable(viewHolder.capabilitiesCallable);
        viewHolder.sosObservationView.setObservationCallable(viewHolder.observationCallable);
        viewHolder.sosObservationView.setActivityContext(activityContext);

        TabHost tabHost = (TabHost) convertView.findViewById(android.R.id.tabhost);
        tabHost.setup();
        tabHost.addTab(tabHost.newTabSpec("FOI").setIndicator("Feature").setContent(R.id.scrollViewFOI));
        tabHost.addTab(tabHost.newTabSpec("SOS").setIndicator("Observations").setContent(R.id.layoutSOS));

        tabHost.setCurrentTab(0);

        convertView.setTag(viewHolder);
    } else {
        viewHolder = (ViewHolder) convertView.getTag();
    }

    if (entity instanceof FOI) {
        viewHolder.featureOfInterest = (FOI) entity;
        viewHolder.textViewName.setText(viewHolder.featureOfInterest.name);
        if (viewHolder.featureOfInterest.description != null) {
            viewHolder.textViewDescription.setText(Html.fromHtml(viewHolder.featureOfInterest.description));
        }
        viewHolder.textViewServiceSensorId.setText(viewHolder.featureOfInterest.id);
    }
    return convertView;
}