Example usage for android.text SpannableString length

List of usage examples for android.text SpannableString length

Introduction

In this page you can find the example usage for android.text SpannableString length.

Prototype

int length();

Source Link

Document

Returns the length of this character sequence.

Usage

From source file:io.plaidapp.designernews.ui.story.StoryActivity.java

private CharSequence getStoryPosterTimeText(String userDisplayName, String userJob, Date createdAt) {
    SpannableString poster = new SpannableString(userDisplayName.toLowerCase());
    poster.setSpan(new TextAppearanceSpan(this, io.plaidapp.R.style.TextAppearance_CommentAuthor), 0,
            poster.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    CharSequence job = !TextUtils.isEmpty(userJob) ? "\n" + userJob.toLowerCase() : "";
    CharSequence timeAgo = DateUtils.getRelativeTimeSpanString(createdAt.getTime(), System.currentTimeMillis(),
            DateUtils.SECOND_IN_MILLIS).toString().toLowerCase();

    return TextUtils.concat(poster, job, "\n", timeAgo);
}

From source file:tw.com.geminihsu.app01.fragment.Fragment_PickUpAirPlane.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuItem item = menu.add(Menu.NONE, ACTIONBAR_MENU_ITEM_SUMMIT, Menu.NONE, getString(R.string.menu_take));
    SpannableString spanString = new SpannableString(item.getTitle().toString());
    spanString.setSpan(new ForegroundColorSpan(Color.WHITE), 0, spanString.length(), 0); //fix the color to white
    item.setTitle(spanString);/*from   w  w w  .  j ava2  s . c  o m*/

    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.android.mail.utils.NotificationUtils.java

private static SpannableStringBuilder ellipsizeStyledSenders(final Context context,
        ArrayList<SpannableString> styledSenders) {
    if (sSendersSplitToken == null) {
        sSendersSplitToken = context.getString(R.string.senders_split_token);
        sElidedPaddingToken = context.getString(R.string.elided_padding_token);
    }//from ww  w  . j  a v a  2s .c om

    SpannableStringBuilder builder = new SpannableStringBuilder();
    SpannableString prevSender = null;
    for (SpannableString sender : styledSenders) {
        if (sender == null) {
            LogUtils.e(LOG_TAG, "null sender iterating over styledSenders");
            continue;
        }
        CharacterStyle[] spans = sender.getSpans(0, sender.length(), CharacterStyle.class);
        if (SendersView.sElidedString.equals(sender.toString())) {
            prevSender = sender;
            sender = copyStyles(spans, sElidedPaddingToken + sender + sElidedPaddingToken);
        } else if (builder.length() > 0
                && (prevSender == null || !SendersView.sElidedString.equals(prevSender.toString()))) {
            prevSender = sender;
            sender = copyStyles(spans, sSendersSplitToken + sender);
        } else {
            prevSender = sender;
        }
        builder.append(sender);
    }
    return builder;
}

From source file:com.kyakujin.android.autoeco.ui.MainActivity.java

/**
 * About/*from  w  w  w . j a  va2s . co m*/
 */
private void showAboutDialog() {
    PackageManager pm = this.getPackageManager();
    String packageName = this.getPackageName();
    String versionName;
    try {
        PackageInfo info = pm.getPackageInfo(packageName, 0);
        versionName = info.versionName;
    } catch (PackageManager.NameNotFoundException e) {
        versionName = "N/A";
    }

    SpannableStringBuilder aboutBody = new SpannableStringBuilder();

    SpannableString mailAddress = new SpannableString(getString(R.string.mailto));
    mailAddress.setSpan(new ClickableSpan() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_SENDTO);
            intent.setData(Uri.parse(getString(R.string.description_mailto)));
            intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.description_mail_subject));
            startActivity(intent);
        }
    }, 0, mailAddress.length(), 0);

    aboutBody.append(Html.fromHtml(getString(R.string.about_body, versionName)));
    aboutBody.append("\n");
    aboutBody.append(mailAddress);

    LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    TextView aboutBodyView = (TextView) layoutInflater.inflate(R.layout.fragment_about_dialog, null);
    aboutBodyView.setText(aboutBody);
    aboutBodyView.setMovementMethod(LinkMovementMethod.getInstance());

    AlertDialog dlg = new AlertDialog.Builder(this).setTitle(R.string.alert_title_about).setView(aboutBodyView)
            .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).create();
    dlg.show();
}

