// TODO lyrics load animation private void loadLyricsToView() { if (mLyricsScrollView == null || mInterface == null) return; mLyricsScrollView.setTextContent(mInterface.getLyrics()); if (!mSearchShowed) { if (mInterface.getLyricsStatus() == LYRICS_STATUS_OK) { mLyricsScrollView.setVisibility(View.VISIBLE); mLyricsEmptyView.setVisibility(View.GONE); } else { mLyricsScrollView.setVisibility(View.GONE); mLyricsEmptyView.setVisibility(View.VISIBLE); } } }
private void searchLyrics() { if (mInterface == null) return; FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_FADE); Bundle args = new Bundle(); args.putString(INTENT_KEY_TRACK, mInterface.getTrackName()); args.putString(INTENT_KEY_ARTIST, mInterface.getArtistName()); String media_path = mInterface.getMediaPath(); String lyrics_path = media_path.substring(0, media_path.lastIndexOf(".")) + ".lrc"; args.putString(INTENT_KEY_PATH, lyrics_path); mSearchFragment.setArguments(args); ft.replace(R.id.search_lyrics, mSearchFragment); ft.addToBackStack(SEARCH_LYRICS); ft.commit(); }
@Override public void onActivityCreated(Bundle savedInstanceState) { mInterface = ((YAMMPApplication) getSherlockActivity().getApplication()).getServiceInterface(); super.onActivityCreated(savedInstanceState); mSearchFragment = new LyricsSearchFragment(); getFragmentManager().addOnBackStackChangedListener(this); View view = getView(); mLyricsScrollView = (TextScrollView) view.findViewById(R.id.lyrics_scroll); mLyricsScrollView.setContentGravity(Gravity.CENTER_HORIZONTAL); mLyricsScrollView.setLineSelectedListener(this); mLyricsEmptyView = (Button) view.findViewById(R.id.lyrics_empty); mLyricsEmptyView.setOnClickListener(this); mLyricsSearchLayout = (LinearLayout) view.findViewById(R.id.search_lyrics); mInterface.addLyricsStateListener(this); }
@Override public void onBackStackChanged() { if (mSearchFragment != null) { boolean search_showed = mSearchFragment.isAdded(); mSearchShowed = search_showed; mLyricsSearchLayout.setVisibility(search_showed ? View.VISIBLE : View.GONE); if (mInterface != null) { boolean lyrics_status_ok = mInterface.getLyricsStatus() == LYRICS_STATUS_OK; mLyricsEmptyView.setVisibility( search_showed || lyrics_status_ok ? View.GONE : View.VISIBLE); mLyricsScrollView.setVisibility( search_showed || !lyrics_status_ok ? View.GONE : View.VISIBLE); } } }
private void scrollLyrics(boolean force) { if (mInterface == null) return; if (mLyricsScrollView == null) return; mLyricsScrollView.setCurrentLine(mInterface.getCurrentLyricsId(), force); }
@Override public void onLineSelected(int id) { if (mInterface != null) { mInterface.seek(mInterface.getPositionByLyricsId(id)); } }