mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
Tried to mitigate the random crash on opening
This commit is contained in:
parent
d8662820f7
commit
3d5182da9a
2 changed files with 17 additions and 12 deletions
|
|
@ -20,6 +20,7 @@ public class App extends Application {
|
|||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
CrashReporter.initialize(this);
|
||||
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
|
|
|
|||
|
|
@ -237,23 +237,27 @@ public class MusicService extends Service implements Playback.PlaybackCallbacks
|
|||
}
|
||||
|
||||
private void restoreState() {
|
||||
QueueRepository queueRepository = new QueueRepository(App.getInstance());
|
||||
List<Song> restoredQueue = queueRepository.getSongs();
|
||||
try {
|
||||
QueueRepository queueRepository = new QueueRepository(App.getInstance());
|
||||
List<Song> restoredQueue = queueRepository.getSongs();
|
||||
|
||||
int restoredPosition = PreferenceUtil.getInstance(getApplicationContext()).getPosition();
|
||||
int restoredPositionInTrack = PreferenceUtil.getInstance(getApplicationContext()).getProgress();
|
||||
int restoredPosition = PreferenceUtil.getInstance(getApplicationContext()).getPosition();
|
||||
int restoredPositionInTrack = PreferenceUtil.getInstance(getApplicationContext()).getProgress();
|
||||
|
||||
if (restoredQueue.size() > 0 && restoredPosition != -1) {
|
||||
this.playingQueue = restoredQueue;
|
||||
if (restoredQueue.size() > 0 && restoredPosition != -1) {
|
||||
this.playingQueue = restoredQueue;
|
||||
|
||||
position = restoredPosition;
|
||||
openCurrent();
|
||||
position = restoredPosition;
|
||||
openCurrent();
|
||||
|
||||
if (restoredPositionInTrack > 0) seek(restoredPositionInTrack);
|
||||
if (restoredPositionInTrack > 0) seek(restoredPositionInTrack);
|
||||
|
||||
notHandledMetaChangedForCurrentTrack = true;
|
||||
handleChangeInternal(META_CHANGED);
|
||||
handleChangeInternal(QUEUE_CHANGED);
|
||||
notHandledMetaChangedForCurrentTrack = true;
|
||||
handleChangeInternal(META_CHANGED);
|
||||
handleChangeInternal(QUEUE_CHANGED);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue