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.facebook.login.DeviceAuthDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    dialog = new Dialog(getActivity(), R.style.com_facebook_auth_dialog);
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View view = inflater.inflate(R.layout.com_facebook_device_auth_dialog_fragment, null);
    progressBar = (ProgressBar) view.findViewById(R.id.progress_bar);
    confirmationCode = (TextView) view.findViewById(R.id.confirmation_code);

    Button cancelButton = (Button) view.findViewById(R.id.cancel_button);
    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override//from w w  w .j  av  a  2  s . c  o m
        public void onClick(View v) {
            onCancel();
        }
    });

    TextView instructions = (TextView) view.findViewById(R.id.com_facebook_device_auth_instructions);
    instructions.setText(Html.fromHtml(getString(R.string.com_facebook_device_auth_instructions)));

    dialog.setContentView(view);
    return dialog;
}

From source file:de.tudresden.inf.rn.mobilis.groups.overlays.GroupsOverlay.java

@Override
protected boolean onTap(int index) {
    OverlayItem item = mOverlays.get(index);
    GroupItemInfo gii = groupItemInfos.get(index);

    LayoutInflater inflater = (LayoutInflater) mainActivity
            .getSystemService(mainActivity.LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.groups_details_dialog,
            (ViewGroup) mainActivity.findViewById(R.id.groups_details_layout_root));

    TextView text = (TextView) layout.findViewById(R.id.groups_details_text);
    text.setText(Html.fromHtml("<b>Latitude:</b> " + gii.latitudeE6 / 1E6 + "<br><b>Longitude:</b> "
            + gii.longitudeE6 / 1E6 + "<br><b>Number of Members:</b> " + gii.memberCount));

    //Prepare the Intent for creating a group at this foursquare venue
    final Intent i = new Intent(mainActivity.getApplicationContext(), GroupInfoActivity.class);
    i.putExtra("group_id", gii.groupId);

    String title = gii.name;//from  w ww  . j a va 2 s.co  m
    if (title == null || title.equals(""))
        title = " ";
    AlertDialog.Builder builder = new AlertDialog.Builder(mainActivity);
    builder.setTitle(title).setView(layout).setIcon(R.drawable.group_marker_24).setCancelable(true)
            .setPositiveButton("Details", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    mainActivity.startActivity(i);
                }
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });
    builder.show();
    return true;
}

From source file:com.liato.bankdroid.banking.banks.ResursBank.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   www  . j av  a 2 s  .c  om

    urlopen = login();
    Matcher matcher = reAccounts.matcher(response);
    while (matcher.find()) {
        /*
         * Capture groups:
         * GROUP                    EXAMPLE DATA
         * 1: Account number        0000000000000000
         * 2: Beviljad kredit       0,00 kr
         * 3: Utnyttjad kredit      0,00 kr
         * 4: Reserverat  belopp    0,00 kr
         * 5: Kvar att utnyttja     0,00 kr
         * 
         */
        String accountId = Html.fromHtml(matcher.group(1)).toString().trim().replaceAll("[^0-9]*", "");
        accounts.add(new Account("Beviljad kredit", Helpers.parseBalance(matcher.group(2)), "b_" + accountId));

        BigDecimal utnyttjad = Helpers.parseBalance(matcher.group(3));
        utnyttjad = utnyttjad.add(Helpers.parseBalance(matcher.group(4)));
        utnyttjad = utnyttjad.negate();
        accounts.add(new Account("Utnyttjad kredit", utnyttjad, "u_" + accountId));

        balance = balance.add(Helpers.parseBalance(matcher.group(3)));
        balance = balance.add(utnyttjad);
        accounts.add(
                new Account("Reserverat belopp", Helpers.parseBalance(matcher.group(4)), "r_" + accountId));
        accounts.add(new Account("Disponibelt", Helpers.parseBalance(matcher.group(5)), "k_" + accountId));
    }

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

