mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 18:03:33 +00:00
TEST - Removed wakelock manager from service
This commit is contained in:
parent
62fb57736a
commit
b54e3588ba
2 changed files with 12 additions and 50 deletions
|
|
@ -71,11 +71,9 @@ public class MusicService extends Service implements Playback.PlaybackCallbacks
|
||||||
public static final int TRACK_STARTED = 9;
|
public static final int TRACK_STARTED = 9;
|
||||||
public static final int TRACK_CHANGED = 1;
|
public static final int TRACK_CHANGED = 1;
|
||||||
public static final int TRACK_ENDED = 2;
|
public static final int TRACK_ENDED = 2;
|
||||||
public static final int RELEASE_WAKELOCK = 0;
|
|
||||||
public static final int PLAY_SONG = 3;
|
public static final int PLAY_SONG = 3;
|
||||||
public static final int PREPARE_NEXT = 4;
|
public static final int PREPARE_NEXT = 4;
|
||||||
public static final int SET_POSITION = 5;
|
public static final int SET_POSITION = 5;
|
||||||
public static final int LOAD_QUEUE = 9;
|
|
||||||
|
|
||||||
private static final long MEDIA_SESSION_ACTIONS = PlaybackStateCompat.ACTION_PLAY
|
private static final long MEDIA_SESSION_ACTIONS = PlaybackStateCompat.ACTION_PLAY
|
||||||
| PlaybackStateCompat.ACTION_PAUSE
|
| PlaybackStateCompat.ACTION_PAUSE
|
||||||
|
|
@ -93,7 +91,6 @@ public class MusicService extends Service implements Playback.PlaybackCallbacks
|
||||||
private int position = -1;
|
private int position = -1;
|
||||||
private int nextPosition = -1;
|
private int nextPosition = -1;
|
||||||
private boolean notHandledMetaChangedForCurrentTrack;
|
private boolean notHandledMetaChangedForCurrentTrack;
|
||||||
private boolean queuesRestored;
|
|
||||||
|
|
||||||
private PlayingNotification playingNotification;
|
private PlayingNotification playingNotification;
|
||||||
private final BroadcastReceiver becomingNoisyReceiver = new BroadcastReceiver() {
|
private final BroadcastReceiver becomingNoisyReceiver = new BroadcastReceiver() {
|
||||||
|
|
@ -105,7 +102,6 @@ public class MusicService extends Service implements Playback.PlaybackCallbacks
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private MediaSessionCompat mediaSession;
|
private MediaSessionCompat mediaSession;
|
||||||
private PowerManager.WakeLock wakeLock;
|
|
||||||
private PlaybackHandler playerHandler;
|
private PlaybackHandler playerHandler;
|
||||||
private Handler uiThreadHandler;
|
private Handler uiThreadHandler;
|
||||||
private ThrottledSeekHandler throttledSeekHandler;
|
private ThrottledSeekHandler throttledSeekHandler;
|
||||||
|
|
@ -116,10 +112,6 @@ public class MusicService extends Service implements Playback.PlaybackCallbacks
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
|
||||||
final PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
|
||||||
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName());
|
|
||||||
wakeLock.setReferenceCounted(false);
|
|
||||||
|
|
||||||
playback = new MultiPlayer(this);
|
playback = new MultiPlayer(this);
|
||||||
playback.setCallbacks(this);
|
playback.setCallbacks(this);
|
||||||
|
|
||||||
|
|
@ -251,7 +243,6 @@ public class MusicService extends Service implements Playback.PlaybackCallbacks
|
||||||
mediaSession.setActive(false);
|
mediaSession.setActive(false);
|
||||||
quit();
|
quit();
|
||||||
releaseResources();
|
releaseResources();
|
||||||
wakeLock.release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -274,7 +265,6 @@ public class MusicService extends Service implements Playback.PlaybackCallbacks
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restoreState() {
|
private void restoreState() {
|
||||||
if (!queuesRestored && playingQueue.isEmpty()) {
|
|
||||||
QueueRepository queueRepository = new QueueRepository(App.getInstance());
|
QueueRepository queueRepository = new QueueRepository(App.getInstance());
|
||||||
List<Song> restoredQueue = queueRepository.getSongs();
|
List<Song> restoredQueue = queueRepository.getSongs();
|
||||||
|
|
||||||
|
|
@ -295,9 +285,6 @@ public class MusicService extends Service implements Playback.PlaybackCallbacks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
queuesRestored = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void quit() {
|
private void quit() {
|
||||||
pause();
|
pause();
|
||||||
playingNotification.stop();
|
playingNotification.stop();
|
||||||
|
|
@ -588,15 +575,6 @@ public class MusicService extends Service implements Playback.PlaybackCallbacks
|
||||||
return playback.getDuration();
|
return playback.getDuration();
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getQueueDurationMillis(int position) {
|
|
||||||
long duration = 0;
|
|
||||||
for (int i = position + 1; i < playingQueue.size(); i++) {
|
|
||||||
duration += playingQueue.get(i).getDuration();
|
|
||||||
}
|
|
||||||
|
|
||||||
return duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int seek(int millis) {
|
public int seek(int millis) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
playback.setProgress(millis);
|
playback.setProgress(millis);
|
||||||
|
|
@ -644,12 +622,6 @@ public class MusicService extends Service implements Playback.PlaybackCallbacks
|
||||||
return mediaSession;
|
return mediaSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void releaseWakeLock() {
|
|
||||||
if (wakeLock.isHeld()) {
|
|
||||||
wakeLock.release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void increaseSongCount() {
|
private void increaseSongCount() {
|
||||||
SongRepository songRepository = new SongRepository(App.getInstance());
|
SongRepository songRepository = new SongRepository(App.getInstance());
|
||||||
songRepository.scrobble(getCurrentSong().getId());
|
songRepository.scrobble(getCurrentSong().getId());
|
||||||
|
|
@ -721,12 +693,6 @@ public class MusicService extends Service implements Playback.PlaybackCallbacks
|
||||||
} else {
|
} else {
|
||||||
service.playNextSong();
|
service.playNextSong();
|
||||||
}
|
}
|
||||||
|
|
||||||
sendEmptyMessage(RELEASE_WAKELOCK);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RELEASE_WAKELOCK:
|
|
||||||
service.releaseWakeLock();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PLAY_SONG:
|
case PLAY_SONG:
|
||||||
|
|
|
||||||
|
|
@ -131,10 +131,6 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
|
||||||
if (pageState != -1) {
|
if (pageState != -1) {
|
||||||
MusicPlayerRemote.playSongAt(position);
|
MusicPlayerRemote.playSongAt(position);
|
||||||
pageState = -1;
|
pageState = -1;
|
||||||
|
|
||||||
// TODO: Soluzione termporanea e non totalmente funzionante al problema del cambio colore
|
|
||||||
// TODO: |_ delle righe delle canzoni già riprodotte
|
|
||||||
playerSongQueueAdapter.notifyDataSetChanged();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue