Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1ceee266 authored by Sal Savage's avatar Sal Savage Committed by Automerger Merge Worker
Browse files

Merge "Notify on parents of nodes that have newly downloaded art" into rvc-dev am: f65085e0

Change-Id: Ia4a0db85347c58d5f9cac5a9bc0f4c4751914a1a
parents 22840aca f65085e0
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.util.Log;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.UUID;

@@ -197,6 +198,13 @@ public class BrowseTree {
                }
                mChildren.add(node);
                mBrowseMap.put(node.getID(), node);

                // Each time we add a node to the tree, check for an image handle so we can add
                // the artwork URI once it has been downloaded
                String imageHandle = node.getCoverArtHandle();
                if (imageHandle != null) {
                    indicateCoverArtUsed(node.getID(), imageHandle);
                }
                return true;
            }
            return false;
@@ -447,6 +455,7 @@ public class BrowseTree {
    synchronized void notifyImageDownload(String handle, Uri uri) {
        if (DBG) Log.d(TAG, "Received downloaded image handle to cascade to BrowseNodes using it");
        ArrayList<String> nodes = getNodesUsingCoverArt(handle);
        HashSet<BrowseNode> parents = new HashSet<BrowseNode>();
        for (String nodeId : nodes) {
            BrowseNode node = findBrowseNodeByID(nodeId);
            if (node == null) {
@@ -455,7 +464,14 @@ public class BrowseTree {
                continue;
            }
            node.setCoverArtUri(uri);
            indicateCoverArtUsed(nodeId, handle);
            if (node.mParent != null) {
                parents.add(node.mParent);
            }
        }

        // Update *parents* of changed nodes so applications will re-grab this node, now with art
        for (BrowseNode node : parents) {
            if (DBG) Log.d(TAG, "Notify node '" + node.getID() + "' that child has cover art now");
            BluetoothMediaBrowserService.notifyChanged(node);
        }
    }
@@ -468,7 +484,7 @@ public class BrowseTree {
            serialized += mRootNode.toString();
            serialized += "\n  Image handles in use (" + mCoverArtMap.size() + "):";
            for (String handle : mCoverArtMap.keySet()) {
                serialized += "    " + handle + "\n";
                serialized += "\n    " + handle + "\n";
            }
        }
        return serialized;