From source file:com.andrewchelladurai.simplebible.SearchFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_search, container, false);

    mInput = (TextInputEditText) view.findViewById(R.id.fragment_search_input);
    mInput.addTextChangedListener(this);
    mLabel = (AppCompatTextView) view.findViewById(R.id.fragment_search_label);

    mSearchButton = (AppCompatButton) view.findViewById(R.id.fragment_search_button_search);
    mSearchButton.setOnClickListener(this);

    mResetButton = (AppCompatButton) view.findViewById(R.id.fragment_search_button_reset);
    mResetButton.setOnClickListener(this);

    mBookmarkButton = (AppCompatButton) view.findViewById(R.id.fragment_search_button_bookmark);
    mBookmarkButton.setOnClickListener(this);

    mShareButton = (AppCompatButton) view.findViewById(R.id.fragment_search_button_share);
    mShareButton.setOnClickListener(this);

    mRecyclerView = (RecyclerView) view.findViewById(R.id.fragment_search_list);
    mRecyclerView.setLayoutManager(new GridLayoutManager(view.getContext(), mColumnCount));

    mHelpLabelContainer = (ScrollView) view.findViewById(R.id.fragment_search_label_help_container);
    AppCompatTextView mHelpLabel = (AppCompatTextView) view.findViewById(R.id.fragment_search_label_help);
    mHelpLabel.setText(Html.fromHtml(getString(R.string.fragment_search_label_help)));

    init();// ww  w. j  a  v  a  2s . c om
    mRecyclerView.setAdapter(mListAdapter);

    refreshList();
    return view;
}

From source file:org.klnusbaum.udj.auth.AuthActivity.java

/**
 * {@inheritDoc}/*  w  w w.ja  va 2  s. co m*/
 */
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    mAccountManager = AccountManager.get(this);
    final Intent intent = getIntent();
    mUsername = intent.getStringExtra(PARAM_USERNAME);
    mRequestNewAccount = mUsername == null;
    mConfirmCredentials = intent.getBooleanExtra(PARAM_CONFIRM_CREDENTIALS, false);
    Log.i(TAG, "    request new: " + mRequestNewAccount);
    requestWindowFeature(Window.FEATURE_LEFT_ICON);
    setContentView(R.layout.login_activity);
    getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, android.R.drawable.ic_dialog_alert);
    mMessage = (TextView) findViewById(R.id.message);
    mUsernameEdit = (EditText) findViewById(R.id.username_edit);
    mPasswordEdit = (EditText) findViewById(R.id.password_edit);
    if (!TextUtils.isEmpty(mUsername))
        mUsernameEdit.setText(mUsername);
    mMessage.setText(getMessage());

    TextView signUp = (TextView) findViewById(R.id.signup_text);
    signUp.setText(Html.fromHtml(getString(R.string.dont_have_account)));
    signUp.setMovementMethod(LinkMovementMethod.getInstance());
}

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

public Urllib login() throws LoginException, BankException {
    try {//from w  w w .ja v a2 s  .  com
        LoginPackage lp = preLogin();
        String response = urlopen.open(lp.getLoginTarget(), lp.getPostData());
        Matcher matcher = reError.matcher(response);
        if (matcher.find()) {
            throw new LoginException(Html.fromHtml(matcher.group(1).trim()).toString());
        }
    } catch (ClientProtocolException e) {
        Log.d(TAG, "ClientProtocolException: " + e.getMessage());
        throw new BankException(e.getMessage());
    } catch (IOException e) {
        Log.d(TAG, "IOException: " + e.getMessage());
        throw new BankException(e.getMessage());
    }
    return urlopen;
}

From source file:com.adkdevelopment.e_contact.DetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.detail_fragment_task, container, false);
    mUnbinder = ButterKnife.bind(this, rootView);

    // to prevent multiple calls to getContext()
    Context context = getContext();

    Intent intent = getActivity().getIntent();
    TaskItem newsItem;//w  w w . j  av a  2s.  c om

    if (intent.hasExtra(TaskItem.TASKITEM)) {

        newsItem = intent.getParcelableExtra(TaskItem.TASKITEM);

        // Time parsing and creating a nice textual version (should be changed to Calendar)
        String dateCreated = Utilities.getFormattedDate(newsItem.getCreated());
        String dateRegistered = Utilities.getFormattedDate(newsItem.getRegistered());
        String dateAssigned = Utilities.getFormattedDate(newsItem.getAssigned());

        mTaskTitleText.setText(Utilities.getType(context, newsItem.getType()));
        mTaskStatus.setText(Utilities.getStatus(context, newsItem.getStatus()));

        // sets color of a status TextView shape according to the schema
        GradientDrawable gradientDrawable = (GradientDrawable) mTaskStatus.getBackground();
        gradientDrawable.setColor(Utilities.getBackgroundColor(context, newsItem.getStatus()));

        mTaskCreatedDate.setText(dateCreated);
        mTaskRegisteredDate.setText(dateRegistered);
        mTaskAssignedDate.setText(dateAssigned);
        mTaskResponsibleName.setText(newsItem.getResponsible());
        mTaskDescription.setText(Html.fromHtml(newsItem.getDescription()));

        Cursor cursor = context.getContentResolver().query(PhotosColumns.CONTENT_URI, null,
                PhotosColumns.TASK_ID + " LIKE ?", new String[] { "" + newsItem.getDatabaseId() }, null);

        if (cursor != null) {
            List<String> photos = new ArrayList<>(cursor.getCount());

            while (cursor.moveToNext()) {
                photos.add(cursor.getString(cursor.getColumnIndex(PhotosColumns.URL)));
            }
            cursor.close();
            newsItem.setPhoto(photos);
        }

    } else {
        // If there is no outside intent - fetch example photos
        List<String> dummyPhotos = new ArrayList<>();
        dummyPhotos.addAll(Arrays.asList(getResources().getStringArray(R.array.task_image_links)));

        newsItem = new TaskItem();
        newsItem.setPhoto(dummyPhotos);
    }

    // To boost performance as we know that size won't change
    mRecyclerView.setHasFixedSize(true);

    // Horizontal LayoutManager
    RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(context, RecyclerView.HORIZONTAL, false);

    mRecyclerView.setLayoutManager(layoutManager);

    // Adapter with data about different activities
    PhotoAdapter photoAdapter = new PhotoAdapter(newsItem.getPhoto(), context, this);
    mRecyclerView.setAdapter(photoAdapter);

    return rootView;
}

