List of usage examples for android.widget TextSwitcher setCurrentText
public void setCurrentText(CharSequence text)
From source file:com.geecko.QuickLyric.tasks.Id3Writer.java
@Override public void onPreExecute() { MainActivity activity = (MainActivity) mContext; ((DrawerLayout) activity.drawer).setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); fragment.enablePullToRefresh(true);/*from www .j a v a2 s . c o m*/ activity.findViewById(R.id.refresh_fab).setEnabled(true); ((RefreshIcon) activity.findViewById(R.id.refresh_fab)).show(); activity.invalidateOptionsMenu(); TextSwitcher textSwitcher = ((TextSwitcher) activity.findViewById(R.id.switcher)); EditText newLyrics = (EditText) activity.findViewById(R.id.edit_lyrics); textSwitcher.setCurrentText(newLyrics.getText().toString()); textSwitcher.setVisibility(View.VISIBLE); newLyrics.setVisibility(View.GONE); }
From source file:com.evandroid.musica.fragment.LyricsViewFragment.java
public void update(Lyrics lyrics, View layout, boolean animation) { 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 id3TV = (TextView) layout.findViewById(R.id.id3_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.getTrack(), lyrics.getOriginalArtist(), lyrics.getOriginalTrack() }); 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/*from ww w .ja v a 2 s.com*/ textSwitcher.setCurrentText(Html.fromHtml(lyrics.getText())); } else { textSwitcher.setVisibility(View.GONE); lrcView.setVisibility(View.VISIBLE); lrcView.setOriginalLyrics(lyrics); lrcView.setSourceLrc(lyrics.getText()); updateLRC(); } bugLayout.setVisibility(View.INVISIBLE); if ("Storage".equals(lyrics.getSource())) id3TV.setVisibility(View.VISIBLE); else 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.getTrack(), 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.geecko.QuickLyric.fragment.LyricsViewFragment.java
@SuppressLint("SetTextI18n") public void update(Lyrics lyrics, View layout, boolean animation) { File musicFile = null;/* www . j a v a 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(); }