1 /* 2 * Copyright (C) 2014 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 package android.support.v4.media; 17 18 import android.graphics.Bitmap; 19 import android.media.MediaDescription; 20 import android.net.Uri; 21 import android.os.Bundle; 22 import android.os.Parcel; 23 import android.support.annotation.RequiresApi; 24 25 @RequiresApi(21) 26 class MediaDescriptionCompatApi21 { 27 getMediaId(Object descriptionObj)28 public static String getMediaId(Object descriptionObj) { 29 return ((MediaDescription) descriptionObj).getMediaId(); 30 } 31 getTitle(Object descriptionObj)32 public static CharSequence getTitle(Object descriptionObj) { 33 return ((MediaDescription) descriptionObj).getTitle(); 34 } 35 getSubtitle(Object descriptionObj)36 public static CharSequence getSubtitle(Object descriptionObj) { 37 return ((MediaDescription) descriptionObj).getSubtitle(); 38 } 39 getDescription(Object descriptionObj)40 public static CharSequence getDescription(Object descriptionObj) { 41 return ((MediaDescription) descriptionObj).getDescription(); 42 } 43 getIconBitmap(Object descriptionObj)44 public static Bitmap getIconBitmap(Object descriptionObj) { 45 return ((MediaDescription) descriptionObj).getIconBitmap(); 46 } 47 getIconUri(Object descriptionObj)48 public static Uri getIconUri(Object descriptionObj) { 49 return ((MediaDescription) descriptionObj).getIconUri(); 50 } 51 getExtras(Object descriptionObj)52 public static Bundle getExtras(Object descriptionObj) { 53 return ((MediaDescription) descriptionObj).getExtras(); 54 } 55 writeToParcel(Object descriptionObj, Parcel dest, int flags)56 public static void writeToParcel(Object descriptionObj, Parcel dest, int flags) { 57 ((MediaDescription) descriptionObj).writeToParcel(dest, flags); 58 } 59 fromParcel(Parcel in)60 public static Object fromParcel(Parcel in) { 61 return MediaDescription.CREATOR.createFromParcel(in); 62 } 63 64 static class Builder { newInstance()65 public static Object newInstance() { 66 return new MediaDescription.Builder(); 67 } 68 69 setMediaId(Object builderObj, String mediaId)70 public static void setMediaId(Object builderObj, String mediaId) { 71 ((MediaDescription.Builder)builderObj).setMediaId(mediaId); 72 } 73 setTitle(Object builderObj, CharSequence title)74 public static void setTitle(Object builderObj, CharSequence title) { 75 ((MediaDescription.Builder)builderObj).setTitle(title); 76 } 77 setSubtitle(Object builderObj, CharSequence subtitle)78 public static void setSubtitle(Object builderObj, CharSequence subtitle) { 79 ((MediaDescription.Builder)builderObj).setSubtitle(subtitle); 80 } 81 setDescription(Object builderObj, CharSequence description)82 public static void setDescription(Object builderObj, CharSequence description) { 83 ((MediaDescription.Builder)builderObj).setDescription(description); 84 } 85 setIconBitmap(Object builderObj, Bitmap iconBitmap)86 public static void setIconBitmap(Object builderObj, Bitmap iconBitmap) { 87 ((MediaDescription.Builder)builderObj).setIconBitmap(iconBitmap); 88 } 89 setIconUri(Object builderObj, Uri iconUri)90 public static void setIconUri(Object builderObj, Uri iconUri) { 91 ((MediaDescription.Builder)builderObj).setIconUri(iconUri); 92 } 93 setExtras(Object builderObj, Bundle extras)94 public static void setExtras(Object builderObj, Bundle extras) { 95 ((MediaDescription.Builder)builderObj).setExtras(extras); 96 } 97 build(Object builderObj)98 public static Object build(Object builderObj) { 99 return ((MediaDescription.Builder) builderObj).build(); 100 } 101 } 102 } 103