[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdeconnect-android] src/org/kde/kdeconnect/Plugins/MprisPlugin: Simplify MPRIS callback code
From:       Albert Vaca <null () kde ! org>
Date:       2017-12-07 16:54:04
Message-ID: E1eMzQy-0006mi-3p () code ! kde ! org
[Download RAW message or body]

Git commit 147d8510d51a7abe713ccd76d236520407d32e4c by Albert Vaca, on behalf of \
Matthijs Tijink. Committed on 07/12/2017 at 16:54.
Pushed by albertvaka into branch 'master'.

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

M  +10   -8    src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisPlugin.java

https://commits.kde.org/kdeconnect-android/147d8510d51a7abe713ccd76d236520407d32e4c

diff --git a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisPlugin.java \
b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisPlugin.java index 23403a8..9faa051 \
                100644
--- a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisPlugin.java
+++ b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisPlugin.java
@@ -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() {


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic