Example usage for android.widget TextView getPaint

List of usage examples for android.widget TextView getPaint

Introduction

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

Prototype

public TextPaint getPaint() 

Source Link

Document

Gets the TextPaint used for the text.

Usage

From source file:com.android.messaging.ui.conversation.ConversationFragment.java

public void updateActionBar(final ActionBar actionBar) {
    if (mComposeMessageView == null || !mComposeMessageView.updateActionBar(actionBar)) {
        updateActionAndStatusBarColor(actionBar);
        // We update this regardless of whether or not the action bar is showing so that we
        // don't get a race when it reappears.
        actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
        actionBar.setDisplayHomeAsUpEnabled(true);
        // Reset the back arrow to its default
        actionBar.setHomeAsUpIndicator(0);
        View customView = actionBar.getCustomView();
        if (customView == null || customView.getId() != R.id.conversation_title_container) {
            final LayoutInflater inflator = (LayoutInflater) getActivity()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            customView = inflator.inflate(R.layout.action_bar_conversation_name, null);
            customView.setOnClickListener(new View.OnClickListener() {
                @Override//from   w  ww.  j a  va  2s .c o  m
                public void onClick(final View v) {
                    onBackPressed();
                }
            });
            actionBar.setCustomView(customView);
        }

        final TextView conversationNameView = (TextView) customView.findViewById(R.id.conversation_title);
        final String conversationName = getConversationName();
        if (!TextUtils.isEmpty(conversationName)) {
            // RTL : To format conversation title if it happens to be phone numbers.
            final BidiFormatter bidiFormatter = BidiFormatter.getInstance();
            final String formattedName = bidiFormatter.unicodeWrap(UiUtils.commaEllipsize(conversationName,
                    conversationNameView.getPaint(), conversationNameView.getWidth(),
                    getString(R.string.plus_one), getString(R.string.plus_n)).toString(),
                    TextDirectionHeuristicsCompat.LTR);
            conversationNameView.setText(formattedName);
            // In case phone numbers are mixed in the conversation name, we need to vocalize it.
            final String vocalizedConversationName = AccessibilityUtil.getVocalizedPhoneNumber(getResources(),
                    conversationName);
            conversationNameView.setContentDescription(vocalizedConversationName);
            getActivity().setTitle(conversationName);
        } else {
            final String appName = getString(R.string.app_name);
            conversationNameView.setText(appName);
            getActivity().setTitle(appName);
        }

        // When conversation is showing and media picker is not showing, then hide the action
        // bar only when we are in landscape mode, with IME open.
        if (mHost.isImeOpen() && UiUtils.isLandscapeMode()) {
            actionBar.hide();
        } else {
            actionBar.show();
        }
    }
}

From source file:com.dmsl.anyplace.UnifiedNavigationActivity.java

private void handlePoisOnMap(Collection<PoisModel> collection) {

    visiblePois.clearAll();/*from  w  w w .ja v  a2  s .co m*/
    String currentFloor = userData.getSelectedFloorNumber();

    // Display part of Description Text Only
    // Make an approximation of available space based on map size
    final int fragmentWidth = (int) (findViewById(R.id.map).getWidth() * 2);
    ViewGroup infoWindow = (ViewGroup) getLayoutInflater().inflate(R.layout.info_window, null);
    TextView infoSnippet = (TextView) infoWindow.findViewById(R.id.snippet);
    TextPaint paint = infoSnippet.getPaint();

    for (PoisModel pm : collection) {
        if (pm.floor_number.equalsIgnoreCase(currentFloor)) {
            String snippet = AndroidUtils.fillTextBox(paint, fragmentWidth, pm.description);
            Marker m = mMap.addMarker(new MarkerOptions()
                    .position(new LatLng(Double.parseDouble(pm.lat), Double.parseDouble(pm.lng))).title(pm.name)
                    .snippet(snippet).icon(BitmapDescriptorFactory.fromResource(R.drawable.pin8)));
            visiblePois.addMarkerAndPoi(m, pm);
        }
    }
}

From source file:group.pals.android.lib.ui.filechooser.FragmentFiles.java

/**
 * As the name means./*  w  w  w.j a v a  2 s  .c  o m*/
 */
private void buildAddressBar(final Uri path) {
    if (path == null)
        return;

    mViewAddressBar.removeAllViews();

    new LoadingDialog<Void, Cursor, Void>(getActivity(), false) {

        LinearLayout.LayoutParams lpBtnLoc;
        LinearLayout.LayoutParams lpDivider;
        LayoutInflater inflater = getLayoutInflater(null);
        final int dim = getResources().getDimensionPixelSize(R.dimen.afc_5dp);
        int count = 0;

        @Override
        protected void onPreExecute() {
            super.onPreExecute();

            lpBtnLoc = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT);
            lpBtnLoc.gravity = Gravity.CENTER;
        }// onPreExecute()

        @Override
        protected Void doInBackground(Void... params) {
            Cursor cursor = getActivity().getContentResolver().query(path, null, null, null, null);
            while (cursor != null) {
                if (cursor.moveToFirst()) {
                    publishProgress(cursor);
                    cursor.close();
                } else
                    break;

                /*
                 * Process the parent directory.
                 */
                Uri uri = Uri.parse(cursor.getString(cursor.getColumnIndex(BaseFile.COLUMN_URI)));
                cursor = getActivity().getContentResolver()
                        .query(BaseFile.genContentUriApi(uri.getAuthority()).buildUpon()
                                .appendPath(BaseFile.CMD_GET_PARENT)
                                .appendQueryParameter(BaseFile.PARAM_SOURCE, uri.getLastPathSegment()).build(),
                                null, null, null, null);
            } // while

            return null;
        }// doInBackground()

        @Override
        protected void onProgressUpdate(Cursor... progress) {
            /*
             * Add divider.
             */
            if (mViewAddressBar.getChildCount() > 0) {
                View divider = inflater.inflate(R.layout.afc_view_locations_divider, null);

                if (lpDivider == null) {
                    lpDivider = new LinearLayout.LayoutParams(dim, dim);
                    lpDivider.gravity = Gravity.CENTER;
                    lpDivider.setMargins(dim, dim, dim, dim);
                }
                mViewAddressBar.addView(divider, 0, lpDivider);
            }

            Uri lastUri = Uri.parse(progress[0].getString(progress[0].getColumnIndex(BaseFile.COLUMN_URI)));

            TextView btnLoc = (TextView) inflater.inflate(R.layout.afc_button_location, null);
            String name = BaseFileProviderUtils.getFileName(progress[0]);
            btnLoc.setText(TextUtils.isEmpty(name) ? getString(R.string.afc_root) : name);
            btnLoc.setTag(lastUri);
            btnLoc.setOnClickListener(mBtnLocationOnClickListener);
            btnLoc.setOnLongClickListener(mBtnLocationOnLongClickListener);
            mViewAddressBar.addView(btnLoc, 0, lpBtnLoc);

            if (count++ == 0) {
                Rect r = new Rect();
                btnLoc.getPaint().getTextBounds(name, 0, name.length(), r);
                if (r.width() >= getResources().getDimensionPixelSize(R.dimen.afc_button_location_max_width)
                        - btnLoc.getPaddingLeft() - btnLoc.getPaddingRight()) {
                    mTextFullDirName
                            .setText(progress[0].getString(progress[0].getColumnIndex(BaseFile.COLUMN_NAME)));
                    mTextFullDirName.setVisibility(View.VISIBLE);
                } else
                    mTextFullDirName.setVisibility(View.GONE);
            } // if
        }// onProgressUpdate()

        @Override
        protected void onPostExecute(Void result) {
            super.onPostExecute(result);

            /*
             * Sometimes without delay time, it doesn't work...
             */
            mViewLocationsContainer.postDelayed(new Runnable() {

                public void run() {
                    mViewLocationsContainer.fullScroll(HorizontalScrollView.FOCUS_RIGHT);
                }// run()
            }, DisplayPrefs.DELAY_TIME_FOR_VERY_SHORT_ANIMATION);
        }// onPostExecute()

    }.execute();
}

From source file:com.haibison.android.anhuu.FragmentFiles.java

/**
 * As the name means.//from  w  ww .  ja v  a  2 s .  c o  m
 */
private void buildAddressBar(final Uri path) {
    if (path == null)
        return;

    mViewAddressBar.removeAllViews();

    new LoadingDialog<Void, Cursor, Void>(getActivity(), false) {

        LinearLayout.LayoutParams lpBtnLoc;
        LinearLayout.LayoutParams lpDivider;
        LayoutInflater inflater = getLayoutInflater(null);
        final int dim = getResources().getDimensionPixelSize(R.dimen.anhuu_f5be488d_5dp);
        int count = 0;

        @Override
        protected void onPreExecute() {
            super.onPreExecute();

            lpBtnLoc = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT);
            lpBtnLoc.gravity = Gravity.CENTER;
        }// onPreExecute()

        @Override
        protected Void doInBackground(Void... params) {
            Cursor cursor = getActivity().getContentResolver().query(path, null, null, null, null);
            while (cursor != null) {
                if (cursor.moveToFirst()) {
                    publishProgress(cursor);
                    cursor.close();
                } else
                    break;

                /*
                 * Process the parent directory.
                 */
                Uri uri = Uri.parse(cursor.getString(cursor.getColumnIndex(BaseFile.COLUMN_URI)));
                cursor = getActivity().getContentResolver()
                        .query(BaseFile.genContentUriApi(uri.getAuthority()).buildUpon()
                                .appendPath(BaseFile.CMD_GET_PARENT)
                                .appendQueryParameter(BaseFile.PARAM_SOURCE, uri.getLastPathSegment()).build(),
                                null, null, null, null);
            } // while

            return null;
        }// doInBackground()

        @Override
        protected void onProgressUpdate(Cursor... progress) {
            /*
             * Add divider.
             */
            if (mViewAddressBar.getChildCount() > 0) {
                View divider = inflater.inflate(R.layout.anhuu_f5be488d_view_locations_divider, null);

                if (lpDivider == null) {
                    lpDivider = new LinearLayout.LayoutParams(dim, dim);
                    lpDivider.gravity = Gravity.CENTER;
                    lpDivider.setMargins(dim, dim, dim, dim);
                }
                mViewAddressBar.addView(divider, 0, lpDivider);
            }

            Uri lastUri = Uri.parse(progress[0].getString(progress[0].getColumnIndex(BaseFile.COLUMN_URI)));

            TextView btnLoc = (TextView) inflater.inflate(R.layout.anhuu_f5be488d_button_location, null);
            String name = BaseFileProviderUtils.getFileName(progress[0]);
            btnLoc.setText(TextUtils.isEmpty(name) ? getString(R.string.anhuu_f5be488d_root) : name);
            btnLoc.setTag(lastUri);
            btnLoc.setOnClickListener(mBtnLocationOnClickListener);
            btnLoc.setOnLongClickListener(mBtnLocationOnLongClickListener);
            mViewAddressBar.addView(btnLoc, 0, lpBtnLoc);

            if (count++ == 0) {
                Rect r = new Rect();
                btnLoc.getPaint().getTextBounds(name, 0, name.length(), r);
                if (r.width() >= getResources()
                        .getDimensionPixelSize(R.dimen.anhuu_f5be488d_button_location_max_width)
                        - btnLoc.getPaddingLeft() - btnLoc.getPaddingRight()) {
                    mTextFullDirName
                            .setText(progress[0].getString(progress[0].getColumnIndex(BaseFile.COLUMN_NAME)));
                    mTextFullDirName.setVisibility(View.VISIBLE);
                } else
                    mTextFullDirName.setVisibility(View.GONE);
            } // if
        }// onProgressUpdate()

        @Override
        protected void onPostExecute(Void result) {
            super.onPostExecute(result);

            /*
             * Sometimes without delay time, it doesn't work...
             */
            mViewLocationsContainer.postDelayed(new Runnable() {

                public void run() {
                    mViewLocationsContainer.fullScroll(HorizontalScrollView.FOCUS_RIGHT);
                }// run()
            }, Display.DELAY_TIME_FOR_VERY_SHORT_ANIMATION);
        }// onPostExecute()

    }.execute();
}

From source file:com.hctrom.romcontrol.licenseadapter.LicenseDialogoAlerta.java

public void applyBlurMaskFilter(TextView tv, BlurMaskFilter.Blur style) {
    /*//from  ww w. j av  a  2 s .  c  om
    MaskFilter
        Known Direct Subclasses
            BlurMaskFilter, EmbossMaskFilter
            
        MaskFilter is the base class for object that perform transformations on an
        alpha-channel mask before drawing it. A subclass of MaskFilter may be installed
        into a Paint. Blur and emboss are implemented as subclasses of MaskFilter.
            
    */
    /*
    BlurMaskFilter
        This takes a mask, and blurs its edge by the specified radius. Whether or or not to
        include the original mask, and whether the blur goes outside, inside, or straddles,
        the original mask's border, is controlled by the Blur enum.
    */
    /*
    public BlurMaskFilter (float radius, BlurMaskFilter.Blur style)
        Create a blur maskfilter.
            
    Parameters
        radius : The radius to extend the blur from the original mask. Must be > 0.
        style : The Blur to use
    Returns
        The new blur maskfilter
    */
    /*
    BlurMaskFilter.Blur
        INNER : Blur inside the border, draw nothing outside.
        NORMAL : Blur inside and outside the original border.
        OUTER : Draw nothing inside the border, blur outside.
        SOLID : Draw solid inside the border, blur outside.
    */
    /*
    public float getTextSize ()
        Returns the size (in pixels) of the default text size in this TextView.
    */

    // Define the blur effect radius
    float radius = tv.getTextSize() / 10;

    // Initialize a new BlurMaskFilter instance
    BlurMaskFilter filter = new BlurMaskFilter(radius, style);

    /*
    public void setLayerType (int layerType, Paint paint)
        Specifies the type of layer backing this view. The layer can be LAYER_TYPE_NONE,
        LAYER_TYPE_SOFTWARE or LAYER_TYPE_HARDWARE.
            
        A layer is associated with an optional Paint instance that controls how the
        layer is composed on screen.
            
    Parameters
        layerType : The type of layer to use with this view, must be one of
            LAYER_TYPE_NONE, LAYER_TYPE_SOFTWARE or LAYER_TYPE_HARDWARE
        paint : The paint used to compose the layer. This argument is optional and
            can be null. It is ignored when the layer type is LAYER_TYPE_NONE
    */
    /*
    public static final int LAYER_TYPE_SOFTWARE
        Indicates that the view has a software layer. A software layer is backed by
        a bitmap and causes the view to be rendered using Android's software rendering
        pipeline, even if hardware acceleration is enabled.
    */

    // Set the TextView layer type
    tv.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

    /*
    public MaskFilter setMaskFilter (MaskFilter maskfilter)
        Set or clear the maskfilter object.
            
        Pass null to clear any previous maskfilter. As a convenience, the parameter
        passed is also returned.
            
    Parameters
        maskfilter : May be null. The maskfilter to be installed in the paint
    Returns
        maskfilter
    */

    // Finally, apply the blur effect on TextView text
    tv.getPaint().setMaskFilter(filter);
}

From source file:github.daneren2005.dsub.fragments.SelectDirectoryFragment.java

