mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-02-01 11:16:47 +01:00
Fixed NullpointerException in PlayerWidgetService
This commit is contained in:
parent
bee7f28500
commit
850cf5204a
@ -24,6 +24,10 @@ public class PlayerWidgetService extends Service {
|
|||||||
private static final String TAG = "PlayerWidgetService";
|
private static final String TAG = "PlayerWidgetService";
|
||||||
|
|
||||||
private PlaybackService playbackService;
|
private PlaybackService playbackService;
|
||||||
|
|
||||||
|
/** Controls write access to playbackservice reference */
|
||||||
|
private Object psLock;
|
||||||
|
|
||||||
/** True while service is updating the widget */
|
/** True while service is updating the widget */
|
||||||
private volatile boolean isUpdating;
|
private volatile boolean isUpdating;
|
||||||
|
|
||||||
@ -36,6 +40,7 @@ public class PlayerWidgetService extends Service {
|
|||||||
if (BuildConfig.DEBUG)
|
if (BuildConfig.DEBUG)
|
||||||
Log.d(TAG, "Service created");
|
Log.d(TAG, "Service created");
|
||||||
isUpdating = false;
|
isUpdating = false;
|
||||||
|
psLock = new Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -148,16 +153,20 @@ public class PlayerWidgetService extends Service {
|
|||||||
public void onServiceConnected(ComponentName className, IBinder service) {
|
public void onServiceConnected(ComponentName className, IBinder service) {
|
||||||
if (BuildConfig.DEBUG)
|
if (BuildConfig.DEBUG)
|
||||||
Log.d(TAG, "Connection to service established");
|
Log.d(TAG, "Connection to service established");
|
||||||
playbackService = ((PlaybackService.LocalBinder) service)
|
synchronized (psLock) {
|
||||||
.getService();
|
playbackService = ((PlaybackService.LocalBinder) service)
|
||||||
startViewUpdaterIfNotRunning();
|
.getService();
|
||||||
|
startViewUpdaterIfNotRunning();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
playbackService = null;
|
synchronized (psLock) {
|
||||||
if (BuildConfig.DEBUG)
|
playbackService = null;
|
||||||
Log.d(TAG, "Disconnected from service");
|
if (BuildConfig.DEBUG)
|
||||||
|
Log.d(TAG, "Disconnected from service");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -169,7 +178,7 @@ public class PlayerWidgetService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ViewUpdater extends Thread {
|
class ViewUpdater extends Thread {
|
||||||
private static final String THREAD_NAME = "ViewUpdater";
|
private static final String THREAD_NAME = "ViewUpdater";
|
||||||
private PlayerWidgetService service;
|
private PlayerWidgetService service;
|
||||||
|
|
||||||
@ -182,7 +191,9 @@ public class PlayerWidgetService extends Service {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
service.updateViews();
|
synchronized (psLock) {
|
||||||
|
service.updateViews();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user