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

Commit d63291e6 authored by Jakub Tyszkowski's avatar Jakub Tyszkowski Committed by Automerger Merge Worker
Browse files

LeAudioTestApp: Basic broadcast metadata handling am: 2927997f am: 79a26eed

parents 250d5264 79a26eed
Loading
Loading
Loading
Loading
+18 −12
Original line number Diff line number Diff line
@@ -55,10 +55,13 @@ public class BroadcastItemsAdapter

    @Override
    public void onBindViewHolder(@NonNull BroadcastItemHolder holder, int position) {
        Integer broadcastId = (Integer) mBroadcastPlaybackMap.keySet().toArray()[position];
        Boolean isPlaying = mBroadcastPlaybackMap.get(broadcastId);
        BluetoothLeBroadcastMetadata meta = mBroadcastMetadataList.get(position);
        Integer broadcastId = meta.getBroadcastId();
        Boolean isPlaybackStateKnown = mBroadcastPlaybackMap.containsKey(broadcastId);

        if (isPlaybackStateKnown) {
            // Set card color based on the playback state
            Boolean isPlaying = mBroadcastPlaybackMap.getOrDefault(broadcastId, false);
            if (isPlaying) {
                holder.background
                .setCardBackgroundColor(ColorStateList.valueOf(Color.parseColor("#92b141")));
@@ -67,14 +70,17 @@ public class BroadcastItemsAdapter
                holder.background.setCardBackgroundColor(ColorStateList.valueOf(Color.WHITE));
                holder.mTextViewBroadcastId.setText("ID: " + broadcastId + " ⏸");
            }
        } else {
            holder.background.setCardBackgroundColor(ColorStateList.valueOf(Color.WHITE));
            holder.mTextViewBroadcastId.setText("ID: " + broadcastId);
        }

        // TODO: Add additional informations to the card
        // BluetoothLeBroadcastMetadata current_item = mBroadcastMetadata.get(position);
    }

    @Override
    public int getItemCount() {
        return mBroadcastPlaybackMap.size();
        return mBroadcastMetadataList.size();
    }

    public void updateBroadcastsMetadata(List<BluetoothLeBroadcastMetadata> broadcasts) {
@@ -137,7 +143,7 @@ public class BroadcastItemsAdapter

                int position = getAdapterPosition();
                if (position != RecyclerView.NO_POSITION) {
                    Integer broadcastId = (Integer) mBroadcastPlaybackMap.keySet().toArray()[position];
                    Integer broadcastId = mBroadcastMetadataList.get(position).getBroadcastId();
                    listener.onItemClick(broadcastId);
                }
            });