Example usage for android.widget TextView setMovementMethod

List of usage examples for android.widget TextView setMovementMethod

Introduction

In this page you can find the example usage for android.widget TextView setMovementMethod.

Prototype

public final void setMovementMethod(MovementMethod movement) 

Source Link

Document

Sets the android.text.method.MovementMethod for handling arrow key movement for this TextView.

Usage

From source file:android.melbournehistorymap.MapsActivity.java

/**
 * Manipulates the map once available./*from w w  w  .  j a  v  a 2  s. 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:org.rm3l.ddwrt.tiles.syslog.StatusSyslogTile.java

@Override
public void onLoadFinished(@NotNull Loader<NVRAMInfo> loader, @Nullable NVRAMInfo data) {
    //Set tiles//from  w  w  w.  j a  va  2 s . c  o  m
    Log.d(LOG_TAG, "onLoadFinished: loader=" + loader + " / data=" + data);

    layout.findViewById(R.id.tile_status_router_syslog_header_loading_view).setVisibility(View.GONE);
    layout.findViewById(R.id.tile_status_router_syslog_content_loading_view).setVisibility(View.GONE);
    layout.findViewById(R.id.tile_status_router_syslog_state).setVisibility(View.VISIBLE);
    layout.findViewById(R.id.tile_status_router_syslog_content).setVisibility(View.VISIBLE);

    if (data == null) {
        data = new NVRAMInfo().setException(new DDWRTNoDataException("No Data!"));
    }

    @NotNull
    final TextView errorPlaceHolderView = (TextView) this.layout
            .findViewById(R.id.tile_status_router_syslog_error);

    @Nullable
    final Exception exception = data.getException();

    if (!(exception instanceof DDWRTTileAutoRefreshNotAllowedException)) {

        if (exception == null) {
            errorPlaceHolderView.setVisibility(View.GONE);
        }

        final String syslogdEnabledPropertyValue = data.getProperty(SYSLOGD_ENABLE);
        final boolean isSyslogEnabled = "1".equals(syslogdEnabledPropertyValue);

        final TextView syslogState = (TextView) this.layout.findViewById(R.id.tile_status_router_syslog_state);

        final View syslogContentView = this.layout.findViewById(R.id.tile_status_router_syslog_content);
        final EditText filterEditText = (EditText) this.layout
                .findViewById(R.id.tile_status_router_syslog_filter);

        syslogState.setText(
                syslogdEnabledPropertyValue == null ? "-" : (isSyslogEnabled ? "Enabled" : "Disabled"));

        syslogState.setVisibility(mDisplayStatus ? View.VISIBLE : View.GONE);

        final TextView logTextView = (TextView) syslogContentView;
        if (isSyslogEnabled) {

            //Highlight textToFind for new log lines
            final String newSyslog = data.getProperty(SYSLOG, EMPTY_STRING);

            //Hide container if no data at all (no existing data, and incoming data is empty too)
            final View scrollView = layout.findViewById(R.id.tile_status_router_syslog_content_scrollview);

            //noinspection ConstantConditions
            Spanned newSyslogSpan = new SpannableString(newSyslog);

            final SharedPreferences sharedPreferences = this.mParentFragmentPreferences;
            final String existingSearch = sharedPreferences != null
                    ? sharedPreferences.getString(getFormattedPrefKey(LAST_SEARCH), null)
                    : null;

            if (!isNullOrEmpty(existingSearch)) {
                if (isNullOrEmpty(filterEditText.getText().toString())) {
                    filterEditText.setText(existingSearch);
                }
                if (!isNullOrEmpty(newSyslog)) {
                    //noinspection ConstantConditions
                    newSyslogSpan = findAndHighlightOutput(newSyslog, existingSearch);
                }
            }

            //                if (!(isNullOrEmpty(existingSearch) || isNullOrEmpty(newSyslog))) {
            //                    filterEditText.setText(existingSearch);
            //                    //noinspection ConstantConditions
            //                    newSyslogSpan = findAndHighlightOutput(newSyslog, existingSearch);
            //                }

            if (isNullOrEmpty(logTextView.getText().toString()) && isNullOrEmpty(newSyslog)) {
                scrollView.setVisibility(View.INVISIBLE);
            } else {
                scrollView.setVisibility(View.VISIBLE);

                logTextView.setMovementMethod(new ScrollingMovementMethod());

                logTextView.append(
                        new SpannableStringBuilder().append(Html.fromHtml("<br/>")).append(newSyslogSpan));
            }

            filterEditText.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    final int DRAWABLE_LEFT = 0;
                    final int DRAWABLE_TOP = 1;
                    final int DRAWABLE_RIGHT = 2;
                    final int DRAWABLE_BOTTOM = 3;

                    if (event.getAction() == MotionEvent.ACTION_UP) {
                        if (event.getRawX() >= (filterEditText.getRight()
                                - filterEditText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) {
                            //Reset everything
                            filterEditText.setText(EMPTY_STRING); //this will trigger the TextWatcher, thus disabling the "Find" button
                            //Highlight text in textview
                            final String currentText = logTextView.getText().toString();

                            logTextView.setText(currentText.replaceAll(SLASH_FONT_HTML, EMPTY_STRING)
                                    .replaceAll(FONT_COLOR_YELLOW_HTML, EMPTY_STRING));

                            if (sharedPreferences != null) {
                                final SharedPreferences.Editor editor = sharedPreferences.edit();
                                editor.putString(getFormattedPrefKey(LAST_SEARCH), EMPTY_STRING);
                                editor.apply();
                            }
                            return true;
                        }
                    }
                    return false;
                }
            });

            filterEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
                @Override
                public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                    if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                        final String textToFind = filterEditText.getText().toString();
                        if (isNullOrEmpty(textToFind)) {
                            //extra-check, even though we can be pretty sure the button is enabled only if textToFind is present
                            return true;
                        }
                        if (sharedPreferences != null) {
                            if (textToFind.equalsIgnoreCase(existingSearch)) {
                                //No need to go further as this is already the string we are looking for
                                return true;
                            }
                            final SharedPreferences.Editor editor = sharedPreferences.edit();
                            editor.putString(getFormattedPrefKey(LAST_SEARCH), textToFind);
                            editor.apply();
                        }
                        //Highlight text in textview
                        final String currentText = logTextView.getText().toString();

                        logTextView.setText(
                                findAndHighlightOutput(currentText.replaceAll(SLASH_FONT_HTML, EMPTY_STRING)
                                        .replaceAll(FONT_COLOR_YELLOW_HTML, EMPTY_STRING), textToFind));

                        return true;
                    }
                    return false;
                }
            });

        }
    }

    if (exception != null && !(exception instanceof DDWRTTileAutoRefreshNotAllowedException)) {
        //noinspection ThrowableResultOfMethodCallIgnored
        final Throwable rootCause = Throwables.getRootCause(exception);
        errorPlaceHolderView.setText("Error: " + (rootCause != null ? rootCause.getMessage() : "null"));
        final Context parentContext = this.mParentFragmentActivity;
        errorPlaceHolderView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                //noinspection ThrowableResultOfMethodCallIgnored
                if (rootCause != null) {
                    Toast.makeText(parentContext, rootCause.getMessage(), Toast.LENGTH_LONG).show();
                }
            }
        });
        errorPlaceHolderView.setVisibility(View.VISIBLE);
    }

    doneWithLoaderInstance(this, loader, R.id.tile_status_router_syslog_togglebutton_title,
            R.id.tile_status_router_syslog_togglebutton);

    Log.d(LOG_TAG, "onLoadFinished(): done loading!");
}

From source file:org.creativecommons.thelist.fragments.AccountFragment.java

@Override
public void onResume() {
    super.onResume();
    mContext = getActivity();//  w  w  w .j av a  2 s .c  o  m
    mMessageHelper = new MessageHelper(mContext);

    //Get account information
    String accountName = getActivity().getIntent().getStringExtra(ARG_ACCOUNT_NAME);
    final String accountType = getActivity().getIntent().getStringExtra(ARG_ACCOUNT_TYPE);
    mAuthTokenType = getActivity().getIntent().getStringExtra(ARG_AUTH_TYPE);
    if (mAuthTokenType == null)
        mAuthTokenType = AccountGeneral.AUTHTOKEN_TYPE_FULL_ACCESS;

    if (accountName != null) {
        ((EditText) getView().findViewById(R.id.accountName)).setText(accountName);
    }

    //UI Elements
    final Button cancelButton = (Button) getView().findViewById(R.id.cancelButton);
    final Button loginButton = (Button) getView().findViewById(R.id.loginButton);
    final Button signUpButton = (Button) getView().findViewById(R.id.signUpButton);
    final EditText accountEmailField = (EditText) getView().findViewById(R.id.accountName);
    final EditText accountPasswordField = (EditText) getView().findViewById(R.id.accountPassword);
    accountPasswordField.setTypeface(Typeface.DEFAULT);
    final TextView newAccountButton = (TextView) getView().findViewById(R.id.signUp);

    //Try Login on Click
    loginButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final String accountEmail = accountEmailField.getText().toString().trim();
            final String accountPassword = accountPasswordField.getText().toString().trim();

            if (accountEmail.isEmpty() || accountPassword.isEmpty()) {
                mMessageHelper.showDialog(mContext, getString(R.string.login_error_title),
                        getString(R.string.login_error_message));
            } else {
                ListUser mCurrentUser = new ListUser(getActivity());
                try {
                    mCurrentUser.userSignIn(accountEmail, accountPassword, mAuthTokenType,
                            new ListUser.AuthCallback() {
                                @Override
                                public void onSuccess(String authtoken) {
                                    //TODO: authtoken stuff
                                    Bundle data = new Bundle();

                                    data.putString(AccountManager.KEY_ACCOUNT_NAME, accountEmail);
                                    data.putString(AccountManager.KEY_ACCOUNT_TYPE, accountType);
                                    data.putString(AccountManager.KEY_AUTHTOKEN, authtoken);
                                    data.putString(PARAM_USER_PASS, accountPassword);

                                    //Create Bundle to create Account
                                    mCallback.onUserSignedIn(data);
                                }
                            });
                } catch (Exception e) {
                    Log.d("LoginFragment", e.getMessage());
                    //data.putString(KEY_ERROR_MESSAGE, e.getMessage());
                }
            }
        }
    });

    //Actually I need an account --> show user Sign Up Button
    if (newAccountButton != null) {
        newAccountButton.setMovementMethod(LinkMovementMethod.getInstance());
    }
    //TODO: hide loginButton and show signUpButton
    //        newAccountButton.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //
    //                //loginButton.setVisibility(View.GONE);
    //                //signUpButton.setVisibility(View.VISIBLE);
    //            }
    //        });

    //Cancel Activity
    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mCallback.onCancelLogin();
        }
    });

    //TODO: do when we have register user
    //        signUpButton.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                //TODO:userSignUp
    //                final String accountEmail = accountEmailField.getText().toString().trim();
    //                final String accountPassword = accountPasswordField.getText().toString().trim();
    //
    //                if (accountEmail.isEmpty() || accountPassword.isEmpty()) {
    //                    mMessageHelper.showDialog(mContext, getString(R.string.login_error_title),
    //                            getString(R.string.login_error_message));
    //                } else {
    //                    //TODO: Login User + save to sharedPreferences
    //                    ListUser mCurrentUser = new ListUser(getActivity());
    //                    try {
    //                        mCurrentUser.userSignUp(accountEmail, accountPassword, mAuthTokenType, new ListUser.AuthCallback() {
    //                            @Override
    //                            public void onSuccess(String authtoken) {
    //
    //                                Bundle data = new Bundle();
    //
    //                                data.putString(AccountManager.KEY_ACCOUNT_NAME, accountEmail);
    //                                data.putString(AccountManager.KEY_ACCOUNT_TYPE, accountType);
    //                                data.putString(AccountManager.KEY_AUTHTOKEN, authtoken);
    //                                data.putString(PARAM_USER_PASS, accountPassword);
    //
    //                                mCallback.onUserSignedUp(data);
    //                            }
    //                        });
    //                    } catch (Exception e) {
    //                        Log.d("LoginFragment", e.getMessage());
    //                    }
    //                }
    //            }
    //        });

}

From source file:org.sirimangalo.meditationplus.AdapterChat.java

@Override
public View getView(final int position, View convertView, ViewGroup parent) {

    View rowView;/* w w w  . j  av  a 2 s  .c o m*/

    if (convertView == null) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        rowView = inflater.inflate(R.layout.list_item_chat, parent, false);
    } else {
        rowView = convertView;
    }

    JSONObject p = values.get(position);
    try {
        int then = Integer.parseInt(p.getString("time"));
        long nowL = System.currentTimeMillis() / 1000;
        int now = (int) nowL;

        int ela = now - then;
        int day = 60 * 60 * 24;
        ela = ela > day ? day : ela;
        int intColor = 255 - Math.round((float) ela * 255 / day);
        intColor = intColor > 100 ? intColor : 100;
        String hexTransparency = Integer.toHexString(intColor);
        hexTransparency = hexTransparency.length() > 1 ? hexTransparency : "0" + hexTransparency;
        String hexColor = "#" + hexTransparency + "000000";
        int transparency = Color.parseColor(hexColor);

        TextView time = (TextView) rowView.findViewById(R.id.time);
        if (time != null) {
            String ts = null;
            ts = Utils.time2Ago(then);
            time.setText(ts);
            time.setTextColor(transparency);
        }

        TextView mess = (TextView) rowView.findViewById(R.id.message);
        if (mess != null) {

            final String username = p.getString("username");

            String messageString = p.getString("message");

            messageString = Html.fromHtml(messageString).toString();

            SpannableString messageSpan = Utils.replaceSmilies(context, messageString, intColor);

            if (messageString.contains("@" + loggedUser)) {
                int index = messageString.indexOf("@" + loggedUser);
                messageSpan.setSpan(new StyleSpan(Typeface.BOLD), index, index + loggedUser.length() + 1,
                        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                messageSpan.setSpan(new ForegroundColorSpan(Color.parseColor("#" + hexTransparency + "990000")),
                        index, index + loggedUser.length() + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            }

            for (String user : users) {
                if (!user.equals(loggedUser) && messageString.contains("@" + user)) {
                    int index = messageString.indexOf("@" + user);
                    messageSpan = Utils.createProfileSpan(context, index, index + user.length() + 1, user,
                            messageSpan);
                    messageSpan.setSpan(
                            new ForegroundColorSpan(Color.parseColor("#" + hexTransparency + "009900")), index,
                            index + user.length() + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                }
            }

            Spannable userSpan = Utils.createProfileSpan(context, 0, username.length(), username,
                    new SpannableString(username + ": "));

            if (p.getString("me").equals("true"))
                userSpan.setSpan(new ForegroundColorSpan(Color.parseColor("#" + hexTransparency + "0000FF")), 0,
                        userSpan.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            else
                userSpan.setSpan(new ForegroundColorSpan(Color.parseColor("#" + hexTransparency + "000000")), 0,
                        userSpan.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

            CharSequence full = TextUtils.concat(userSpan, messageSpan);

            mess.setTextColor(transparency);
            mess.setText(full);
            mess.setMovementMethod(LinkMovementMethod.getInstance());
            Linkify.addLinks(mess, Linkify.ALL);
            mess.setTag(p.getString("cid"));
        }

    } catch (JSONException e) {
        e.printStackTrace();
    }
    return rowView;

}

From source file:com.heath_bar.tvdb.SeriesOverview.java

/** Populate the interface with the data pulled from the webz */
private void PopulateStuff(TvSeries seriesInfo) {

    if (seriesInfo == null) {
        Toast.makeText(getApplicationContext(), "Something bad happened. No data was found.",
                Toast.LENGTH_SHORT).show();
        return;//from w w  w  . j  av a  2s.  co m
    }

    // Set title
    getSupportActionBar().setTitle(seriesInfo.getName());

    // Hide/Activate the favorites button
    if (seriesInfo.isFavorite(getApplicationContext())) {
        Button b = (Button) findViewById(R.id.btn_add_to_favorites);
        b.setVisibility(View.GONE);
    } else {
        Button b = (Button) findViewById(R.id.btn_add_to_favorites);
        b.setVisibility(View.VISIBLE);
        b.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Button b = (Button) findViewById(R.id.btn_add_to_favorites);
                b.setVisibility(View.GONE);
                addToFavorites();
            }
        });
    }

    // Set the banner
    ImageView imageView = (ImageView) findViewById(R.id.series_banner);
    imageView.setImageBitmap(seriesInfo.getImage().getBitmap());
    imageView.setVisibility(View.VISIBLE);
    final String seriesName = seriesInfo.getName();

    imageView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            shareImage();
        }
    });

    // Set the banner link
    TextView textview = (TextView) findViewById(R.id.banner_listing_link);
    textview.setTextColor(getResources().getColor(R.color.tvdb_green));
    textview.setVisibility(View.VISIBLE);
    textview.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent i = new Intent(getApplicationContext(), BannerListing.class);
            i.putExtra("seriesId", seriesId);
            i.putExtra("seriesName", seriesName);
            startActivity(i);
        }
    });

    // Set air info
    textview = (TextView) findViewById(R.id.airs_header);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.last_episode);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.next_episode);
    textview.setVisibility(View.VISIBLE);

    textview = (TextView) findViewById(R.id.series_air_info);
    StringBuffer sb = new StringBuffer();
    sb.append(seriesInfo.getAirDay());
    if (!seriesInfo.getAirTime().equals(""))
        sb.append(" at " + seriesInfo.getAirTime());
    if (!seriesInfo.getNetwork().equals(""))
        sb.append(" on " + seriesInfo.getNetwork());
    textview.setText(sb.toString());
    textview.setVisibility(View.VISIBLE);

    // Set actors
    textview = (TextView) findViewById(R.id.starring);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.series_actors);
    textview.setVisibility(View.VISIBLE);

    SpannableStringBuilder text = tagsBuilder(seriesInfo.getActors(), "|");
    textview.setText(text, BufferType.SPANNABLE);
    textview.setMovementMethod(LinkMovementMethod.getInstance());

    // Set rating
    textview = (TextView) findViewById(R.id.rating_header);
    textview.setVisibility(View.VISIBLE);

    textview = (TextView) findViewById(R.id.rating);
    textview.setText(seriesInfo.getRating() + " / 10");
    textview.setVisibility(View.VISIBLE);

    // Set genre
    textview = (TextView) findViewById(R.id.genre_header);
    textview.setVisibility(View.VISIBLE);

    textview = (TextView) findViewById(R.id.genre);
    textview.setText(StringUtil.commafy(seriesInfo.getGenre()));
    textview.setVisibility(View.VISIBLE);

    // Set runtime
    textview = (TextView) findViewById(R.id.runtime_header);
    textview.setVisibility(View.VISIBLE);

    textview = (TextView) findViewById(R.id.runtime);
    textview.setText(seriesInfo.getRuntime() + " minutes");
    textview.setVisibility(View.VISIBLE);

    // Set overview
    textview = (TextView) findViewById(R.id.overview_header);
    textview.setVisibility(View.VISIBLE);

    textview = (TextView) findViewById(R.id.overview);
    textview.setText(seriesInfo.getOverview());
    textview.setVisibility(View.VISIBLE);

    // Show Seasons header
    textview = (TextView) findViewById(R.id.seasons_header);
    textview.setVisibility(View.VISIBLE);

    // IMDB Link
    textview = (TextView) findViewById(R.id.imdb_link);
    textview.setVisibility(View.VISIBLE);

    final String imdbId = seriesInfo.getIMDB();
    SpannableStringBuilder ssb = new SpannableStringBuilder(getResources().getString(R.string.imdb));
    ssb.setSpan(new NonUnderlinedClickableSpan(getResources().getString(R.string.imdb)) {
        @Override
        public void onClick(View v) {
            Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.imdb.com/title/" + imdbId));
            startActivity(myIntent);
        }
    }, 0, ssb.length(), 0);

    ssb.setSpan(new TextAppearanceSpan(this, R.style.episode_link), 0, ssb.length(), 0); // Set the style of the text
    textview.setText(ssb, BufferType.SPANNABLE);
    textview.setMovementMethod(LinkMovementMethod.getInstance());
}

From source file:ru.valle.btc.MainActivity.java

private void showQRCodePopupForAddress(final String address) {
    DisplayMetrics dm = getResources().getDisplayMetrics();
    final int screenSize = Math.min(dm.widthPixels, dm.heightPixels);
    final String uriStr = SCHEME_BITCOIN + address;
    new AsyncTask<Void, Void, Bitmap>() {

        @Override//from w  w w.j a  v a  2 s  . c  o  m
        protected Bitmap doInBackground(Void... params) {
            return QRCode.getMinimumQRCode(uriStr, ErrorCorrectLevel.M).createImage(screenSize / 2);
        }

        @Override
        protected void onPostExecute(final Bitmap bitmap) {
            if (bitmap != null) {
                View view = getLayoutInflater().inflate(R.layout.address_qr, mainLayout, false);
                if (view != null) {
                    final ImageView qrView = (ImageView) view.findViewById(R.id.qr_code_image);
                    qrView.setImageBitmap(bitmap);

                    final TextView bitcoinProtocolLinkView = (TextView) view.findViewById(R.id.link1);
                    SpannableStringBuilder labelUri = new SpannableStringBuilder(uriStr);
                    ClickableSpan urlSpan = new ClickableSpan() {
                        @Override
                        public void onClick(View widget) {
                            Intent intent = new Intent(Intent.ACTION_VIEW);
                            intent.setData(Uri.parse(uriStr));
                            try {
                                startActivity(intent);
                            } catch (Exception e) {
                                Toast.makeText(MainActivity.this, R.string.no_apps_to_view_url,
                                        Toast.LENGTH_LONG).show();
                            }
                        }
                    };
                    labelUri.setSpan(urlSpan, 0, labelUri.length(),
                            SpannableStringBuilder.SPAN_INCLUSIVE_INCLUSIVE);
                    bitcoinProtocolLinkView.setText(labelUri);
                    bitcoinProtocolLinkView.setMovementMethod(LinkMovementMethod.getInstance());

                    final TextView blockexplorerLinkView = (TextView) view.findViewById(R.id.link2);
                    SpannableStringBuilder blockexplorerLinkText = new SpannableStringBuilder(
                            "blockexplorer.com");
                    setUrlSpanForAddress("blockexplorer.com", address, blockexplorerLinkText);
                    blockexplorerLinkView.setText(blockexplorerLinkText);
                    blockexplorerLinkView.setMovementMethod(LinkMovementMethod.getInstance());

                    final TextView blockchainLinkView = (TextView) view.findViewById(R.id.link3);
                    SpannableStringBuilder blockchainLinkText = new SpannableStringBuilder("blockchain.info");
                    setUrlSpanForAddress("blockchain.info", address, blockchainLinkText);
                    blockchainLinkView.setText(blockchainLinkText);
                    blockchainLinkView.setMovementMethod(LinkMovementMethod.getInstance());

                    AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                    builder.setTitle(address);
                    builder.setView(view);
                    if (systemSupportsPrint()) {
                        builder.setPositiveButton(R.string.print, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                Renderer.printQR(MainActivity.this, SCHEME_BITCOIN + address);
                            }
                        });
                        builder.setNegativeButton(android.R.string.cancel, null);
                    } else {
                        builder.setPositiveButton(android.R.string.ok, null);
                    }

                    builder.show();
                }
            }
        }
    }.execute();
}

From source file:com.tweetlanes.android.view.ProfileFragment.java

void configureView() {

    TextView fullNameTextView = (TextView) mProfileView.findViewById(R.id.fullNameTextView);
    TextView followingTextView = (TextView) mProfileView.findViewById(R.id.followState);
    TextView descriptionTextView = (TextView) mProfileView.findViewById(R.id.bioTextView);
    TextView tweetCount = (TextView) mProfileView.findViewById(R.id.tweetCountLabel);
    TextView followingCount = (TextView) mProfileView.findViewById(R.id.followingCountLabel);
    TextView followersCount = (TextView) mProfileView.findViewById(R.id.followersCountLabel);
    TextView favoritesCount = (TextView) mProfileView.findViewById(R.id.favorites_count);
    LinearLayout linkLayout = (LinearLayout) mProfileView.findViewById(R.id.linkLayout);
    TextView link = (TextView) mProfileView.findViewById(R.id.link);
    LinearLayout locationLayout = (LinearLayout) mProfileView.findViewById(R.id.locationLayout);
    TextView location = (TextView) mProfileView.findViewById(R.id.location);
    LinearLayout detailsLayout = (LinearLayout) mProfileView.findViewById(R.id.detailsLayout);
    ImageView privateAccountImage = (ImageView) mProfileView.findViewById(R.id.private_account_image);
    mFriendshipButton = (Button) mProfileView.findViewById(R.id.friendship_button);
    mFriendshipDivider = (View) mProfileView.findViewById(R.id.friendship_divider);

    if (mUser != null) {
        ImageView avatar = (ImageView) mProfileView.findViewById(R.id.profileImage);
        //String imageUrl = TwitterManager.getProfileImageUrl(mUser.getScreenName(), TwitterManager.ProfileImageSize.ORIGINAL);
        String imageUrl = mUser.getProfileImageUrl(TwitterManager.ProfileImageSize.ORIGINAL);
        UrlImageViewHelper.setUrlDrawable(avatar, imageUrl, R.drawable.ic_contact_picture);
        //avatar.setImageURL(imageUrl);

        ImageView coverImage = (ImageView) mProfileView.findViewById(R.id.coverImage);
        if (coverImage != null) {
            String url = mUser.getCoverImageUrl();
            if (url != null) {
                UrlImageViewHelper.setUrlDrawable(coverImage, url, R.drawable.ic_contact_picture);
            }/*w  ww .  j  av a2s . c  om*/
        }

        fullNameTextView.setText(mUser.getName());
        if (mFollowsLoggedInUser != null && mFollowsLoggedInUser.booleanValue() == true) {
            followingTextView.setText(R.string.follows_you);
        } else {
            followingTextView.setText(null);
        }

        String description = mUser.getDescription();
        if (description != null) {
            String descriptionMarkup = TwitterUtil.getTextMarkup(description);
            descriptionTextView.setText(Html.fromHtml(descriptionMarkup + " "));
            descriptionTextView.setMovementMethod(LinkMovementMethod.getInstance());
            URLSpanNoUnderline.stripUnderlines(descriptionTextView);
        }

        detailsLayout.setVisibility(View.VISIBLE);
        privateAccountImage.setVisibility(mUser.getProtected() ? View.VISIBLE : View.GONE);

        tweetCount.setText(Util.getPrettyCount(mUser.getStatusesCount()));
        followingCount.setText(Util.getPrettyCount(mUser.getFriendsCount()));
        followersCount.setText(Util.getPrettyCount(mUser.getFollowersCount()));
        if (favoritesCount != null) {
            favoritesCount.setText(Util.getPrettyCount(mUser.getFavoritesCount()));
        }

        if (mUser.getUrl() != null) {
            linkLayout.setVisibility(View.VISIBLE);
            //link.setText(mUser.getUrl());
            //URLSpanNoUnderline.stripUnderlines(link);
            link.setText(Html.fromHtml("<a href=\"" + mUser.getUrl() + "\">" + mUser.getUrl() + "</a>"));
            link.setMovementMethod(LinkMovementMethod.getInstance());
            URLSpanNoUnderline.stripUnderlines(link);
        } else {
            linkLayout.setVisibility(View.GONE);
        }

        if (mUser.getLocation() != null) {
            locationLayout.setVisibility(View.VISIBLE);
            location.setText(mUser.getLocation());
        } else {
            locationLayout.setVisibility(View.GONE);
        }

        configureFriendshipButtonVisibility(mLoggedInUserFollows);

        getBaseLaneActivity().setComposeTweetDefault();
    } else {
        fullNameTextView.setText(null);
        followingTextView.setText(null);
        descriptionTextView.setText(null);

        detailsLayout.setVisibility(View.GONE);
        linkLayout.setVisibility(View.GONE);
        locationLayout.setVisibility(View.GONE);
        mFriendshipButton.setVisibility(View.GONE);
        mFriendshipDivider.setVisibility(View.GONE);
        privateAccountImage.setVisibility(View.GONE);
    }
}

