1 /* 2 * Copyright 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.car.media.widgets; 18 19 import android.annotation.NonNull; 20 import android.content.Context; 21 import android.widget.ImageView; 22 23 import com.android.car.apps.common.widget.CarTabLayout; 24 import com.android.car.media.common.MediaItemMetadata; 25 26 /** 27 * An entity representing a media item to be included in the tab bar at the top of the UI. 28 */ 29 public class MediaItemTab extends CarTabLayout.CarTab { 30 private final MediaItemMetadata mItem; 31 32 /** 33 * Creates a new tab for the given media item. 34 */ MediaItemTab(@onNull Context context, @NonNull MediaItemMetadata item)35 public MediaItemTab(@NonNull Context context, @NonNull MediaItemMetadata item) { 36 super(null, item.getTitle()); 37 mItem = item; 38 } 39 40 @Override bindIcon(ImageView imageView)41 protected void bindIcon(ImageView imageView) { 42 MediaItemMetadata.updateImageView(imageView.getContext(), mItem, imageView, 0, false); 43 } 44 45 /** 46 * Returns the item represented by this view 47 */ 48 @NonNull getItem()49 public MediaItemMetadata getItem() { 50 return mItem; 51 } 52 } 53