2
0
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:
Matthijs Tijink
2017-12-07 17:52:18 +01:00
committed by Albert Vaca
parent 044261ceb1
commit 147d8510d5

View File

@@ -198,6 +198,10 @@ public class MprisPlugin extends Plugin {
@Override
public boolean onCreate() {
requestPlayerList();
//Always request the player list so the data is up-to-date
requestPlayerList();
return true;
}
@@ -312,22 +316,20 @@ public class MprisPlugin extends Plugin {
playerStatusUpdated.put(id, h);
h.dispatchMessage(new Message());
//Get the status if this is the first handler we have
if (playerListUpdated.size() == 1 && !players.isEmpty()) {
requestPlayerStatus(getPlayerList().get(0));
}
public void removePlayerStatusUpdatedHandler(String id) {
playerStatusUpdated.remove(id);
}
public void setPlayerListUpdatedHandler(String id, Handler h) {
playerListUpdated.put(id,h);
h.dispatchMessage(new Message());
//Get the status if this is the first handler we have
if (playerListUpdated.size() == 1) {
requestPlayerList();
}
public void removePlayerListUpdatedHandler(String id) {
playerListUpdated.remove(id);
}
public List<String> getPlayerList() {