From source file:com.shafiq.mytwittle.view.ProfileFragment.java

void configureView() {

    TextView fullNameTextView = (TextView) mProfileView.findViewById(R.id.fullNameTextView);
    TextView followingTextView = (TextView) mProfileView.findViewById(R.id.followState);
    TextView descriptionTextView = (TextView) mProfileView.findViewById(R.id.bioTextView);
    TextView tweetCount = (TextView) mProfileView.findViewById(R.id.tweetCountLabel);
    TextView followingCount = (TextView) mProfileView.findViewById(R.id.followingCountLabel);
    TextView followersCount = (TextView) mProfileView.findViewById(R.id.followersCountLabel);
    TextView favoritesCount = (TextView) mProfileView.findViewById(R.id.favorites_count);
    LinearLayout linkLayout = (LinearLayout) mProfileView.findViewById(R.id.linkLayout);
    TextView link = (TextView) mProfileView.findViewById(R.id.link);
    LinearLayout locationLayout = (LinearLayout) mProfileView.findViewById(R.id.locationLayout);
    TextView location = (TextView) mProfileView.findViewById(R.id.location);
    LinearLayout detailsLayout = (LinearLayout) mProfileView.findViewById(R.id.detailsLayout);
    ImageView privateAccountImage = (ImageView) mProfileView.findViewById(R.id.private_account_image);
    mFriendshipButton = (Button) mProfileView.findViewById(R.id.friendship_button);
    mFriendshipDivider = (View) mProfileView.findViewById(R.id.friendship_divider);

    if (mUser != null) {
        ImageView avatar = (ImageView) mProfileView.findViewById(R.id.profileImage);
        // String imageUrl =
        // TwitterManager.getProfileImageUrl(mUser.getScreenName(),
        // TwitterManager.ProfileImageSize.ORIGINAL);
        String imageUrl = mUser.getProfileImageUrl(TwitterManager.ProfileImageSize.ORIGINAL);
        UrlImageViewHelper.setUrlDrawable(avatar, imageUrl, R.drawable.ic_contact_picture);
        // avatar.setImageURL(imageUrl);

        ImageView coverImage = (ImageView) mProfileView.findViewById(R.id.coverImage);
        if (coverImage != null) {
            String url = mUser.getCoverImageUrl();
            if (url != null) {
                UrlImageViewHelper.setUrlDrawable(coverImage, url, R.drawable.ic_contact_picture);
            }/*from   w ww  .j  av a  2  s  . co  m*/
        }

        fullNameTextView.setText(mUser.getName());
        if (mFollowsLoggedInUser != null && mFollowsLoggedInUser.booleanValue() == true) {
            followingTextView.setText(R.string.follows_you);
        } else {
            followingTextView.setText(null);
        }

        String description = mUser.getDescription();
        if (description != null) {
            String descriptionMarkup = TwitterUtil.getTextMarkup(description);
            descriptionTextView.setText(Html.fromHtml(descriptionMarkup + " "));
            descriptionTextView.setMovementMethod(LinkMovementMethod.getInstance());
            URLSpanNoUnderline.stripUnderlines(descriptionTextView);
        }

        detailsLayout.setVisibility(View.VISIBLE);
        privateAccountImage.setVisibility(mUser.getProtected() ? View.VISIBLE : View.GONE);

        tweetCount.setText(Util.getPrettyCount(mUser.getStatusesCount()));
        followingCount.setText(Util.getPrettyCount(mUser.getFriendsCount()));
        followersCount.setText(Util.getPrettyCount(mUser.getFollowersCount()));
        if (favoritesCount != null) {
            favoritesCount.setText(Util.getPrettyCount(mUser.getFavoritesCount()));
        }

        if (mUser.getUrl() != null) {
            linkLayout.setVisibility(View.VISIBLE);
            // link.setText(mUser.getUrl());
            // URLSpanNoUnderline.stripUnderlines(link);
            link.setText(Html.fromHtml("<a href=\"" + mUser.getUrl() + "\">" + mUser.getUrl() + "</a>"));
            link.setMovementMethod(LinkMovementMethod.getInstance());
            URLSpanNoUnderline.stripUnderlines(link);
        } else {
            linkLayout.setVisibility(View.GONE);
        }

        if (mUser.getLocation() != null) {
            locationLayout.setVisibility(View.VISIBLE);
            location.setText(mUser.getLocation());
        } else {
            locationLayout.setVisibility(View.GONE);
        }

        configureFriendshipButtonVisibility(mLoggedInUserFollows);

        getBaseLaneActivity().setComposeTweetDefault();
    } else {
        fullNameTextView.setText(null);
        followingTextView.setText(null);
        descriptionTextView.setText(null);

        detailsLayout.setVisibility(View.GONE);
        linkLayout.setVisibility(View.GONE);
        locationLayout.setVisibility(View.GONE);
        mFriendshipButton.setVisibility(View.GONE);
        mFriendshipDivider.setVisibility(View.GONE);
        privateAccountImage.setVisibility(View.GONE);
    }
}