private void setupTextDisplay(final View header) {
    final TextView titleView = (TextView) header.findViewById(R.id.select_album_title);
    if (playlistName != null) {
        titleView.setText(playlistName);
    } else if (podcastName != null) {
        titleView.setText(podcastName);//  www. j  a  va  2 s  .  com
        titleView.setPadding(0, 6, 4, 8);
    } else if (name != null) {
        titleView.setText(name);

        if (artistInfo != null) {
            titleView.setPadding(0, 6, 4, 8);
        }
    } else if (share != null) {
        titleView.setVisibility(View.GONE);
    }

    int songCount = 0;

    Set<String> artists = new HashSet<String>();
    Set<Integer> years = new HashSet<Integer>();
    Integer totalDuration = 0;
    for (Entry entry : entries) {
        if (!entry.isDirectory()) {
            songCount++;
            if (entry.getArtist() != null) {
                artists.add(entry.getArtist());
            }
            if (entry.getYear() != null) {
                years.add(entry.getYear());
            }
            Integer duration = entry.getDuration();
            if (duration != null) {
                totalDuration += duration;
            }
        }
    }

    final TextView artistView = (TextView) header.findViewById(R.id.select_album_artist);
    if (podcastDescription != null || artistInfo != null) {
        artistView.setVisibility(View.VISIBLE);
        String text = podcastDescription != null ? podcastDescription : artistInfo.getBiography();
        Spanned spanned = null;
        if (text != null) {
            spanned = Html.fromHtml(text);
        }
        artistView.setText(spanned);
        artistView.setSingleLine(false);
        final int minLines = context.getResources().getInteger(R.integer.TextDescriptionLength);
        artistView.setLines(minLines);
        artistView.setTextAppearance(context, android.R.style.TextAppearance_Small);

        final Spanned spannedText = spanned;
        artistView.setOnClickListener(new View.OnClickListener() {
            @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
            @Override
            public void onClick(View v) {
                if (artistView.getMaxLines() == minLines) {
                    // Use LeadingMarginSpan2 to try to make text flow around image
                    Display display = context.getWindowManager().getDefaultDisplay();
                    ImageView coverArtView = (ImageView) header.findViewById(R.id.select_album_art);
                    coverArtView.measure(display.getWidth(), display.getHeight());

                    int height, width;
                    ViewGroup.MarginLayoutParams vlp = (ViewGroup.MarginLayoutParams) coverArtView
                            .getLayoutParams();
                    if (coverArtView.getDrawable() != null) {
                        height = coverArtView.getMeasuredHeight() + coverArtView.getPaddingBottom();
                        width = coverArtView.getWidth() + coverArtView.getPaddingRight();
                    } else {
                        height = coverArtView.getHeight();
                        width = coverArtView.getWidth() + coverArtView.getPaddingRight();
                    }
                    float textLineHeight = artistView.getPaint().getTextSize();
                    int lines = (int) Math.ceil(height / textLineHeight);

                    SpannableString ss = new SpannableString(spannedText);
                    ss.setSpan(new MyLeadingMarginSpan2(lines, width), 0, ss.length(),
                            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

                    View linearLayout = header.findViewById(R.id.select_album_text_layout);
                    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) linearLayout
                            .getLayoutParams();
                    int[] rules = params.getRules();
                    rules[RelativeLayout.RIGHT_OF] = 0;
                    params.leftMargin = vlp.rightMargin;

                    artistView.setText(ss);
                    artistView.setMaxLines(100);

                    vlp = (ViewGroup.MarginLayoutParams) titleView.getLayoutParams();
                    vlp.leftMargin = width;
                } else {
                    artistView.setMaxLines(minLines);
                }
            }
        });
        artistView.setMovementMethod(LinkMovementMethod.getInstance());
    } else if (topTracks) {
        artistView.setText(R.string.menu_top_tracks);
        artistView.setVisibility(View.VISIBLE);
    } else if (showAll) {
        artistView.setText(R.string.menu_show_all);
        artistView.setVisibility(View.VISIBLE);
    } else if (artists.size() == 1) {
        String artistText = artists.iterator().next();
        if (years.size() == 1) {
            artistText += " - " + years.iterator().next();
        }
        artistView.setText(artistText);
        artistView.setVisibility(View.VISIBLE);
    } else {
        artistView.setVisibility(View.GONE);
    }

    TextView songCountView = (TextView) header.findViewById(R.id.select_album_song_count);
    TextView songLengthView = (TextView) header.findViewById(R.id.select_album_song_length);
    if (podcastDescription != null || artistInfo != null) {
        songCountView.setVisibility(View.GONE);
        songLengthView.setVisibility(View.GONE);
    } else {
        String s = context.getResources().getQuantityString(R.plurals.select_album_n_songs, songCount,
                songCount);
        songCountView.setText(s.toUpperCase());
        songLengthView.setText(Util.formatDuration(totalDuration));
    }
}

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

/**
 * ? thumbnail view  ?  ?  ?.//from  www.ja v  a  2  s. c o m
 *  ??  thumbnail view   {@link #thumbnailWidth}
 */
