refactor: move synchronized keyword in funtion header

This commit is contained in:
Jakob Kukla 2021-11-15 23:53:13 +01:00
commit a429198833

View file

@ -497,8 +497,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
playSongAt(queueManager.getNextPosition(force));
}
private void openTrackAndPrepareNextAt(int position) {
synchronized (this) {
private synchronized void openTrackAndPrepareNextAt(int position) {
queueManager.position = position;
openCurrent();
@ -507,29 +506,24 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
notifyChange(META_CHANGED);
notHandledMetaChangedForCurrentTrack = false;
}
}
private void openCurrent() {
synchronized (this) {
private synchronized void openCurrent() {
if (queueManager.getCurrentSong() == null) return;
playback.setDataSource(queueManager.getCurrentSong());
}
}
private void prepareNext() {
playerHandler.removeMessages(PREPARE_NEXT);
playerHandler.obtainMessage(PREPARE_NEXT).sendToTarget();
}
private void prepareNextImpl() {
synchronized (this) {
private synchronized void prepareNextImpl() {
if (queueManager.getCurrentSong() == null) return;
queueManager.nextPosition = queueManager.getNextPosition(false);
playback.queueDataSource(queueManager.getSongAt(queueManager.nextPosition));
}
}
public void initNotification() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && !PreferenceUtil.getInstance(this).getClassicNotification()) {
@ -656,8 +650,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
}
}
public void play() {
synchronized (this) {
public synchronized void play() {
if (!playback.isPlaying()) {
if (!playback.isReady()) {
playSongAt(queueManager.position);
@ -672,7 +665,6 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
}
}
}
}
public void playPreviousSong(boolean force) {
playSongAt(queueManager.getPreviousPosition(force));
@ -694,13 +686,11 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
return playback.getDuration();
}
public int seek(int millis) {
synchronized (this) {
public synchronized int seek(int millis) {
playback.setProgress(millis);
throttledSeekHandler.notifySeek();
return millis;
}
}
private void notifyChange(@NonNull final String what) {
handleChangeInternal(what);