Lines Matching refs:key

44      * The metadata key for the content artwork / album art.
50 * The metadata key for the content's average rating, not the user's rating.
51 * The value associated with this key is a {@link Rating} instance.
57 * The metadata key for the content's user rating.
58 * The value associated with this key is a {@link Rating} instance.
59 * This key can be flagged as "editable" (with {@link #addEditableKey(int)}) to enable
67 * Editable key mask
127 * Flags the given key as being editable.
131 * @param key the type of metadata that can be edited. The supported key is
134 public synchronized void addEditableKey(int key) {
139 // only one editable key at the moment, so we're not wasting memory on an array
140 // of editable keys to check the validity of the key, just hardcode the supported key.
141 if (key == RATING_KEY_BY_USER) {
142 mEditableKeys |= (KEY_EDITABLE_MASK & key);
145 Log.e(TAG, "Metadata key " + key + " cannot be edited");
168 // only one editable key supported here
181 * @param key The identifier of a the metadata field to set. Valid values are
192 * @param value The text for the given key, or {@code null} to signify there is no valid
197 public synchronized MediaMetadataEditor putString(int key, String value)
203 if (METADATA_KEYS_TYPE.get(key, METADATA_TYPE_INVALID) != METADATA_TYPE_STRING) {
204 throw(new IllegalArgumentException("Invalid type 'String' for key "+ key));
206 mEditorMetadata.putString(String.valueOf(key), value);
215 * @param key the identifier of a the metadata field to set. Valid values are
221 * @param value The long value for the given key
226 public synchronized MediaMetadataEditor putLong(int key, long value)
232 if (METADATA_KEYS_TYPE.get(key, METADATA_TYPE_INVALID) != METADATA_TYPE_LONG) {
233 throw(new IllegalArgumentException("Invalid type 'long' for key "+ key));
235 mEditorMetadata.putLong(String.valueOf(key), value);
242 * @param key the identifier of the bitmap to set. The only valid value is
250 public synchronized MediaMetadataEditor putBitmap(int key, Bitmap bitmap)
256 if (key != BITMAP_KEY_ARTWORK) {
257 throw(new IllegalArgumentException("Invalid type 'Bitmap' for key "+ key));
268 * @param key the identifier of a the metadata field to set. Valid keys for a:
281 public synchronized MediaMetadataEditor putObject(int key, Object value)
287 switch(METADATA_KEYS_TYPE.get(key, METADATA_TYPE_INVALID)) {
290 return putLong(key, ((Long)value).longValue());
292 throw(new IllegalArgumentException("Not a non-null Long for key "+ key));
296 return putString(key, (String) value);
298 throw(new IllegalArgumentException("Not a String for key "+ key));
301 mEditorMetadata.putParcelable(String.valueOf(key), (Parcelable)value);
306 return putBitmap(key, (Bitmap) value);
308 throw(new IllegalArgumentException("Not a Bitmap for key "+ key));
311 throw(new IllegalArgumentException("Invalid key "+ key));
318 * Returns the long value for the key.
319 * @param key one of the keys supported in {@link #putLong(int, long)}
320 * @param defaultValue the value returned if the key is not present
321 * @return the long value for the key, or the supplied default value if the key is not present
324 public synchronized long getLong(int key, long defaultValue)
326 if (METADATA_KEYS_TYPE.get(key, METADATA_TYPE_INVALID) != METADATA_TYPE_LONG) {
327 throw(new IllegalArgumentException("Invalid type 'long' for key "+ key));
329 return mEditorMetadata.getLong(String.valueOf(key), defaultValue);
333 * Returns the {@link String} value for the key.
334 * @param key one of the keys supported in {@link #putString(int, String)}
335 * @param defaultValue the value returned if the key is not present
336 * @return the {@link String} value for the key, or the supplied default value if the key is
340 public synchronized String getString(int key, String defaultValue)
342 if (METADATA_KEYS_TYPE.get(key, METADATA_TYPE_INVALID) != METADATA_TYPE_STRING) {
343 throw(new IllegalArgumentException("Invalid type 'String' for key "+ key));
345 return mEditorMetadata.getString(String.valueOf(key), defaultValue);
349 * Returns the {@link Bitmap} value for the key.
350 * @param key the {@link #BITMAP_KEY_ARTWORK} key
351 * @param defaultValue the value returned if the key is not present
352 * @return the {@link Bitmap} value for the key, or the supplied default value if the key is
356 public synchronized Bitmap getBitmap(int key, Bitmap defaultValue)
358 if (key != BITMAP_KEY_ARTWORK) {
359 throw(new IllegalArgumentException("Invalid type 'Bitmap' for key "+ key));
365 * Returns an object representation of the value for the key
366 * @param key one of the keys supported in {@link #putObject(int, Object)}
367 * @param defaultValue the value returned if the key is not present
368 * @return the object for the key, as a {@link Long}, {@link Bitmap}, {@link String}, or
369 * {@link Rating} depending on the key value, or the supplied default value if the key is
373 public synchronized Object getObject(int key, Object defaultValue)
375 switch (METADATA_KEYS_TYPE.get(key, METADATA_TYPE_INVALID)) {
377 if (mEditorMetadata.containsKey(String.valueOf(key))) {
378 return mEditorMetadata.getLong(String.valueOf(key));
383 if (mEditorMetadata.containsKey(String.valueOf(key))) {
384 return mEditorMetadata.getString(String.valueOf(key));
389 if (mEditorMetadata.containsKey(String.valueOf(key))) {
390 return mEditorMetadata.getParcelable(String.valueOf(key));
395 // only one key for Bitmap supported, value is not stored in mEditorMetadata Bundle
396 if (key == BITMAP_KEY_ARTWORK) {
398 } // else: fall through to invalid key handling
400 throw(new IllegalArgumentException("Invalid key "+ key));