From source file:com.zitech.framework.widget.SlidingTabs.java

/**
 * call this function if you call some setXXX() function
 *///from   www .  j  av  a  2  s  . co  m
private void updateTabStyles() {
    PagerAdapter adapter = this.pager.getAdapter();
    if (adapter instanceof TabsTitleInterface) {
        for (int i = 0; i < this.tabCount; i++) {
            View v = this.tabsContainer.getChildAt(i);
            v.setBackgroundResource(this.tabBackgroundResId);
            if (v instanceof TextView) {
                TextView tab = (TextView) v;
                SpannableString spannableString = ((TabsTitleInterface) adapter).getTabTitle(i);
                if (i == this.selectedPosition) {
                    spannableString.setSpan(new ForegroundColorSpan(this.selectedTabTextColor), 0,
                            spannableString.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
                    tab.setText(spannableString);
                } else {
                    spannableString.setSpan(new ForegroundColorSpan(this.tabTextColor), 0,
                            spannableString.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
                    tab.setText(spannableString);
                }
            }
        }
    } else {
        for (int i = 0; i < this.tabCount; i++) {
            View v = this.tabsContainer.getChildAt(i);
            v.setBackgroundResource(this.tabBackgroundResId);
            if (v instanceof TextView) {
                TextView tab = (TextView) v;
                tab.setTextSize(TypedValue.COMPLEX_UNIT_SP, tabTextSize);
                tab.setTypeface(this.tabTypeface, this.tabTypefaceStyle);
                tab.setTextColor(this.tabTextColor);
                // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
                // pre-ICS-build
                if (textAllCaps) {
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                        tab.setAllCaps(true);
                    } else {
                        tab.setText(tab.getText().toString().toUpperCase(locale));
                    }
                }
                if (i == this.selectedPosition) {
                    tab.setTextColor(this.selectedTabTextColor);
                } else {
                    tab.setTextColor(this.tabTextColor);
                }
            }
        }
    }
}

From source file:io.plaidapp.ui.DesignerNewsStory.java

private void bindDescription() {
    final TextView storyComment = (TextView) header.findViewById(R.id.story_comment);
    if (!TextUtils.isEmpty(story.comment)) {
        HtmlUtils.setTextWithNiceLinks(storyComment,
                markdown.markdownToSpannable(story.comment, storyComment, new Bypass.LoadImageCallback() {
                    @Override/*from  w  w w .j  a  va2  s.  c  om*/
                    public void loadImage(String src, ImageLoadingSpan loadingSpan) {
                        Glide.with(DesignerNewsStory.this).load(src).asBitmap()
                                .diskCacheStrategy(DiskCacheStrategy.ALL)
                                .into(new ImageSpanTarget(storyComment, loadingSpan));
                    }
                }));
    } else {
        storyComment.setVisibility(View.GONE);
    }

    upvoteStory = (Button) header.findViewById(R.id.story_vote_action);
    upvoteStory.setText(getResources().getQuantityString(R.plurals.upvotes, story.vote_count,
            NumberFormat.getInstance().format(story.vote_count)));
    upvoteStory.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            upvoteStory();
        }
    });

    Button share = (Button) header.findViewById(R.id.story_share_action);
    share.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(ShareCompat.IntentBuilder.from(DesignerNewsStory.this).setText(story.url)
                    .setType("text/plain").setSubject(story.title).getIntent());
        }
    });

    TextView storyPosterTime = (TextView) header.findViewById(R.id.story_poster_time);
    SpannableString poster = new SpannableString("" + story.user_display_name);
    poster.setSpan(new TextAppearanceSpan(this, R.style.TextAppearance_CommentAuthor), 0, poster.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    CharSequence job = !TextUtils.isEmpty(story.user_job) ? "\n" + story.user_job : "";
    CharSequence timeAgo = DateUtils.getRelativeTimeSpanString(story.created_at.getTime(),
            System.currentTimeMillis(), DateUtils.SECOND_IN_MILLIS);
    storyPosterTime.setText(TextUtils.concat(poster, job, "\n", timeAgo));
    ImageView avatar = (ImageView) header.findViewById(R.id.story_poster_avatar);
    if (!TextUtils.isEmpty(story.user_portrait_url)) {
        Glide.with(this).load(story.user_portrait_url).placeholder(R.drawable.avatar_placeholder)
                .transform(circleTransform).into(avatar);
    } else {
        avatar.setVisibility(View.GONE);
    }
}

