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