Example usage for android.text.style UnderlineSpan UnderlineSpan

List of usage examples for android.text.style UnderlineSpan UnderlineSpan

Introduction

In this page you can find the example usage for android.text.style UnderlineSpan UnderlineSpan.

Prototype

public UnderlineSpan() 

Source Link

Document

Creates an UnderlineSpan .

Usage

From source file:edu.berkeley.boinc.ProjectDetailsFragment.java

private void populateLayout() {

    if (project == null) {
        retryLayout = true;//from   www  .  ja va 2 s .  com
        return; // if data not available yet, return. frequently retrys with onReceive
    }

    retryLayout = false;
    View v = root;

    updateChangingItems(v);

    slideshowWrapper = (HorizontalScrollView) v.findViewById(R.id.slideshow_wrapper);
    slideshowHook = (LinearLayout) v.findViewById(R.id.slideshow_hook);
    slideshowLoading = (ProgressBar) v.findViewById(R.id.slideshow_loading);

    // set website
    TextView website = (TextView) v.findViewById(R.id.project_url);
    SpannableString content = new SpannableString(project.master_url);
    content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
    website.setText(content);
    website.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(project.master_url));
            startActivity(i);
        }
    });

    // set general area
    if (projectInfo != null && projectInfo.generalArea != null) {
        TextView generalArea = (TextView) v.findViewById(R.id.general_area);
        generalArea.setText(projectInfo.generalArea);
    } else {
        LinearLayout wrapper = (LinearLayout) v.findViewById(R.id.general_area_wrapper);
        wrapper.setVisibility(View.GONE);
    }

    // set specific area
    if (projectInfo != null && projectInfo.specificArea != null) {
        TextView specificArea = (TextView) v.findViewById(R.id.specific_area);
        specificArea.setText(projectInfo.specificArea);
    } else {
        LinearLayout wrapper = (LinearLayout) v.findViewById(R.id.specific_area_wrapper);
        wrapper.setVisibility(View.GONE);
    }

    // set description
    if (projectInfo != null && projectInfo.description != null) {
        TextView description = (TextView) v.findViewById(R.id.description);
        description.setText(projectInfo.description);
    } else {
        LinearLayout wrapper = (LinearLayout) v.findViewById(R.id.description_wrapper);
        wrapper.setVisibility(View.GONE);
    }

    // set home
    if (projectInfo != null && projectInfo.home != null) {
        TextView home = (TextView) v.findViewById(R.id.based_at);
        home.setText(projectInfo.home);
    } else {
        LinearLayout wrapper = (LinearLayout) v.findViewById(R.id.based_at_wrapper);
        wrapper.setVisibility(View.GONE);
    }

    // load slideshow
    new UpdateSlideshowImagesAsync().execute();
}

From source file:com.zulip.android.util.CustomHtmlToSpannedConverter.java