From source file:com.tweetlanes.android.core.view.ProfileFragment.java

void configureView() {

    TextView fullNameTextView = (TextView) mProfileView.findViewById(R.id.fullNameTextView);
    TextView followingTextView = (TextView) mProfileView.findViewById(R.id.followState);
    TextView descriptionTextView = (TextView) mProfileView.findViewById(R.id.bioTextView);
    TextView tweetCount = (TextView) mProfileView.findViewById(R.id.tweetCountLabel);
    TextView followingCount = (TextView) mProfileView.findViewById(R.id.followingCountLabel);
    TextView followersCount = (TextView) mProfileView.findViewById(R.id.followersCountLabel);
    TextView favoritesCount = (TextView) mProfileView.findViewById(R.id.favorites_count);
    LinearLayout linkLayout = (LinearLayout) mProfileView.findViewById(R.id.linkLayout);
    TextView link = (TextView) mProfileView.findViewById(R.id.link);
    LinearLayout locationLayout = (LinearLayout) mProfileView.findViewById(R.id.locationLayout);
    TextView location = (TextView) mProfileView.findViewById(R.id.location);
    LinearLayout detailsLayout = (LinearLayout) mProfileView.findViewById(R.id.detailsLayout);
    ImageView privateAccountImage = (ImageView) mProfileView.findViewById(R.id.private_account_image);
    mFriendshipButton = (Button) mProfileView.findViewById(R.id.friendship_button);
    mFriendshipDivider = mProfileView.findViewById(R.id.friendship_divider);

    if (mUser != null) {
        ImageView avatar = (ImageView) mProfileView.findViewById(R.id.profileImage);
        // String imageUrl =
        // TwitterManager.getProfileImageUrl(mUser.getScreenName(),
        // TwitterManager.ProfileImageSize.ORIGINAL);
        String imageUrl = mUser.getProfileImageUrl(TwitterManager.ProfileImageSize.ORIGINAL);
        UrlImageViewHelper.setUrlDrawable(avatar, imageUrl, R.drawable.ic_contact_picture);
        // avatar.setImageURL(imageUrl);

        ImageView coverImage = (ImageView) mProfileView.findViewById(R.id.coverImage);
        if (coverImage != null) {
            String url = mUser.getCoverImageUrl();
            if (url != null) {
                UrlImageViewHelper.setUrlDrawable(coverImage, url, R.drawable.ic_contact_picture);
            }/*from ww w  .  j  a v  a  2s  .c o m*/
        }

        fullNameTextView.setText(mUser.getName());
        if (mFollowsLoggedInUser != null && mFollowsLoggedInUser.booleanValue()) {
            followingTextView.setText(R.string.follows_you);
        } else {
            followingTextView.setText(null);
        }

        String description = mUser.getDescription();
        URLEntity[] urlEntities = mUser.getUrlEntities();
        if (description != null) {
            String descriptionMarkup = TwitterUtil.getTextMarkup(description, urlEntities);
            descriptionTextView.setText(Html.fromHtml(descriptionMarkup + " "));
            descriptionTextView.setMovementMethod(LinkMovementMethod.getInstance());
            URLSpanNoUnderline.stripUnderlines(descriptionTextView);
        }

        if (mUser.getUrl() != null) {
            linkLayout.setVisibility(View.VISIBLE);
            String urlMarkup = TwitterUtil.getTextMarkup(mUser.getUrl(), urlEntities);
            link.setText(Html.fromHtml(urlMarkup + ""));
            link.setMovementMethod(LinkMovementMethod.getInstance());
            URLSpanNoUnderline.stripUnderlines(link);
        } else {
            linkLayout.setVisibility(View.GONE);
        }

        detailsLayout.setVisibility(View.VISIBLE);
        privateAccountImage.setVisibility(mUser.getProtected() ? View.VISIBLE : View.GONE);

        tweetCount.setText(Util.getPrettyCount(mUser.getStatusesCount()));
        followingCount.setText(Util.getPrettyCount(mUser.getFriendsCount()));
        followersCount.setText(Util.getPrettyCount(mUser.getFollowersCount()));
        if (favoritesCount != null) {
            favoritesCount.setText(Util.getPrettyCount(mUser.getFavoritesCount()));
        }

        if (mUser.getLocation() != null) {
            locationLayout.setVisibility(View.VISIBLE);
            location.setText(mUser.getLocation());
        } else {
            locationLayout.setVisibility(View.GONE);
        }

        configureFriendshipButtonVisibility(mLoggedInUserFollows);

    } else {
        fullNameTextView.setText(null);
        followingTextView.setText(null);
        descriptionTextView.setText(null);

        detailsLayout.setVisibility(View.GONE);
        linkLayout.setVisibility(View.GONE);
        locationLayout.setVisibility(View.GONE);
        mFriendshipButton.setVisibility(View.GONE);
        mFriendshipDivider.setVisibility(View.GONE);
        privateAccountImage.setVisibility(View.GONE);
    }
}