Refactoring
This commit is contained in:
parent
aabd0367b9
commit
8a57d32214
3 changed files with 30 additions and 26 deletions
|
|
@ -5,8 +5,8 @@ import android.util.SparseArray;
|
|||
public abstract class AbsSynchronizedLyrics extends Lyrics {
|
||||
private static final int TIME_OFFSET_MS = 500; // time adjustment to display line before it actually starts
|
||||
|
||||
public final SparseArray<String> lines = new SparseArray<>();
|
||||
public int offset = 0;
|
||||
protected final SparseArray<String> lines = new SparseArray<>();
|
||||
protected int offset = 0;
|
||||
|
||||
public String getLine(int time) {
|
||||
time += offset + AbsSynchronizedLyrics.TIME_OFFSET_MS;
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ public class Lyrics {
|
|||
public Song song;
|
||||
public String data;
|
||||
|
||||
boolean parsed = false;
|
||||
boolean valid = false;
|
||||
protected boolean parsed = false;
|
||||
protected boolean valid = false;
|
||||
|
||||
public Lyrics setData(Song song, String data) {
|
||||
this.song = song;
|
||||
|
|
|
|||
|
|
@ -184,21 +184,33 @@ public class PlayerAlbumCoverFragment extends AbsMusicServiceFragment implements
|
|||
.start();
|
||||
}
|
||||
|
||||
private boolean isLyricsLayoutVisible() {
|
||||
return lyrics != null && lyrics.isSynchronized() && lyrics.isValid() && PreferenceUtil.getInstance(getActivity()).synchronizedLyricsShow();
|
||||
}
|
||||
|
||||
private boolean isLyricsLayoutBound() {
|
||||
return lyricsLayout != null && lyricsLine1 != null && lyricsLine2 != null;
|
||||
}
|
||||
|
||||
private void hideLyricsLayout() {
|
||||
lyricsLayout.animate().alpha(0f).setDuration(PlayerAlbumCoverFragment.LYRICS_ANIM_DURATION).withEndAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!isLyricsLayoutBound()) return;
|
||||
lyricsLayout.setVisibility(View.GONE);
|
||||
lyricsLine1.setText(null);
|
||||
lyricsLine2.setText(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setLyrics(Lyrics l) {
|
||||
lyrics = l;
|
||||
|
||||
if (lyricsLayout == null || lyricsLine1 == null || lyricsLine2 == null) return;
|
||||
if (!isLyricsLayoutBound()) return;
|
||||
|
||||
if (!PreferenceUtil.getInstance(getActivity()).synchronizedLyricsShow() || l == null || !l.isSynchronized() || !l.isValid()) {
|
||||
lyricsLayout.animate().alpha(0f).setDuration(PlayerAlbumCoverFragment.LYRICS_ANIM_DURATION).withEndAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (lyricsLayout == null || lyricsLine1 == null || lyricsLine2 == null) return;
|
||||
lyricsLayout.setVisibility(View.GONE);
|
||||
lyricsLine1.setText(null);
|
||||
lyricsLine2.setText(null);
|
||||
}
|
||||
});
|
||||
if (!isLyricsLayoutVisible()) {
|
||||
hideLyricsLayout();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -219,18 +231,10 @@ public class PlayerAlbumCoverFragment extends AbsMusicServiceFragment implements
|
|||
|
||||
@Override
|
||||
public void onUpdateProgressViews(int progress, int total) {
|
||||
if (lyricsLayout == null || lyricsLine1 == null || lyricsLine2 == null) return;
|
||||
if (!isLyricsLayoutBound()) return;
|
||||
|
||||
if (!PreferenceUtil.getInstance(getActivity()).synchronizedLyricsShow() || lyrics == null || !lyrics.isSynchronized() || !lyrics.isValid()) {
|
||||
lyricsLayout.animate().alpha(0f).setDuration(PlayerAlbumCoverFragment.LYRICS_ANIM_DURATION).withEndAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (lyricsLayout == null || lyricsLine1 == null || lyricsLine2 == null) return;
|
||||
lyricsLayout.setVisibility(View.GONE);
|
||||
lyricsLine1.setText(null);
|
||||
lyricsLine2.setText(null);
|
||||
}
|
||||
});
|
||||
if (!isLyricsLayoutVisible()) {
|
||||
hideLyricsLayout();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue