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 com.example.android.mediabrowserservice.model; 18 19 import android.media.MediaMetadata; 20 import android.text.TextUtils; 21 22 /** 23 * Holder class that encapsulates a MediaMetadata and allows the actual metadata to be modified 24 * without requiring to rebuild the collections the metadata is in. 25 */ 26 public class MutableMediaMetadata { 27 28 public MediaMetadata metadata; 29 public final String trackId; 30 MutableMediaMetadata(String trackId, MediaMetadata metadata)31 public MutableMediaMetadata(String trackId, MediaMetadata metadata) { 32 this.metadata = metadata; 33 this.trackId = trackId; 34 } 35 36 @Override equals(Object o)37 public boolean equals(Object o) { 38 if (this == o) { 39 return true; 40 } 41 if (o == null || o.getClass() != MutableMediaMetadata.class) { 42 return false; 43 } 44 45 MutableMediaMetadata that = (MutableMediaMetadata) o; 46 47 return TextUtils.equals(trackId, that.trackId); 48 } 49 50 @Override hashCode()51 public int hashCode() { 52 return trackId.hashCode(); 53 } 54 } 55