private FloatingModel[] measureFloatingModels(LayoutInflater inflater) {
    Point displaySize = AppearanceUtils.getDisplaySize(activity.getWindowManager().getDefaultDisplay());

    LinearLayout view = (LinearLayout) inflater.inflate(R.layout.post_item_layout, (ViewGroup) rootView, false);

    TextView commentView = (TextView) view.findViewById(R.id.post_comment);
    TextPaint textPaint = commentView.getPaint();
    int textLineHeight = Math.max(1, commentView.getLineHeight());
    int rootWidth = (int) (displaySize.x * settings.getRootViewWeight());
    postItemPadding = view.getPaddingLeft() + view.getPaddingRight();
    int textWidth = postItemWidth = rootWidth - postItemPadding;

    View thumbnailView = view.findViewById(R.id.post_thumbnail);
    ViewGroup.MarginLayoutParams thumbnailLayoutParams = (ViewGroup.MarginLayoutParams) thumbnailView
            .getLayoutParams();
    thumbnailMargin = thumbnailLayoutParams.leftMargin + thumbnailLayoutParams.rightMargin;

    View attachmentTypeView = thumbnailView.findViewById(R.id.post_thumbnail_attachment_type);
    FloatingModel[] floatingModels = new FloatingModel[2];

    attachmentTypeView.setVisibility(View.GONE);
    thumbnailView.measure(displaySize.x, displaySize.y);
    Point thumbnailSize = new Point(thumbnailMargin + thumbnailView.getMeasuredWidth(),
            thumbnailView.getMeasuredHeight());
    floatingModels[0] = new FloatingModel(thumbnailSize, textWidth, textPaint);

    attachmentTypeView.setVisibility(View.VISIBLE);
    thumbnailView.measure(displaySize.x, displaySize.y);
    thumbnailSize = new Point(thumbnailMargin + thumbnailView.getMeasuredWidth(),
            thumbnailView.getMeasuredHeight());
    floatingModels[1] = new FloatingModel(thumbnailSize, textWidth, textPaint);

    thumbnailWidth = thumbnailSize.x;
    maxItemLines = divcell(thumbnailSize.y, textLineHeight);

    return floatingModels;
}

From source file:github.popeen.dsub.fragments.SelectDirectoryFragment.java