From source file:io.plaidapp.ui.DesignerNewsStory.java

private void bindDescription() {
    final TextView storyComment = (TextView) header.findViewById(R.id.story_comment);
    if (!TextUtils.isEmpty(story.comment)) {
        HtmlUtils.parseMarkdownAndSetText(storyComment, story.comment, markdown,
                new Bypass.LoadImageCallback() {
                    @Override/*from   ww w  .  j  av  a  2s  . co  m*/
                    public void loadImage(String src, ImageLoadingSpan loadingSpan) {
                        Glide.with(DesignerNewsStory.this).load(src).asBitmap()
                                .diskCacheStrategy(DiskCacheStrategy.ALL)
                                .into(new ImageSpanTarget(storyComment, loadingSpan));
                    }
                });
    } else {
        storyComment.setVisibility(View.GONE);
    }

    upvoteStory = (TextView) header.findViewById(R.id.story_vote_action);
    upvoteStory.setText(getResources().getQuantityString(R.plurals.upvotes, story.vote_count,
            NumberFormat.getInstance().format(story.vote_count)));
    upvoteStory.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            upvoteStory();
        }
    });

    final TextView share = (TextView) header.findViewById(R.id.story_share_action);
    share.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((AnimatedVectorDrawable) share.getCompoundDrawables()[1]).start();
            startActivity(ShareCompat.IntentBuilder.from(DesignerNewsStory.this).setText(story.url)
                    .setType("text/plain").setSubject(story.title).getIntent());
        }
    });

    TextView storyPosterTime = (TextView) header.findViewById(R.id.story_poster_time);
    SpannableString poster = new SpannableString(story.user_display_name.toLowerCase());
    poster.setSpan(new TextAppearanceSpan(this, R.style.TextAppearance_CommentAuthor), 0, poster.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    CharSequence job = !TextUtils.isEmpty(story.user_job) ? "\n" + story.user_job.toLowerCase() : "";
    CharSequence timeAgo = DateUtils.getRelativeTimeSpanString(story.created_at.getTime(),
            System.currentTimeMillis(), DateUtils.SECOND_IN_MILLIS).toString().toLowerCase();
    storyPosterTime.setText(TextUtils.concat(poster, job, "\n", timeAgo));
    ImageView avatar = (ImageView) header.findViewById(R.id.story_poster_avatar);
    if (!TextUtils.isEmpty(story.user_portrait_url)) {
        Glide.with(this).load(story.user_portrait_url).placeholder(R.drawable.avatar_placeholder)
                .transform(circleTransform).into(avatar);
    } else {
        avatar.setVisibility(View.GONE);
    }
}

From source file:com.android.launcher3.Utilities.java

/**
 * Wraps a message with a TTS span, so that a different message is spoken than
 * what is getting displayed./*from w  w  w .j a v  a2 s .co  m*/
 * @param msg original message
 * @param ttsMsg message to be spoken
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static CharSequence wrapForTts(CharSequence msg, String ttsMsg) {
    if (Utilities.ATLEAST_LOLLIPOP) {
        SpannableString spanned = new SpannableString(msg);
        spanned.setSpan(new TtsSpan.TextBuilder(ttsMsg).build(), 0, spanned.length(),
                Spannable.SPAN_INCLUSIVE_INCLUSIVE);
        return spanned;
    } else {
        return msg;
    }
}

From source file:com.geecko.QuickLyric.fragment.LyricsViewFragment.java

@SuppressLint("SetTextI18n")
public void update(Lyrics lyrics, View layout, boolean animation) {
    File musicFile = null;//  w w w  .  java  2  s  . c o m
    Bitmap cover = null;
    if (PermissionsChecker.hasPermission(getActivity(), "android.permission.READ_EXTERNAL_STORAGE")) {
        musicFile = Id3Reader.getFile(getActivity(), lyrics.getOriginalArtist(), lyrics.getOriginalTrack());
        cover = Id3Reader.getCover(getActivity(), lyrics.getArtist(), lyrics.getTitle());
    }
    setCoverArt(cover, null);
    boolean artCellDownload = Integer.valueOf(
            PreferenceManager.getDefaultSharedPreferences(getActivity()).getString("pref_artworks", "0")) == 0;
    if (cover == null)
        new CoverArtLoader().execute(lyrics, this.getActivity(),
                artCellDownload || OnlineAccessVerifier.isConnectedWifi(getActivity()));
    getActivity().findViewById(R.id.edit_tags_btn).setEnabled(true);
    getActivity().findViewById(R.id.edit_tags_btn)
            .setVisibility(musicFile == null || !musicFile.canWrite() || lyrics.isLRC()
                    || Id3Reader.getLyrics(getActivity(), lyrics.getArtist(), lyrics.getTitle()) == null
                            ? View.GONE
                            : View.VISIBLE);
    TextSwitcher textSwitcher = ((TextSwitcher) layout.findViewById(R.id.switcher));
    LrcView lrcView = (LrcView) layout.findViewById(R.id.lrc_view);
    View v = getActivity().findViewById(R.id.tracks_msg);
    if (v != null)
        ((ViewGroup) v.getParent()).removeView(v);
    TextView artistTV = (TextView) getActivity().findViewById(R.id.artist);
    TextView songTV = (TextView) getActivity().findViewById(R.id.song);
    final TextView id3TV = (TextView) layout.findViewById(R.id.source_tv);
    TextView writerTV = (TextView) layout.findViewById(R.id.writer_tv);
    TextView copyrightTV = (TextView) layout.findViewById(R.id.copyright_tv);
    RelativeLayout bugLayout = (RelativeLayout) layout.findViewById(R.id.error_msg);
    this.mLyrics = lyrics;
    if (SDK_INT >= ICE_CREAM_SANDWICH)
        beamLyrics(lyrics, this.getActivity());
    new PresenceChecker().execute(this, new String[] { lyrics.getArtist(), lyrics.getTitle(),
            lyrics.getOriginalArtist(), lyrics.getOriginalTrack() });

    if (lyrics.getArtist() != null)
        artistTV.setText(lyrics.getArtist());
    else
        artistTV.setText("");
    if (lyrics.getTitle() != null)
        songTV.setText(lyrics.getTitle());
    else
        songTV.setText("");
    if (lyrics.getCopyright() != null) {
        copyrightTV.setText("Copyright: " + lyrics.getCopyright());
        copyrightTV.setVisibility(View.VISIBLE);
    } else {
        copyrightTV.setText("");
        copyrightTV.setVisibility(View.GONE);
    }
    if (lyrics.getWriter() != null) {
        if (lyrics.getWriter().contains(","))
            writerTV.setText("Writers:\n" + lyrics.getWriter());
        else
            writerTV.setText("Writer:" + lyrics.getWriter());
        writerTV.setVisibility(View.VISIBLE);
    } else {
        writerTV.setText("");
        writerTV.setVisibility(View.GONE);
    }
    if (isActiveFragment)
        ((RefreshIcon) getActivity().findViewById(R.id.refresh_fab)).show();
    EditText newLyrics = (EditText) getActivity().findViewById(R.id.edit_lyrics);
    if (newLyrics != null)
        newLyrics.setText("");

    if (lyrics.getFlag() == Lyrics.POSITIVE_RESULT) {
        if (!lyrics.isLRC()) {
            textSwitcher.setVisibility(View.VISIBLE);
            lrcView.setVisibility(View.GONE);
            if (animation)
                textSwitcher.setText(Html.fromHtml(lyrics.getText()));
            else
                textSwitcher.setCurrentText(Html.fromHtml(lyrics.getText()));
        } else {
            textSwitcher.setVisibility(View.GONE);
            lrcView.setVisibility(View.VISIBLE);
            lrcView.setOriginalLyrics(lyrics);
            lrcView.setSourceLrc(lyrics.getText());
            if (isActiveFragment)
                ((ControllableAppBarLayout) getActivity().findViewById(R.id.appbar)).expandToolbar(true);
            updateLRC();
        }

        bugLayout.setVisibility(View.INVISIBLE);
        id3TV.setMovementMethod(LinkMovementMethod.getInstance());
        if ("Storage".equals(lyrics.getSource())) {
            id3TV.setVisibility(View.VISIBLE);
            SpannableString text = new SpannableString(getString(R.string.from_id3));
            text.setSpan(new UnderlineSpan(), 1, text.length() - 1, 0);
            id3TV.setText(text);
            id3TV.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    ((MainActivity) getActivity()).id3PopUp(id3TV);
                }
            });
        } else {
            id3TV.setOnClickListener(null);
            id3TV.setVisibility(View.GONE);
        }
        mScrollView.post(new Runnable() {
            @Override
            public void run() {
                mScrollView.scrollTo(0, 0); //only useful when coming from localLyricsFragment
                mScrollView.smoothScrollTo(0, 0);
            }
        });
    } else {
        textSwitcher.setText("");
        textSwitcher.setVisibility(View.INVISIBLE);
        lrcView.setVisibility(View.INVISIBLE);
        bugLayout.setVisibility(View.VISIBLE);
        int message;
        int whyVisibility;
        if (lyrics.getFlag() == Lyrics.ERROR || !OnlineAccessVerifier.check(getActivity())) {
            message = R.string.connection_error;
            whyVisibility = TextView.GONE;
        } else {
            message = R.string.no_results;
            whyVisibility = TextView.VISIBLE;
            updateSearchView(false, lyrics.getTitle(), false);
        }
        TextView whyTextView = ((TextView) bugLayout.findViewById(R.id.bugtext_why));
        ((TextView) bugLayout.findViewById(R.id.bugtext)).setText(message);
        whyTextView.setVisibility(whyVisibility);
        whyTextView.setPaintFlags(whyTextView.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
        id3TV.setVisibility(View.GONE);
    }
    stopRefreshAnimation();
    getActivity().getIntent().setAction("");
    getActivity().invalidateOptionsMenu();
}