private void handleEndTag(String tag) {
    if (tag.equalsIgnoreCase("br")) {
        handleBr(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("p")) {
        handleP(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("div")) {
        handleP(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("strong")) {
        end(mSpannableStringBuilder, Bold.class, new StyleSpan(Typeface.BOLD));
    } else if (tag.equalsIgnoreCase("b")) {
        end(mSpannableStringBuilder, Bold.class, new StyleSpan(Typeface.BOLD));
    } else if (tag.equalsIgnoreCase("em")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("cite")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("dfn")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("i")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("big")) {
        end(mSpannableStringBuilder, Big.class, new RelativeSizeSpan(1.25f));
    } else if (tag.equalsIgnoreCase("small")) {
        end(mSpannableStringBuilder, Small.class, new RelativeSizeSpan(0.8f));
    } else if (tag.equalsIgnoreCase("font")) {
        endFont(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("blockquote")) {
        handleP(mSpannableStringBuilder);
        end(mSpannableStringBuilder, Blockquote.class, new CustomQuoteSpan());
    } else if (tag.equalsIgnoreCase("tt")) {
        end(mSpannableStringBuilder, Monospace.class, new TypefaceSpan(MONOSPACE));
    } else if (tag.equalsIgnoreCase("a")) {
        endA(mSpannableStringBuilder);//from  ww w.  j a  v  a 2 s.  c  o m
    } else if (tag.equalsIgnoreCase("span")) {
        endSpan(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("u")) {
        end(mSpannableStringBuilder, Underline.class, new UnderlineSpan());
    } else if (tag.equalsIgnoreCase("sup")) {
        end(mSpannableStringBuilder, Super.class, new SuperscriptSpan());
    } else if (tag.equalsIgnoreCase("sub")) {
        end(mSpannableStringBuilder, Sub.class, new SubscriptSpan());
    } else if (tag.equalsIgnoreCase("code")) {
        endMultiple(mSpannableStringBuilder, InlineCode.class,
                new Object[] { new TypefaceSpan(MONOSPACE), new ForegroundColorSpan(0xffdd1144) // pink
                });
    } else if (tag.equalsIgnoreCase("pre")) {
        end(mSpannableStringBuilder, CodeBlock.class, new TypefaceSpan(MONOSPACE));
    } else if (tag.length() == 2 && Character.toLowerCase(tag.charAt(0)) == 'h' && tag.charAt(1) >= '1'
            && tag.charAt(1) <= '6') {
        handleP(mSpannableStringBuilder);
        endHeader(mSpannableStringBuilder);
    } else if (mTagHandler != null) {
        mTagHandler.handleTag(false, tag, mSpannableStringBuilder, mReader);
    }
}

From source file:com.barbrdo.app.activities.UserProfileActivity.java

@Override
void bindControls() {
    editTextPhone.addTextChangedListener(new PhoneNumberFormattingTextWatcher(editTextPhone));
    imageViewProfilePicture.setOnClickListener(this);
    textViewSearchRadius.setOnClickListener(this);
    textViewChangePassword.setOnClickListener(this);
    SpannableString content = new SpannableString(getString(R.string.change_password));
    content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
    textViewChangePassword.setText(content);

    getView(R.id.cv_password_change).setVisibility(View.GONE);
    textViewCancel.setOnClickListener(this);
    textViewUpgrade.setOnClickListener(this);
}

From source file:org.mozilla.gecko.home.HistoryPanel.java

/**
 * Make Span that is clickable, italicized, and underlined
 * between the string markers <code>FORMAT_S1</code> and
 * <code>FORMAT_S2</code>./* w w w  .  j  a v  a 2 s.  c o  m*/
 *
 * @param text String to format
 * @return formatted SpannableStringBuilder, or null if there
 * is not any text to format.
 */
private SpannableStringBuilder formatHintText(String text) {
    // Set formatting as marked by string placeholders.
    final int underlineStart = text.indexOf(FORMAT_S1);
    final int underlineEnd = text.indexOf(FORMAT_S2);

    // Check that there is text to be formatted.
    if (underlineStart >= underlineEnd) {
        return null;
    }

    final SpannableStringBuilder ssb = new SpannableStringBuilder(text);

    // Set italicization.
    ssb.setSpan(new StyleSpan(Typeface.ITALIC), 0, ssb.length(), 0);

    // Set clickable text.
    final ClickableSpan clickableSpan = new ClickableSpan() {
        @Override
        public void onClick(View widget) {
            Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.HOMESCREEN,
                    "hint-private-browsing");
            try {
                final JSONObject json = new JSONObject();
                json.put("type", "Menu:Open");
                EventDispatcher.getInstance().dispatchEvent(json, null);
            } catch (JSONException e) {
                Log.e(LOGTAG, "Error forming JSON for Private Browsing contextual hint", e);
            }
        }
    };

    ssb.setSpan(clickableSpan, 0, text.length(), 0);

    // Remove underlining set by ClickableSpan.
    final UnderlineSpan noUnderlineSpan = new UnderlineSpan() {
        @Override
        public void updateDrawState(TextPaint textPaint) {
            textPaint.setUnderlineText(false);
        }
    };

    ssb.setSpan(noUnderlineSpan, 0, text.length(), 0);

    // Add underlining for "Private Browsing".
    ssb.setSpan(new UnderlineSpan(), underlineStart, underlineEnd, 0);

    ssb.delete(underlineEnd, underlineEnd + FORMAT_S2.length());
    ssb.delete(underlineStart, underlineStart + FORMAT_S1.length());

    return ssb;
}

From source file:piuk.blockchain.android.ui.dialogs.TransactionSummaryDialog.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    super.onCreateDialog(savedInstanceState);

    final FragmentActivity activity = getActivity();

    final LayoutInflater inflater = LayoutInflater.from(activity);

    final Builder dialog = new AlertDialog.Builder(new ContextThemeWrapper(activity, R.style.Theme_Dialog))
            .setTitle(R.string.transaction_summary_title);

    final LinearLayout view = (LinearLayout) inflater.inflate(R.layout.transaction_summary_fragment, null);

    dialog.setView(view);//from  ww  w .j  a va 2  s  .c  om

    try {
        final MyRemoteWallet wallet = application.getRemoteWallet();

        BigInteger totalOutputValue = BigInteger.ZERO;
        for (TransactionOutput output : tx.getOutputs()) {
            totalOutputValue = totalOutputValue.add(output.getValue());
        }

        final TextView resultDescriptionView = (TextView) view.findViewById(R.id.result_description);
        final TextView toView = (TextView) view.findViewById(R.id.transaction_to);
        final TextView toViewLabel = (TextView) view.findViewById(R.id.transaction_to_label);
        final View toViewContainer = (View) view.findViewById(R.id.transaction_to_container);
        final TextView hashView = (TextView) view.findViewById(R.id.transaction_hash);
        final TextView transactionTimeView = (TextView) view.findViewById(R.id.transaction_date);
        final TextView confirmationsView = (TextView) view.findViewById(R.id.transaction_confirmations);
        final TextView noteView = (TextView) view.findViewById(R.id.transaction_note);
        final Button addNoteButton = (Button) view.findViewById(R.id.add_note_button);
        final TextView feeView = (TextView) view.findViewById(R.id.transaction_fee);
        final View feeViewContainer = view.findViewById(R.id.transaction_fee_container);
        final TextView valueNowView = (TextView) view.findViewById(R.id.transaction_value);
        final View valueNowContainerView = view.findViewById(R.id.transaction_value_container);

        String to = null;
        for (TransactionOutput output : tx.getOutputs()) {
            try {
                String toAddress = output.getScriptPubKey().getToAddress().toString();
                if (!wallet.isAddressMine(toAddress)) {
                    to = toAddress;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String from = null;
        for (TransactionInput input : tx.getInputs()) {
            try {
                String fromAddress = input.getFromAddress().toString();
                if (!wallet.isAddressMine(fromAddress)) {
                    from = fromAddress;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        long realResult = 0;
        int confirmations = 0;

        if (tx instanceof MyTransaction) {
            MyTransaction myTx = (MyTransaction) tx;

            realResult = myTx.getResult().longValue();

            if (wallet.getLatestBlock() != null) {
                confirmations = wallet.getLatestBlock().getHeight() - myTx.getHeight() + 1;
            }

        } else if (application.isInP2PFallbackMode()) {
            realResult = tx.getValue(application.bitcoinjWallet).longValue();

            if (tx.getConfidence().getConfidenceType() == ConfidenceType.BUILDING)
                confirmations = tx.getConfidence().getDepthInBlocks();
        }

        final long finalResult = realResult;

        if (realResult <= 0) {
            toViewLabel.setText(R.string.transaction_fragment_to);

            if (to == null) {
                ((LinearLayout) toViewContainer.getParent()).removeView(toViewContainer);
            } else {
                toView.setText(to);
            }
        } else {
            toViewLabel.setText(R.string.transaction_fragment_from);

            if (from == null) {
                ((LinearLayout) toViewContainer.getParent()).removeView(toViewContainer);
            } else {
                toView.setText(from);
            }
        }

        //confirmations view
        if (confirmations > 0) {
            confirmationsView.setText("" + confirmations);
        } else {
            confirmationsView.setText("Unconfirmed");
        }

        //Hash String view
        final String hashString = new String(Hex.encode(tx.getHash().getBytes()), "UTF-8");

        hashView.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                        Uri.parse("https:/" + Constants.BLOCKCHAIN_DOMAIN + "/tx/" + hashString));

                startActivity(browserIntent);
            }
        });

        //Notes View
        String note = wallet.getTxNotes().get(hashString);

        if (note == null) {
            addNoteButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    dismiss();

                    AddNoteDialog.showDialog(getFragmentManager(), hashString);
                }
            });

            view.removeView(noteView);
        } else {
            view.removeView(addNoteButton);

            noteView.setText(note);

            noteView.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    dismiss();

                    AddNoteDialog.showDialog(getFragmentManager(), hashString);
                }
            });
        }

        addNoteButton.setEnabled(!application.isInP2PFallbackMode());

        SpannableString content = new SpannableString(hashString);
        content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
        hashView.setText(content);

        if (realResult > 0 && from != null)
            resultDescriptionView.setText(this.getString(R.string.transaction_fragment_amount_you_received,
                    WalletUtils.formatValue(BigInteger.valueOf(realResult))));
        else if (realResult < 0 && to != null)
            resultDescriptionView.setText(this.getString(R.string.transaction_fragment_amount_you_sent,
                    WalletUtils.formatValue(BigInteger.valueOf(realResult))));
        else
            resultDescriptionView.setText(this.getString(R.string.transaction_fragment_amount_you_moved,
                    WalletUtils.formatValue(totalOutputValue)));

        final Date time = tx.getUpdateTime();

        transactionTimeView.setText(dateFormat.format(time));

        //These will be made visible again later once information is fetched from server
        feeViewContainer.setVisibility(View.GONE);
        valueNowContainerView.setVisibility(View.GONE);

        if (tx instanceof MyTransaction) {
            MyTransaction myTx = (MyTransaction) tx;

            final long txIndex = myTx.getTxIndex();

            final Handler handler = new Handler();

            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        final JSONObject obj = getTransactionSummary(txIndex, wallet.getGUID(), finalResult);

                        handler.post(new Runnable() {
                            @Override
                            public void run() {
                                try {
                                    if (obj.get("fee") != null) {
                                        feeViewContainer.setVisibility(View.VISIBLE);

                                        feeView.setText(WalletUtils.formatValue(
                                                BigInteger.valueOf(Long.valueOf(obj.get("fee").toString())))
                                                + " BTC");
                                    }

                                    if (obj.get("confirmations") != null) {
                                        int confirmations = ((Number) obj.get("confirmations")).intValue();

                                        confirmationsView.setText("" + confirmations);
                                    }

                                    String result_local = (String) obj.get("result_local");
                                    String result_local_historical = (String) obj
                                            .get("result_local_historical");

                                    if (result_local != null && result_local.length() > 0) {
                                        valueNowContainerView.setVisibility(View.VISIBLE);

                                        if (result_local_historical == null
                                                || result_local_historical.length() == 0
                                                || result_local_historical.equals(result_local)) {
                                            valueNowView.setText(result_local);
                                        } else {
                                            valueNowView.setText(getString(R.string.value_now_ten, result_local,
                                                    result_local_historical));
                                        }
                                    }
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                        });
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }).start();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    Dialog d = dialog.create();

    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();

    lp.dimAmount = 0;
    lp.width = WindowManager.LayoutParams.FILL_PARENT;
    lp.height = WindowManager.LayoutParams.WRAP_CONTENT;

    d.show();

    d.getWindow().setAttributes(lp);

    d.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

    return d;
}

From source file:liqui.droid.activity.Base.java

/**
 * Creates the breadcrumb./*from  w w w . j av a  2 s . c  om*/
 *
 * @param subTitle the sub title
 * @param breadCrumbHolders the bread crumb holders
 */
public void createBreadcrumb(String subTitle, BreadCrumbHolder... breadCrumbHolders) {
    if (breadCrumbHolders != null) {
        LinearLayout llPart = (LinearLayout) this.findViewById(R.id.ll_part);
        for (int i = 0; i < breadCrumbHolders.length; i++) {
            TextView tvBreadCrumb = new TextView(getApplication());
            SpannableString part = new SpannableString(breadCrumbHolders[i].getLabel());
            part.setSpan(new UnderlineSpan(), 0, part.length(), 0);
            tvBreadCrumb.append(part);
            tvBreadCrumb.setTag(breadCrumbHolders[i]);
            tvBreadCrumb.setBackgroundResource(R.drawable.default_link);
            tvBreadCrumb.setTextAppearance(getApplication(), R.style.default_text_small);
            tvBreadCrumb.setSingleLine(true);
            tvBreadCrumb.setOnClickListener(new OnClickBreadCrumb(this));

            llPart.addView(tvBreadCrumb);

            if (i < breadCrumbHolders.length - 1) {
                TextView slash = new TextView(getApplication());
                slash.setText(" / ");
                slash.setTextAppearance(getApplication(), R.style.default_text_small);
                llPart.addView(slash);
            }
        }
    }

    ScrollingTextView tvSubtitle = (ScrollingTextView) this.findViewById(R.id.tv_subtitle);
    tvSubtitle.setText(subTitle);
}

From source file:android.melbournehistorymap.MapsActivity.java

/**
 * Manipulates the map once available./*from  w ww  .j  a  va 2s  .com*/
 * This callback is triggered when the map is ready to be used.
 * This is where we can add markers or lines, add listeners or move the camera. In this case,
 * we just add a marker near Sydney, Australia.
 * If Google Play services is not installed on the device, the user will be prompted to install
 * it inside the SupportMapFragment. This method will only be triggered once the user has
 * installed Google Play services and returned to the app.
 */
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    spinner = (ProgressBar) findViewById(R.id.prograssSpinner);
    //check if permission has been granted
    if (ActivityCompat.checkSelfPermission(this,
            Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
            && ActivityCompat.checkSelfPermission(this,
                    Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        // Permission has already been granted
        return;
    }
    mMap.setMyLocationEnabled(true);
    mMap.getUiSettings().setZoomControlsEnabled(false);

    double lat;
    double lng;
    final int radius;
    int zoom;

    lat = Double.parseDouble(CurrLat);
    lng = Double.parseDouble(CurrLong);

    //build current location
    LatLng currentLocation = new LatLng(lat, lng);
    final LatLng realLocation = currentLocation;

    if (MELBOURNE.contains(currentLocation)) {
        mMap.getUiSettings().setMyLocationButtonEnabled(true);
        zoom = 17;
    } else {
        mMap.getUiSettings().setMyLocationButtonEnabled(false);
        lat = -37.81161508043379;
        lng = 144.9647320434451;
        zoom = 15;
        currentLocation = new LatLng(lat, lng);
    }

    mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(currentLocation, 13));

    CameraPosition cameraPosition = new CameraPosition.Builder().target(currentLocation) // Sets the center of the map to location user
            .zoom(zoom) // Sets the zoom
            .bearing(0) // Sets the orientation of the camera to east
            .tilt(25) // Sets the tilt of the camera to 30 degrees
            .build(); // Creates a CameraPosition from the builder

    //Animate user to map location, if in Melbourne or outside of Melbourne bounds
    mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition),
            new GoogleMap.CancelableCallback() {
                @Override
                public void onFinish() {
                    updateMap();
                }

                @Override
                public void onCancel() {

                }
            });

    final TextView placeTitle = (TextView) findViewById(R.id.placeTitle);
    final TextView placeVic = (TextView) findViewById(R.id.placeVic);
    final TextView expPlaceTitle = (TextView) findViewById(R.id.expPlaceTitle);
    final TextView expPlaceVic = (TextView) findViewById(R.id.expPlaceVic);
    final TextView expPlaceDescription = (TextView) findViewById(R.id.placeDescription);
    final TextView wikiLicense = (TextView) findViewById(R.id.wikiLicense);
    final TextView expPlaceDistance = (TextView) findViewById(R.id.expPlaceDistance);
    final RelativeLayout tile = (RelativeLayout) findViewById(R.id.tile);
    final TextView fab = (TextView) findViewById(R.id.fab);
    final RelativeLayout distanceCont = (RelativeLayout) findViewById(R.id.distanceContainer);

    //        String license = "Text is available under the <a rel=\"license\" href=\"//en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License\">Creative Commons Attribution-ShareAlike License</a><a rel=\"license\" href=\"//creativecommons.org/licenses/by-sa/3.0/\" style=\"display:none;\"></a>;\n" +
    //                "additional terms may apply.";
    //        wikiLicense.setText(Html.fromHtml(license));
    //        wikiLicense.setMovementMethod(LinkMovementMethod.getInstance());
    //Marker click
    mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {

        @Override
        public boolean onMarkerClick(Marker marker) {
            String title = marker.getTitle();
            mMap.setPadding(0, 0, 0, 620);
            //set clicked marker to full opacity
            marker.setAlpha(1f);
            //set previous marker back to partial opac (if there is a prevMarker
            if (dirtyMarker == 1) {
                prevMarker.setAlpha(0.6f);
            }
            prevMarker = marker;
            dirtyMarker = 1;

            //Set DB helper
            DBHelper myDBHelper = new DBHelper(MapsActivity.this, WikiAPI.DB_NAME, null, WikiAPI.VERSION);

            //Only search for Wiki API requests if no place article returned.
            // **
            //Open DB as readable only.
            SQLiteDatabase db = myDBHelper.getReadableDatabase();
            //Set the query
            String dbFriendlyName = title.replace("\'", "\'\'");
            //Limit by 1 rows
            Cursor cursor = db.query(DBHelper.TABLE_NAME, null, "PLACE_NAME = '" + dbFriendlyName + "'", null,
                    null, null, null, "1");

            //move through each row returned in the query results
            while (cursor.moveToNext()) {

                String place_ID = cursor.getString(cursor.getColumnIndex("PLACE_ID"));
                String placeName = cursor.getString(cursor.getColumnIndex("PLACE_NAME"));
                String placeLoc = cursor.getString(cursor.getColumnIndex("PLACE_LOCATION"));
                String placeArticle = cursor.getString(cursor.getColumnIndex("ARTICLE"));
                String placeLat = cursor.getString(cursor.getColumnIndex("LAT"));
                String placeLng = cursor.getString(cursor.getColumnIndex("LNG"));

                //Get Google Place photos
                //Source: https://developers.google.com/places/android-api/photos
                final String placeId = place_ID;
                Places.GeoDataApi.getPlacePhotos(mGoogleApiClient, placeId)
                        .setResultCallback(new ResultCallback<PlacePhotoMetadataResult>() {
                            @Override
                            public void onResult(PlacePhotoMetadataResult photos) {
                                if (!photos.getStatus().isSuccess()) {
                                    return;
                                }
                                ImageView mImageView = (ImageView) findViewById(R.id.imageView);
                                ImageView mImageViewExpanded = (ImageView) findViewById(R.id.headerImage);
                                TextView txtAttribute = (TextView) findViewById(R.id.photoAttribute);
                                TextView expTxtAttribute = (TextView) findViewById(R.id.expPhotoAttribute);
                                PlacePhotoMetadataBuffer photoMetadataBuffer = photos.getPhotoMetadata();
                                if (photoMetadataBuffer.getCount() > 0) {
                                    // Display the first bitmap in an ImageView in the size of the view
                                    photoMetadataBuffer.get(0).getScaledPhoto(mGoogleApiClient, 600, 200)
                                            .setResultCallback(mDisplayPhotoResultCallback);
                                    //get photo attributions
                                    PlacePhotoMetadata photo = photoMetadataBuffer.get(0);
                                    CharSequence attribution = photo.getAttributions();
                                    if (attribution != null) {
                                        txtAttribute.setText(Html.fromHtml(String.valueOf(attribution)));
                                        expTxtAttribute.setText(Html.fromHtml(String.valueOf(attribution)));
                                        //http://stackoverflow.com/questions/4303160/how-can-i-make-links-in-fromhtml-clickable-android
                                        txtAttribute.setMovementMethod(LinkMovementMethod.getInstance());
                                        expTxtAttribute.setMovementMethod(LinkMovementMethod.getInstance());
                                    } else {
                                        txtAttribute.setText(" ");
                                        expTxtAttribute.setText(" ");
                                    }
                                } else {
                                    //Reset image view as no photo was identified
                                    mImageView.setImageResource(android.R.color.transparent);
                                    mImageViewExpanded.setImageResource(android.R.color.transparent);
                                    txtAttribute.setText(R.string.no_photos);
                                    expTxtAttribute.setText(R.string.no_photos);
                                }
                                photoMetadataBuffer.release();
                            }
                        });

                LatLng destLocation = new LatLng(Double.parseDouble(placeLat), Double.parseDouble(placeLng));
                //Work out distance between current location and place location
                //Source Library: https://github.com/googlemaps/android-maps-utils
                double distance = SphericalUtil.computeDistanceBetween(realLocation, destLocation);
                distance = Math.round(distance);
                distance = distance * 0.001;
                String strDistance = String.valueOf(distance);
                String[] arrDistance = strDistance.split("\\.");
                String unit = "km";
                if (arrDistance[0] == "0") {
                    unit = "m";
                    strDistance = arrDistance[1];
                } else {
                    strDistance = arrDistance[0] + "." + arrDistance[1].substring(0, 1);
                }

                placeArticle = placeArticle
                        .replaceAll("(<div class=\"thumb t).*\\s.*\\s.*\\s.*\\s.*\\s<\\/div>\\s<\\/div>", " ");

                Spannable noUnderlineMessage = new SpannableString(Html.fromHtml(placeArticle));

                //http://stackoverflow.com/questions/4096851/remove-underline-from-links-in-textview-android
                for (URLSpan u : noUnderlineMessage.getSpans(0, noUnderlineMessage.length(), URLSpan.class)) {
                    noUnderlineMessage.setSpan(new UnderlineSpan() {
                        public void updateDrawState(TextPaint tp) {
                            tp.setUnderlineText(false);
                        }
                    }, noUnderlineMessage.getSpanStart(u), noUnderlineMessage.getSpanEnd(u), 0);
                }

                placeArticle = String.valueOf(noUnderlineMessage);
                placeArticle = placeArticle.replaceAll("(\\[\\d\\])", " ");

                placeTitle.setText(placeName);
                expPlaceTitle.setText(placeName);
                placeVic.setText(placeLoc);
                expPlaceVic.setText(placeLoc);
                expPlaceDescription.setText(placeArticle);
                if (MELBOURNE.contains(realLocation)) {
                    expPlaceDistance.setText("Distance: " + strDistance + unit);
                    distanceCont.setVisibility(View.VISIBLE);
                }
            }

            tile.setVisibility(View.VISIBLE);
            fab.setVisibility(View.VISIBLE);
            //Set to true to not show default behaviour.
            return false;
        }
    });

    mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
        @Override
        public void onMapClick(LatLng latLng) {
            int viewStatus = tile.getVisibility();
            if (viewStatus == View.VISIBLE) {
                tile.setVisibility(View.INVISIBLE);
                fab.setVisibility(View.INVISIBLE);
                //set previous marker back to partial opac (if there is a prevMarker
                if (dirtyMarker == 1) {
                    prevMarker.setAlpha(0.6f);
                }
            }

            mMap.setPadding(0, 0, 0, 0);
        }
    });

    FloatingActionButton shareIcon = (FloatingActionButton) findViewById(R.id.shareIcon);
    shareIcon.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //https://www.google.com.au/maps/place/Federation+Square/@-37.8179789,144.9668635,15z

            //Build implicit intent by triggering a SENDTO action, which will capture applications that allow for messages
            //that allow for messages to be sent to a specific user with data
            //http://developer.android.com/reference/android/content/Intent.html#ACTION_SENDTO
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("text/plain");
            //Build SMS
            String encodedPlace = "empty";
            try {
                encodedPlace = URLEncoder.encode(String.valueOf(expPlaceTitle.getText()), "UTF-8");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
            intent.putExtra(Intent.EXTRA_TEXT, String.valueOf(expPlaceTitle.getText())
                    + " \n\nhttps://www.google.com.au/maps/place/" + encodedPlace);
            Intent sms = Intent.createChooser(intent, null);
            startActivity(sms);
        }
    });

    TextView fullArticle = (TextView) findViewById(R.id.fullArticle);
    fullArticle.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String wikiPlace = WikiPlace.getName(String.valueOf(expPlaceTitle.getText()));
            String url = "https://en.wikipedia.org/wiki/" + wikiPlace;

            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
            startActivity(browserIntent);
        }
    });
}

