Lines Matching refs:key

46      * The metadata key for the content artwork / album art.
52 * The metadata key for the content's average rating, not the user's rating.
53 * The value associated with this key is a {@link Rating} instance.
59 * The metadata key for the content's user rating.
60 * The value associated with this key is a {@link Rating} instance.
61 * This key can be flagged as "editable" (with {@link #addEditableKey(int)}) to enable
69 * Editable key mask
135 * Flags the given key as being editable.
139 * @param key the type of metadata that can be edited. The supported key is
142 public synchronized void addEditableKey(int key) {
147 // only one editable key at the moment, so we're not wasting memory on an array
148 // of editable keys to check the validity of the key, just hardcode the supported key.
149 if (key == RATING_KEY_BY_USER) {
150 mEditableKeys |= (KEY_EDITABLE_MASK & key);
153 Log.e(TAG, "Metadata key " + key + " cannot be edited");
176 // only one editable key supported here
189 * @param key The identifier of a the metadata field to set. Valid values are
200 * @param value The text for the given key, or {@code null} to signify there is no valid
205 public synchronized MediaMetadataEditor putString(int key, String value)
211 if (METADATA_KEYS_TYPE.get(key, METADATA_TYPE_INVALID) != METADATA_TYPE_STRING) {
212 throw(new IllegalArgumentException("Invalid type 'String' for key "+ key));
214 mEditorMetadata.putString(String.valueOf(key), value);
223 * @param key the identifier of a the metadata field to set. Valid values are
229 * @param value The long value for the given key
234 public synchronized MediaMetadataEditor putLong(int key, long value)
240 if (METADATA_KEYS_TYPE.get(key, METADATA_TYPE_INVALID) != METADATA_TYPE_LONG) {
241 throw(new IllegalArgumentException("Invalid type 'long' for key "+ key));
243 mEditorMetadata.putLong(String.valueOf(key), value);
250 * @param key the identifier of the bitmap to set. The only valid value is
258 public synchronized MediaMetadataEditor putBitmap(int key, Bitmap bitmap)
264 if (key != BITMAP_KEY_ARTWORK) {
265 throw(new IllegalArgumentException("Invalid type 'Bitmap' for key "+ key));
276 * @param key the identifier of a the metadata field to set. Valid keys for a:
289 public synchronized MediaMetadataEditor putObject(int key, Object value)
295 switch(METADATA_KEYS_TYPE.get(key, METADATA_TYPE_INVALID)) {
298 return putLong(key, ((Long)value).longValue());
300 throw(new IllegalArgumentException("Not a non-null Long for key "+ key));
304 return putString(key, (String) value);
306 throw(new IllegalArgumentException("Not a String for key "+ key));
309 mEditorMetadata.putParcelable(String.valueOf(key), (Parcelable)value);
314 return putBitmap(key, (Bitmap) value);
316 throw(new IllegalArgumentException("Not a Bitmap for key "+ key));
319 throw(new IllegalArgumentException("Invalid key "+ key));
326 * Returns the long value for the key.
327 * @param key one of the keys supported in {@link #putLong(int, long)}
328 * @param defaultValue the value returned if the key is not present
329 * @return the long value for the key, or the supplied default value if the key is not present
332 public synchronized long getLong(int key, long defaultValue)
334 if (METADATA_KEYS_TYPE.get(key, METADATA_TYPE_INVALID) != METADATA_TYPE_LONG) {
335 throw(new IllegalArgumentException("Invalid type 'long' for key "+ key));
337 return mEditorMetadata.getLong(String.valueOf(key), defaultValue);
341 * Returns the {@link String} value for the key.
342 * @param key one of the keys supported in {@link #putString(int, String)}
343 * @param defaultValue the value returned if the key is not present
344 * @return the {@link String} value for the key, or the supplied default value if the key is
348 public synchronized String getString(int key, String defaultValue)
350 if (METADATA_KEYS_TYPE.get(key, METADATA_TYPE_INVALID) != METADATA_TYPE_STRING) {
351 throw(new IllegalArgumentException("Invalid type 'String' for key "+ key));
353 return mEditorMetadata.getString(String.valueOf(key), defaultValue);
357 * Returns the {@link Bitmap} value for the key.
358 * @param key the {@link #BITMAP_KEY_ARTWORK} key
359 * @param defaultValue the value returned if the key is not present
360 * @return the {@link Bitmap} value for the key, or the supplied default value if the key is
364 public synchronized Bitmap getBitmap(int key, Bitmap defaultValue)
366 if (key != BITMAP_KEY_ARTWORK) {
367 throw(new IllegalArgumentException("Invalid type 'Bitmap' for key "+ key));
373 * Returns an object representation of the value for the key
374 * @param key one of the keys supported in {@link #putObject(int, Object)}
375 * @param defaultValue the value returned if the key is not present
376 * @return the object for the key, as a {@link Long}, {@link Bitmap}, {@link String}, or
377 * {@link Rating} depending on the key value, or the supplied default value if the key is
381 public synchronized Object getObject(int key, Object defaultValue)
383 switch (METADATA_KEYS_TYPE.get(key, METADATA_TYPE_INVALID)) {
385 if (mEditorMetadata.containsKey(String.valueOf(key))) {
386 return mEditorMetadata.getLong(String.valueOf(key));
391 if (mEditorMetadata.containsKey(String.valueOf(key))) {
392 return mEditorMetadata.getString(String.valueOf(key));
397 if (mEditorMetadata.containsKey(String.valueOf(key))) {
398 return mEditorMetadata.getParcelable(String.valueOf(key));
403 // only one key for Bitmap supported, value is not stored in mEditorMetadata Bundle
404 if (key == BITMAP_KEY_ARTWORK) {
406 } // else: fall through to invalid key handling
408 throw(new IllegalArgumentException("Invalid key "+ key));