mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-09-01 06:35:09 +00:00
Simplify MPRIS callback code
Summary: Makes sure the MPRIS data is always up-to-date, so requesting updates separately is never necessary. Also provides a way to remove callbacks. Test Plan: All information still appears in the MPRIS activity and the controls still work. Reviewers: #kde_connect, albertvaka Reviewed By: #kde_connect, albertvaka Differential Revision: https://phabricator.kde.org/D9084
This commit is contained in:
committed by
Albert Vaca
parent
044261ceb1
commit
147d8510d5
@@ -198,6 +198,10 @@ public class MprisPlugin extends Plugin {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCreate() {
|
public boolean onCreate() {
|
||||||
requestPlayerList();
|
requestPlayerList();
|
||||||
|
|
||||||
|
//Always request the player list so the data is up-to-date
|
||||||
|
requestPlayerList();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,22 +316,20 @@ public class MprisPlugin extends Plugin {
|
|||||||
playerStatusUpdated.put(id, h);
|
playerStatusUpdated.put(id, h);
|
||||||
|
|
||||||
h.dispatchMessage(new Message());
|
h.dispatchMessage(new Message());
|
||||||
|
}
|
||||||
|
|
||||||
//Get the status if this is the first handler we have
|
public void removePlayerStatusUpdatedHandler(String id) {
|
||||||
if (playerListUpdated.size() == 1 && !players.isEmpty()) {
|
playerStatusUpdated.remove(id);
|
||||||
requestPlayerStatus(getPlayerList().get(0));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlayerListUpdatedHandler(String id, Handler h) {
|
public void setPlayerListUpdatedHandler(String id, Handler h) {
|
||||||
playerListUpdated.put(id,h);
|
playerListUpdated.put(id,h);
|
||||||
|
|
||||||
h.dispatchMessage(new Message());
|
h.dispatchMessage(new Message());
|
||||||
|
}
|
||||||
|
|
||||||
//Get the status if this is the first handler we have
|
public void removePlayerListUpdatedHandler(String id) {
|
||||||
if (playerListUpdated.size() == 1) {
|
playerListUpdated.remove(id);
|
||||||
requestPlayerList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getPlayerList() {
|
public List<String> getPlayerList() {
|
||||||
|
Reference in New Issue
Block a user