From source file:com.fastbootmobile.encore.app.fragments.PlaylistViewFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View root = inflater.inflate(R.layout.fragment_playlist_view, container, false);
    assert root != null;

    if (mPlaylist == null) {
        // If playlist couldn't load, abort early
        return root;
    }//  w w  w .  j a v  a 2 s.  c o  m

    mListViewContents = (PlaylistListView) root.findViewById(R.id.lvPlaylistContents);

    // Setup the parallaxed header
    View headerView = inflater.inflate(R.layout.header_listview_songs, mListViewContents, false);
    mListViewContents.addParallaxedHeaderView(headerView);

    mAdapter = new PlaylistAdapter();
    mListViewContents.setAdapter(mAdapter);
    mListViewContents.setOnScrollListener(new ScrollStatusBarColorListener() {
        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            if (view.getChildCount() == 0 || getActivity() == null) {
                return;
            }

            final float heroHeight = mIvHero.getMeasuredHeight();
            final float scrollY = getScroll(view);
            final float toolbarBgAlpha = Math.min(1, scrollY / heroHeight);
            final int toolbarAlphaInteger = (((int) (toolbarBgAlpha * 255)) << 24) | 0xFFFFFF;
            mColorDrawable.setColor(toolbarAlphaInteger & getResources().getColor(R.color.primary));

            SpannableString spannableTitle = new SpannableString(
                    mPlaylist.getName() != null ? mPlaylist.getName() : "");
            mAlphaSpan.setAlpha(toolbarBgAlpha);

            ActionBar actionbar = ((AppActivity) getActivity()).getSupportActionBar();
            if (actionbar != null) {
                actionbar.setBackgroundDrawable(mColorDrawable);
                spannableTitle.setSpan(mAlphaSpan, 0, spannableTitle.length(),
                        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                actionbar.setTitle(spannableTitle);
                if (Utils.hasLollipop()) {
                    getActivity().getWindow().setStatusBarColor(
                            toolbarAlphaInteger & getResources().getColor(R.color.primary_dark));
                }
            }
        }
    });

    headerView.findViewById(R.id.pbAlbumLoading).setVisibility(View.GONE);

    mIvHero = (ImageView) headerView.findViewById(R.id.ivHero);

    mTvPlaylistName = (TextView) headerView.findViewById(R.id.tvAlbumName);

    // Download button
    mOfflineBtn = (CircularProgressButton) headerView.findViewById(R.id.cpbOffline);
    mOfflineBtn.setAlpha(0.0f);
    mOfflineBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ProviderIdentifier pi = mPlaylist.getProvider();
            IMusicProvider provider = PluginsLookup.getDefault().getProvider(pi).getBinder();
            try {
                if (mPlaylist.getOfflineStatus() == BoundEntity.OFFLINE_STATUS_NO) {
                    provider.setPlaylistOfflineMode(mPlaylist.getRef(), true);
                    mOfflineBtn.setIndeterminateProgressMode(true);
                    mOfflineBtn.setProgress(1);

                    if (ProviderAggregator.getDefault().isOfflineMode()) {
                        Toast.makeText(getActivity(), R.string.toast_offline_playlist_sync, Toast.LENGTH_SHORT)
                                .show();
                    }
                } else {
                    provider.setPlaylistOfflineMode(mPlaylist.getRef(), false);
                    mOfflineBtn.setProgress(0);
                }
            } catch (RemoteException e) {
                Log.e(TAG, "Cannot set this playlist to offline mode", e);
                mOfflineBtn.setProgress(-1);
            }
        }
    });

    mHandler.sendEmptyMessageDelayed(UPDATE_OFFLINE_STATUS, 300);
    mTvPlaylistName.setText(mPlaylist.getName());

    Bitmap hero = Utils.dequeueBitmap(PlaylistActivity.BITMAP_PLAYLIST_HERO);
    if (hero == null) {
        mIvHero.setImageResource(R.drawable.album_placeholder);
    } else {
        mIvHero.setImageBitmap(hero);

        // Request the higher resolution
        loadArt();
    }

    mPlayFab = (FloatingActionButton) headerView.findViewById(R.id.fabPlay);

    // Set source logo
    mIvSource = (ImageView) headerView.findViewById(R.id.ivSourceLogo);
    mLogoBitmap = PluginsLookup.getDefault().getCachedLogo(getResources(), mPlaylist);
    mIvSource.setImageDrawable(mLogoBitmap);

    // Set the FAB animated drawable
    mFabDrawable = new PlayPauseDrawable(getResources(), 1);
    mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PLAY);
    mFabDrawable.setYOffset(6);

    mPlayFab.setImageDrawable(mFabDrawable);
    mPlayFab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mFabDrawable.getCurrentShape() == PlayPauseDrawable.SHAPE_PLAY) {
                if (mFabShouldResume) {
                    PlaybackProxy.play();
                    mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PAUSE);
                    mFabDrawable.setBuffering(true);
                } else {
                    playNow();
                }

                if (Utils.hasLollipop()) {
                    showMaterialReelBar(mPlayFab);
                }
            } else {
                mFabShouldResume = true;
                PlaybackProxy.pause();
                mFabDrawable.setBuffering(true);
            }
        }
    });

    // Fill the playlist
    mAdapter.setPlaylist(mPlaylist);

    // Set the list listener
    mListViewContents.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            Song song = mAdapter.getItem(i - 1);
            if (Utils.canPlaySong(song)) {
                PlaybackProxy.clearQueue();
                PlaybackProxy.queuePlaylist(mPlaylist, false);
                PlaybackProxy.playAtIndex(i - 1);

                // Update FAB
                mFabShouldResume = true;
                mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PAUSE);
                mFabDrawable.setBuffering(true);

                if (Utils.hasLollipop()) {
                    showMaterialReelBar(mPlayFab);
                }
            }
        }
    });

    // Set the display animation
    AlphaAnimation anim = new AlphaAnimation(0.f, 1.f);
    anim.setDuration(200);
    mListViewContents.setLayoutAnimation(new LayoutAnimationController(anim));

    setupMaterialReelBar(root, mReelFabClickListener);

    // Setup the opening animations for non-Lollipop devices
    if (!Utils.hasLollipop()) {
        mTvPlaylistName.setVisibility(View.VISIBLE);
        mTvPlaylistName.setAlpha(0.0f);
        mTvPlaylistName.animate().alpha(1.0f).setDuration(AlbumActivity.BACK_DELAY).start();
    }

    mIvSource.setAlpha(0.0f);
    mIvSource.animate().alpha(1).setDuration(200).start();

    return root;
}