Unify next/previous in CoverView
This commit is contained in:
parent
67dc10a84b
commit
079221eafb
@ -251,42 +251,37 @@ public class CoverView extends View {
|
|||||||
mHandler.sendEmptyMessage(0);
|
mHandler.sendEmptyMessage(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nextCover()
|
private void shiftCover(int delta)
|
||||||
{
|
{
|
||||||
if (mService == null)
|
if (mService == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mService.nextSong();
|
mService.setCurrentSong(delta);
|
||||||
|
|
||||||
System.arraycopy(mSongs, 1, mSongs, 0, STORE_SIZE - 1);
|
int from = delta > 0 ? 1 : 0;
|
||||||
System.arraycopy(mBitmaps, 1, mBitmaps, 0, STORE_SIZE - 1);
|
int to = delta > 0 ? 0 : 1;
|
||||||
mSongs[STORE_SIZE - 1] = null;
|
int i = delta > 0 ? STORE_SIZE - 1 : 0;
|
||||||
mBitmaps[STORE_SIZE - 1] = null;
|
|
||||||
|
System.arraycopy(mSongs, from, mSongs, to, STORE_SIZE - 1);
|
||||||
|
System.arraycopy(mBitmaps, from, mBitmaps, to, STORE_SIZE - 1);
|
||||||
|
mSongs[i] = null;
|
||||||
|
mBitmaps[i] = null;
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
mHandler.sendEmptyMessage(2);
|
mHandler.sendEmptyMessage(i);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void nextCover()
|
||||||
|
{
|
||||||
|
shiftCover(1);
|
||||||
|
}
|
||||||
|
|
||||||
public void previousCover()
|
public void previousCover()
|
||||||
{
|
{
|
||||||
if (mService == null)
|
shiftCover(-1);
|
||||||
return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
mService.previousSong();
|
|
||||||
|
|
||||||
System.arraycopy(mSongs, 0, mSongs, 1, STORE_SIZE - 1);
|
|
||||||
System.arraycopy(mBitmaps, 0, mBitmaps, 1, STORE_SIZE - 1);
|
|
||||||
mSongs[0] = null;
|
|
||||||
mBitmaps[0] = null;
|
|
||||||
reset();
|
|
||||||
|
|
||||||
mHandler.sendEmptyMessage(0);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void togglePlayback()
|
public void togglePlayback()
|
||||||
@ -418,11 +413,7 @@ public class CoverView extends View {
|
|||||||
scrollTo(mScroller.getCurrX(), mScroller.getCurrY());
|
scrollTo(mScroller.getCurrX(), mScroller.getCurrY());
|
||||||
postInvalidate();
|
postInvalidate();
|
||||||
} else if (mTentativeCover != -1) {
|
} else if (mTentativeCover != -1) {
|
||||||
if (mTentativeCover == 2)
|
shiftCover(mTentativeCover - 1);
|
||||||
nextCover();
|
|
||||||
else if (mTentativeCover == 0)
|
|
||||||
previousCover();
|
|
||||||
|
|
||||||
mTentativeCover = -1;
|
mTentativeCover = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,7 @@ interface IPlaybackService {
|
|||||||
int getPosition();
|
int getPosition();
|
||||||
int getDuration();
|
int getDuration();
|
||||||
|
|
||||||
void previousSong();
|
void setCurrentSong(int delta);
|
||||||
void togglePlayback();
|
void togglePlayback();
|
||||||
void nextSong();
|
|
||||||
void seekToProgress(int progress);
|
void seekToProgress(int progress);
|
||||||
}
|
}
|
@ -103,14 +103,9 @@ public class PlaybackService extends Service implements Runnable, MediaPlayer.On
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nextSong()
|
public void setCurrentSong(int delta)
|
||||||
{
|
{
|
||||||
setCurrentSong(1);
|
PlaybackService.this.setCurrentSong(delta);
|
||||||
}
|
|
||||||
|
|
||||||
public void previousSong()
|
|
||||||
{
|
|
||||||
setCurrentSong(-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void togglePlayback()
|
public void togglePlayback()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user