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