From source file:com.antonioleiva.materializeyourapp.MainActivity.java

private void setRecyclerAdapter(final RecyclerView recyclerView) {
    RequestQueue queue = Volley.newRequestQueue(this);

    queue.add(new JsonObjectRequest(DATA_URL, null, new Response.Listener<JSONObject>() {
        @Override/*from   w  w w .  j  a  va2  s  .  c  o m*/
        public void onResponse(JSONObject response) {
            Gson gson = new Gson();
            NewsBeans news = gson.fromJson(response.toString(), NewsBeans.class);
            List<NewsModel> items = new ArrayList<>();
            for (NewsBeans.ArticlesBean articlesBean : news.getArticles()) {
                NewsModel model = new NewsModel(articlesBean.getTitle(),
                        articlesBean.getImages() != null ? articlesBean.getImages().get(0).getUrl()
                                : articlesBean.getListPic(),
                        Html.fromHtml(articlesBean.getContent()));
                items.add(model);
            }
            RecyclerViewAdapter adapter = new RecyclerViewAdapter(items);
            adapter.setOnItemClickListener(MainActivity.this);
            recyclerView.setAdapter(adapter);
        }
    }, null));
}

From source file:com.liato.bankdroid.banking.banks.PlusGirot.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   ww  w  .  j  a v a  2  s .  co m
    urlopen = login();
    try {
        Matcher matcher;
        matcher = reAccounts.matcher(response);
        if (matcher.find()) {
            /*
             * Capture groups:
             * GROUP                EXAMPLE DATA
             * 1: Account holder    Efternamn,Fornamn
             * 2: PG account        456 12 34-5
             * 3: Amount            123,45
             * 4: Credit            24,68
             *  
             */
            Account account = new Account(
                    matcher.group(2).trim() + " (" + Html.fromHtml(matcher.group(1)).toString().trim() + ")",
                    Helpers.parseBalance(matcher.group(3)), matcher.group(2).trim().replaceAll("[^0-9]*", ""));
            accounts.add(account);
            balance = balance.add(Helpers.parseBalance(matcher.group(3)));
        }

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

        matcher = reTransactions.matcher(response);
        ArrayList<Transaction> transactions = new ArrayList<Transaction>();
        while (matcher.find()) {
            /*
             * Capture groups:
             * GROUP                EXAMPLE DATA
             * 1: Date              2011-04-04
             * 2: Specification     UTTAG
             * 3: Payment code      Inr.
             * 4: Amount            -100,00
             *   
             */
            transactions.add(new Transaction(matcher.group(1).trim(),
                    Html.fromHtml(matcher.group(2)).toString().trim() + " "
                            + Html.fromHtml(matcher.group(3)).toString().trim(),
                    Helpers.parseBalance(matcher.group(4))));
        }
        accounts.get(0).setTransactions(transactions);
    } finally {
        super.updateComplete();
    }
}

From source file:com.pixellostudio.qqdroid.BaseQuote.java

public boolean onContextItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case 1:/* ww w  . j ava2 s .  co  m*/
        AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();

        Spanned quote = Html.fromHtml((String) view.getAdapter().getItem(menuInfo.position));

        Intent i = new Intent(Intent.ACTION_SEND);
        i.putExtra(Intent.EXTRA_TEXT,
                getBaseContext().getText(R.string.quotefrom) + " " + name + " : " + quote);
        i.setType("text/plain");
        startActivity(Intent.createChooser(i, this.getText(R.string.share)));

        break;
    default:
        return super.onContextItemSelected(item);
    }
    return true;
}