From source file:com.nttec.everychan.ui.presentation.HtmlParser.java

private void handleEndTag(String tag) {
    if (tag.equalsIgnoreCase("br")) {
        handleBr(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("p")) {
        handleP(mSpannableStringBuilder, mStartLength, mLastPTagLength);
    } else if (tag.equalsIgnoreCase("div")) {
        handleP(mSpannableStringBuilder, mStartLength, mLastPTagLength);
    } else if (tag.equalsIgnoreCase("strong")) {
        end(mSpannableStringBuilder, Bold.class, new StyleSpan(Typeface.BOLD));
    } else if (tag.equalsIgnoreCase("b")) {
        end(mSpannableStringBuilder, Bold.class, new StyleSpan(Typeface.BOLD));
    } else if (tag.equalsIgnoreCase("em")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("cite")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("dfn")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("i")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("s")) {
        end(mSpannableStringBuilder, Strike.class, new StrikethroughSpan());
    } else if (tag.equalsIgnoreCase("strike")) {
        end(mSpannableStringBuilder, Strike.class, new StrikethroughSpan());
    } else if (tag.equalsIgnoreCase("del")) {
        end(mSpannableStringBuilder, Strike.class, new StrikethroughSpan());
    } else if (tag.equalsIgnoreCase("big")) {
        end(mSpannableStringBuilder, Big.class, new RelativeSizeSpan(1.25f));
    } else if (tag.equalsIgnoreCase("small")) {
        end(mSpannableStringBuilder, Small.class, new RelativeSizeSpan(0.8f));
    } else if (tag.equalsIgnoreCase("font")) {
        endFont(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("blockquote")) {
        handleP(mSpannableStringBuilder, mStartLength, mLastPTagLength);
        endBlockquote(mSpannableStringBuilder, mColors);
    } else if (tag.equalsIgnoreCase("tt")) {
        end(mSpannableStringBuilder, Monospace.class, new TypefaceSpan("monospace"));
    } else if (tag.equalsIgnoreCase("code")) {
        end(mSpannableStringBuilder, Monospace.class, new TypefaceSpan("monospace"));
    } else if (tag.equalsIgnoreCase("ul")) {
        if (!mListTags.isEmpty())
            mListTags.removeFirst();/*from w  w w  .java2s  .  co m*/
    } else if (tag.equalsIgnoreCase("ol")) {
        if (!mListTags.isEmpty())
            mListTags.removeFirst();
    } else if (tag.equalsIgnoreCase("li")) {
        //??  ?? <li>
    } else if (tag.equalsIgnoreCase("tr")) {
        handleTr(mSpannableStringBuilder, false);
    } else if (tag.equalsIgnoreCase("td")) {
        handleTd(mSpannableStringBuilder, false);
    } else if (tag.equalsIgnoreCase("a")) {
        endA(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("u")) {
        end(mSpannableStringBuilder, Underline.class, new UnderlineSpan());
    } else if (tag.equalsIgnoreCase("sup")) {
        end(mSpannableStringBuilder, Super.class, new SuperscriptSpan());
    } else if (tag.equalsIgnoreCase("sub")) {
        end(mSpannableStringBuilder, Sub.class, new SubscriptSpan());
    } else if (tag.length() == 2 && Character.toLowerCase(tag.charAt(0)) == 'h' && tag.charAt(1) >= '1'
            && tag.charAt(1) <= '6') {
        handleP(mSpannableStringBuilder, mStartLength, mLastPTagLength);
        endHeader(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("span")) {
        endSpan(mSpannableStringBuilder, mColors, mOpenSpoilers);
    } else if (tag.equalsIgnoreCase("aibquote")) {
        end(mSpannableStringBuilder, Aibquote.class,
                new ForegroundColorSpan(mColors != null ? mColors.quoteForeground : Color.GREEN));
    } else if (tag.equalsIgnoreCase("aibspoiler")) {
        endAibspoiler(mSpannableStringBuilder, mColors, mOpenSpoilers);
    } /* else if (mTagHandler != null) {
      mTagHandler.handleTag(false, tag, mSpannableStringBuilder, mReader);
      }*/
}

From source file:at.jclehner.rxdroid.DrugListActivity.java

@TargetApi(11)
private void updateDateString() {
    if (mCurrentDate == null)
        return;// w w w . ja v a 2 s.c om

    final SpannableString dateString = new SpannableString(
            DateFormat.getDateFormat(this).format(mCurrentDate.getTime()));

    if (isShowingCurrentDate())
        Util.applyStyle(dateString, new UnderlineSpan());

    Util.applyStyle(dateString, new RelativeSizeSpan(0.75f));
    getSupportActionBar().setSubtitle(dateString);
}