private void setupTextDisplay(final View header) {

    final TextView titleView = (TextView) header.findViewById(R.id.select_album_title);
    if (playlistName != null) {
        titleView.setText(playlistName);
    } else if (podcastName != null) {
        Collections.reverse(entries);
        titleView.setText(podcastName);/*from   w  w  w.j  a  v a 2s.  c om*/
        titleView.setPadding(0, 6, 4, 8);
    } else if (name != null) {
        titleView.setText(name);
        if (artistInfo != null) {
            titleView.setPadding(0, 6, 4, 8);
        }
    } else if (share != null) {
        titleView.setVisibility(View.GONE);
    }

    int songCount = 0;

    Set<String> artists = new HashSet<String>();
    Set<Integer> years = new HashSet<Integer>();
    totalDuration = 0;
    for (Entry entry : entries) {
        if (!entry.isDirectory()) {
            songCount++;
            if (entry.getArtist() != null) {
                artists.add(entry.getArtist());
            }
            if (entry.getYear() != null) {
                years.add(entry.getYear());
            }
            Integer duration = entry.getDuration();
            if (duration != null) {
                totalDuration += duration;
            }
        }
    }
    String artistName = "";
    bookDescription = "Could not collect any info about the book at this time";
    try {

        artistName = artists.iterator().next();
        String endpoint = "getBookDirectory";
        if (Util.isTagBrowsing(context)) {
            endpoint = "getBook";
        }
        SharedPreferences prefs = Util.getPreferences(context);
        String url = Util.getRestUrl(context, endpoint) + "&id=" + directory.getId() + "&f=json";

        Log.w("GetInfo", url);
        String artist, title;
        int year = 0;
        artist = title = "";

        try {
            artist = artists.iterator().next();
        } catch (Exception e) {
            Log.w("GetInfoArtist", e.toString());
        }
        try {
            title = titleView.getText().toString();
        } catch (Exception e) {
            Log.w("GetInfoTitle", e.toString());
        }
        try {
            year = years.iterator().next();
        } catch (Exception e) {
            Log.w("GetInfoYear", e.toString());
        }

        BookInfoAPIParams params = new BookInfoAPIParams(url, artist, title, year);
        bookInfo = new BookInfoAPI(context).execute(params).get();
        bookDescription = bookInfo[0];
        bookReader = bookInfo[1];

    } catch (Exception e) {
        Log.w("GetInfoError", e.toString());
    }
    if (bookDescription.equals("noInfo")) {
        bookDescription = "The server has no description for this book";
    }

    final TextView artistView = (TextView) header.findViewById(R.id.select_album_artist);
    if (podcastDescription != null || artistInfo != null || bookDescription != null) {
        artistView.setVisibility(View.VISIBLE);

        String text = "";
        if (bookDescription != null) {
            text = bookDescription;
        }
        if (podcastDescription != null) {
            text = podcastDescription;
        }
        if (artistInfo != null) {
            text = artistInfo.getBiography();
        }
        Spanned spanned = null;
        if (text != null) {
            String newText = "";
            try {
                if (!artistName.equals("")) {
                    newText += "<b>" + context.getResources().getString(R.string.main_artist) + "</b>: "
                            + artistName + "<br/>";
                }
            } catch (Exception e) {
            }
            try {
                if (totalDuration > 0) {
                    newText += "<b>" + context.getResources().getString(R.string.album_book_reader) + "</b>: "
                            + bookReader + "<br/>";
                }
            } catch (Exception e) {
            }
            try {
                if (totalDuration > 0) {
                    newText += "<b>" + context.getResources().getString(R.string.album_book_length) + "</b>: "
                            + Util.formatDuration(totalDuration) + "<br/>";
                }
            } catch (Exception e) {
            }
            try {
                newText += text + "<br/>";
            } catch (Exception e) {
            }
            spanned = Html.fromHtml(newText);
        }

        artistView.setText(spanned);
        artistView.setSingleLine(false);
        final int minLines = context.getResources().getInteger(R.integer.TextDescriptionLength);
        artistView.setLines(minLines);
        artistView.setTextAppearance(context, android.R.style.TextAppearance_Small);

        final Spanned spannedText = spanned;
        artistView.setOnClickListener(new View.OnClickListener() {
            @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
            @Override
            public void onClick(View v) {
                if (artistView.getMaxLines() == minLines) {
                    // Use LeadingMarginSpan2 to try to make text flow around image
                    Display display = context.getWindowManager().getDefaultDisplay();
                    ImageView coverArtView = (ImageView) header.findViewById(R.id.select_album_art);
                    coverArtView.measure(display.getWidth(), display.getHeight());

                    int height, width;
                    ViewGroup.MarginLayoutParams vlp = (ViewGroup.MarginLayoutParams) coverArtView
                            .getLayoutParams();
                    if (coverArtView.getDrawable() != null) {
                        height = coverArtView.getMeasuredHeight() + coverArtView.getPaddingBottom();
                        width = coverArtView.getWidth() + coverArtView.getPaddingRight();
                    } else {
                        height = coverArtView.getHeight();
                        width = coverArtView.getWidth() + coverArtView.getPaddingRight();
                    }
                    float textLineHeight = artistView.getPaint().getTextSize();

                    int lines = (int) Math.ceil(height / textLineHeight) + 1;

                    SpannableString ss = new SpannableString(spannedText);
                    ss.setSpan(new MyLeadingMarginSpan2(lines, width), 0, ss.length(),
                            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

                    View linearLayout = header.findViewById(R.id.select_album_text_layout);
                    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) linearLayout
                            .getLayoutParams();
                    int[] rules = params.getRules();
                    rules[RelativeLayout.RIGHT_OF] = 0;
                    params.leftMargin = vlp.rightMargin;

                    artistView.setText(ss);
                    artistView.setMaxLines(100);

                    vlp = (ViewGroup.MarginLayoutParams) titleView.getLayoutParams();
                    vlp.leftMargin = width;
                } else {
                    artistView.setMaxLines(minLines);
                }
            }
        });
        artistView.setMovementMethod(LinkMovementMethod.getInstance());
    } else if (topTracks) {
        artistView.setText(R.string.menu_top_tracks);
        artistView.setVisibility(View.VISIBLE);
    } else if (showAll) {
        artistView.setText(R.string.menu_show_all);
        artistView.setVisibility(View.VISIBLE);
    } else if (artists.size() == 1) {
        String artistText = artists.iterator().next();
        if (years.size() == 1) {
            artistText += " - " + years.iterator().next();
        }
        artistView.setText(artistText);
        artistView.setVisibility(View.VISIBLE);
    } else {
        artistView.setVisibility(View.GONE);
    }

    TextView songCountView = (TextView) header.findViewById(R.id.select_album_song_count);
    TextView songLengthView = (TextView) header.findViewById(R.id.select_album_song_length);
    if (podcastDescription != null || artistInfo != null) {
        songCountView.setVisibility(View.GONE);
        songLengthView.setVisibility(View.GONE);
    } else {
        String s = context.getResources().getQuantityString(R.plurals.select_album_n_songs, songCount,
                songCount);

        songCountView.setVisibility(View.GONE);
        songLengthView.setVisibility(View.GONE);
    }
}