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 17 package android.support.v4.media; 18 19 import android.graphics.Bitmap; 20 import android.media.MediaMetadata; 21 import android.media.Rating; 22 import android.os.Parcel; 23 24 import androidx.annotation.RequiresApi; 25 26 import java.util.Set; 27 28 @RequiresApi(21) 29 class MediaMetadataCompatApi21 { 30 public static Set<String> keySet(Object metadataObj) { 31 return ((MediaMetadata)metadataObj).keySet(); 32 } 33 34 public static Bitmap getBitmap(Object metadataObj, String key) { 35 return ((MediaMetadata)metadataObj).getBitmap(key); 36 } 37 38 public static long getLong(Object metadataObj, String key) { 39 return ((MediaMetadata)metadataObj).getLong(key); 40 } 41 42 public static Object getRating(Object metadataObj, String key) { 43 return ((MediaMetadata)metadataObj).getRating(key); 44 } 45 46 public static CharSequence getText(Object metadataObj, String key) { 47 return ((MediaMetadata) metadataObj).getText(key); 48 } 49 50 public static void writeToParcel(Object metadataObj, Parcel dest, int flags) { 51 ((MediaMetadata) metadataObj).writeToParcel(dest, flags); 52 } 53 54 public static Object createFromParcel(Parcel in) { 55 return MediaMetadata.CREATOR.createFromParcel(in); 56 } 57 58 public static class Builder { 59 public static Object newInstance() { 60 return new MediaMetadata.Builder(); 61 } 62 63 public static void putBitmap(Object builderObj, String key, Bitmap value) { 64 ((MediaMetadata.Builder)builderObj).putBitmap(key, value); 65 } 66 67 public static void putLong(Object builderObj, String key, long value) { 68 ((MediaMetadata.Builder)builderObj).putLong(key, value); 69 } 70 71 public static void putRating(Object builderObj, String key, Object ratingObj) { 72 ((MediaMetadata.Builder)builderObj).putRating(key, (Rating)ratingObj); 73 } 74 75 public static void putText(Object builderObj, String key, CharSequence value) { 76 ((MediaMetadata.Builder) builderObj).putText(key, value); 77 } 78 79 public static void putString(Object builderObj, String key, String value) { 80 ((MediaMetadata.Builder) builderObj).putString(key, value); 81 } 82 83 public static Object build(Object builderObj) { 84 return ((MediaMetadata.Builder)builderObj).build(); 85 } 86 87 private Builder() { 88 } 89 } 90 91 private MediaMetadataCompatApi21() { 92 } 93 } 94