Add genre to MediaMetadata.
PiperOrigin-RevId: 380000589
This commit is contained in:
parent
d1aacc5f3b
commit
259f0f67a3
@ -67,6 +67,7 @@ public final class MediaMetadata implements Bundleable {
|
|||||||
@Nullable private CharSequence conductor;
|
@Nullable private CharSequence conductor;
|
||||||
@Nullable private Integer discNumber;
|
@Nullable private Integer discNumber;
|
||||||
@Nullable private Integer totalDiscCount;
|
@Nullable private Integer totalDiscCount;
|
||||||
|
@Nullable private CharSequence genre;
|
||||||
@Nullable private Bundle extras;
|
@Nullable private Bundle extras;
|
||||||
|
|
||||||
public Builder() {}
|
public Builder() {}
|
||||||
@ -99,6 +100,7 @@ public final class MediaMetadata implements Bundleable {
|
|||||||
this.conductor = mediaMetadata.conductor;
|
this.conductor = mediaMetadata.conductor;
|
||||||
this.discNumber = mediaMetadata.discNumber;
|
this.discNumber = mediaMetadata.discNumber;
|
||||||
this.totalDiscCount = mediaMetadata.totalDiscCount;
|
this.totalDiscCount = mediaMetadata.totalDiscCount;
|
||||||
|
this.genre = mediaMetadata.genre;
|
||||||
this.extras = mediaMetadata.extras;
|
this.extras = mediaMetadata.extras;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,6 +305,12 @@ public final class MediaMetadata implements Bundleable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Sets the genre. */
|
||||||
|
public Builder setGenre(@Nullable CharSequence genre) {
|
||||||
|
this.genre = genre;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/** Sets the extras {@link Bundle}. */
|
/** Sets the extras {@link Bundle}. */
|
||||||
public Builder setExtras(@Nullable Bundle extras) {
|
public Builder setExtras(@Nullable Bundle extras) {
|
||||||
this.extras = extras;
|
this.extras = extras;
|
||||||
@ -471,6 +479,8 @@ public final class MediaMetadata implements Bundleable {
|
|||||||
@Nullable public final Integer discNumber;
|
@Nullable public final Integer discNumber;
|
||||||
/** Optional total number of discs. */
|
/** Optional total number of discs. */
|
||||||
@Nullable public final Integer totalDiscCount;
|
@Nullable public final Integer totalDiscCount;
|
||||||
|
/** Optional genre. */
|
||||||
|
@Nullable public final CharSequence genre;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional extras {@link Bundle}.
|
* Optional extras {@link Bundle}.
|
||||||
@ -509,6 +519,7 @@ public final class MediaMetadata implements Bundleable {
|
|||||||
this.conductor = builder.conductor;
|
this.conductor = builder.conductor;
|
||||||
this.discNumber = builder.discNumber;
|
this.discNumber = builder.discNumber;
|
||||||
this.totalDiscCount = builder.totalDiscCount;
|
this.totalDiscCount = builder.totalDiscCount;
|
||||||
|
this.genre = builder.genre;
|
||||||
this.extras = builder.extras;
|
this.extras = builder.extras;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -552,7 +563,8 @@ public final class MediaMetadata implements Bundleable {
|
|||||||
&& Util.areEqual(composer, that.composer)
|
&& Util.areEqual(composer, that.composer)
|
||||||
&& Util.areEqual(conductor, that.conductor)
|
&& Util.areEqual(conductor, that.conductor)
|
||||||
&& Util.areEqual(discNumber, that.discNumber)
|
&& Util.areEqual(discNumber, that.discNumber)
|
||||||
&& Util.areEqual(totalDiscCount, that.totalDiscCount);
|
&& Util.areEqual(totalDiscCount, that.totalDiscCount)
|
||||||
|
&& Util.areEqual(genre, that.genre);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -584,7 +596,8 @@ public final class MediaMetadata implements Bundleable {
|
|||||||
composer,
|
composer,
|
||||||
conductor,
|
conductor,
|
||||||
discNumber,
|
discNumber,
|
||||||
totalDiscCount);
|
totalDiscCount,
|
||||||
|
genre);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bundleable implementation.
|
// Bundleable implementation.
|
||||||
@ -619,6 +632,7 @@ public final class MediaMetadata implements Bundleable {
|
|||||||
FIELD_CONDUCTOR,
|
FIELD_CONDUCTOR,
|
||||||
FIELD_DISC_NUMBER,
|
FIELD_DISC_NUMBER,
|
||||||
FIELD_TOTAL_DISC_COUNT,
|
FIELD_TOTAL_DISC_COUNT,
|
||||||
|
FIELD_GENRE,
|
||||||
FIELD_EXTRAS
|
FIELD_EXTRAS
|
||||||
})
|
})
|
||||||
private @interface FieldNumber {}
|
private @interface FieldNumber {}
|
||||||
@ -650,6 +664,7 @@ public final class MediaMetadata implements Bundleable {
|
|||||||
private static final int FIELD_CONDUCTOR = 24;
|
private static final int FIELD_CONDUCTOR = 24;
|
||||||
private static final int FIELD_DISC_NUMBER = 25;
|
private static final int FIELD_DISC_NUMBER = 25;
|
||||||
private static final int FIELD_TOTAL_DISC_COUNT = 26;
|
private static final int FIELD_TOTAL_DISC_COUNT = 26;
|
||||||
|
private static final int FIELD_GENRE = 27;
|
||||||
private static final int FIELD_EXTRAS = 1000;
|
private static final int FIELD_EXTRAS = 1000;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -668,6 +683,7 @@ public final class MediaMetadata implements Bundleable {
|
|||||||
bundle.putCharSequence(keyForField(FIELD_WRITER), writer);
|
bundle.putCharSequence(keyForField(FIELD_WRITER), writer);
|
||||||
bundle.putCharSequence(keyForField(FIELD_COMPOSER), composer);
|
bundle.putCharSequence(keyForField(FIELD_COMPOSER), composer);
|
||||||
bundle.putCharSequence(keyForField(FIELD_CONDUCTOR), conductor);
|
bundle.putCharSequence(keyForField(FIELD_CONDUCTOR), conductor);
|
||||||
|
bundle.putCharSequence(keyForField(FIELD_GENRE), genre);
|
||||||
|
|
||||||
if (userRating != null) {
|
if (userRating != null) {
|
||||||
bundle.putBundle(keyForField(FIELD_USER_RATING), userRating.toBundle());
|
bundle.putBundle(keyForField(FIELD_USER_RATING), userRating.toBundle());
|
||||||
@ -736,6 +752,7 @@ public final class MediaMetadata implements Bundleable {
|
|||||||
.setWriter(bundle.getCharSequence(keyForField(FIELD_WRITER)))
|
.setWriter(bundle.getCharSequence(keyForField(FIELD_WRITER)))
|
||||||
.setComposer(bundle.getCharSequence(keyForField(FIELD_COMPOSER)))
|
.setComposer(bundle.getCharSequence(keyForField(FIELD_COMPOSER)))
|
||||||
.setConductor(bundle.getCharSequence(keyForField(FIELD_CONDUCTOR)))
|
.setConductor(bundle.getCharSequence(keyForField(FIELD_CONDUCTOR)))
|
||||||
|
.setGenre(bundle.getCharSequence(keyForField(FIELD_GENRE)))
|
||||||
.setExtras(bundle.getBundle(keyForField(FIELD_EXTRAS)));
|
.setExtras(bundle.getBundle(keyForField(FIELD_EXTRAS)));
|
||||||
|
|
||||||
if (bundle.containsKey(keyForField(FIELD_USER_RATING))) {
|
if (bundle.containsKey(keyForField(FIELD_USER_RATING))) {
|
||||||
|
@ -65,6 +65,7 @@ public class MediaMetadataTest {
|
|||||||
assertThat(mediaMetadata.writer).isNull();
|
assertThat(mediaMetadata.writer).isNull();
|
||||||
assertThat(mediaMetadata.discNumber).isNull();
|
assertThat(mediaMetadata.discNumber).isNull();
|
||||||
assertThat(mediaMetadata.totalDiscCount).isNull();
|
assertThat(mediaMetadata.totalDiscCount).isNull();
|
||||||
|
assertThat(mediaMetadata.genre).isNull();
|
||||||
assertThat(mediaMetadata.extras).isNull();
|
assertThat(mediaMetadata.extras).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,6 +122,7 @@ public class MediaMetadataTest {
|
|||||||
.setWriter("Writer")
|
.setWriter("Writer")
|
||||||
.setDiscNumber(1)
|
.setDiscNumber(1)
|
||||||
.setTotalDiscCount(3)
|
.setTotalDiscCount(3)
|
||||||
|
.setGenre("Pop")
|
||||||
.setExtras(extras) // Extras is not implemented in MediaMetadata.equals(Object o).
|
.setExtras(extras) // Extras is not implemented in MediaMetadata.equals(Object o).
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user