• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.android.car.media.widgets;
2 
3 import android.annotation.Nullable;
4 import android.content.Context;
5 import android.util.AttributeSet;
6 import android.view.LayoutInflater;
7 import android.widget.RelativeLayout;
8 import android.widget.SeekBar;
9 import android.widget.TextView;
10 
11 import com.android.car.media.MetadataController;
12 import com.android.car.media.R;
13 import com.android.car.media.common.PlaybackModel;
14 
15 /**
16  * A view that can be used to display the metadata and playback progress of a media item.
17  * This view can be styled using the "MetadataView" styleable attributes.
18  */
19 public class MetadataView extends RelativeLayout {
20     private final MetadataController mMetadataController;
21 
MetadataView(Context context)22     public MetadataView(Context context) {
23         this(context, null);
24     }
25 
MetadataView(Context context, AttributeSet attrs)26     public MetadataView(Context context, AttributeSet attrs) {
27         this(context, attrs, 0);
28     }
29 
MetadataView(Context context, AttributeSet attrs, int defStyleAttr)30     public MetadataView(Context context, AttributeSet attrs, int defStyleAttr) {
31         this(context, attrs, defStyleAttr, 0);
32     }
33 
MetadataView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)34     public MetadataView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
35         super(context, attrs, defStyleAttr, defStyleRes);
36         LayoutInflater.from(context).inflate(R.layout.metadata_compact, this, true);
37         TextView title = findViewById(R.id.title);
38         TextView subtitle = findViewById(R.id.subtitle);
39         SeekBar seekBar = findViewById(R.id.seek_bar);
40         mMetadataController = new MetadataController(title, subtitle, null, seekBar, null);
41     }
42 
43     /**
44      * Registers the {@link PlaybackModel} this widget will use to follow playback state.
45      * Consumers of this class must unregister the {@link PlaybackModel} by calling this method with
46      * null.
47      *
48      * @param model {@link PlaybackModel} to subscribe, or null to unsubscribe.
49      */
setModel(@ullable PlaybackModel model)50     public void setModel(@Nullable PlaybackModel model) {
51         mMetadataController.setModel(model);
52     }
53 
54 }
55