Rename BundleableUtils to BundleableUtil for consistency

All utility classes in the common module has the same naming convention.

PiperOrigin-RevId: 399831748
This commit is contained in:
gyumin 2021-09-30 03:31:13 +01:00 committed by Christos Tsilopoulos
parent 00412967c7
commit b105412a41
9 changed files with 28 additions and 29 deletions

View File

@ -20,7 +20,7 @@ import androidx.annotation.IntDef;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.google.android.exoplayer2.drm.DrmInitData; import com.google.android.exoplayer2.drm.DrmInitData;
import com.google.android.exoplayer2.metadata.Metadata; import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.util.BundleableUtils; import com.google.android.exoplayer2.util.BundleableUtil;
import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.ColorInfo; import com.google.android.exoplayer2.video.ColorInfo;
@ -1429,7 +1429,7 @@ public final class Format implements Bundleable {
bundle.putFloat(keyForField(FIELD_PIXEL_WIDTH_HEIGHT_RATIO), pixelWidthHeightRatio); bundle.putFloat(keyForField(FIELD_PIXEL_WIDTH_HEIGHT_RATIO), pixelWidthHeightRatio);
bundle.putByteArray(keyForField(FIELD_PROJECTION_DATA), projectionData); bundle.putByteArray(keyForField(FIELD_PROJECTION_DATA), projectionData);
bundle.putInt(keyForField(FIELD_STEREO_MODE), stereoMode); bundle.putInt(keyForField(FIELD_STEREO_MODE), stereoMode);
bundle.putBundle(keyForField(FIELD_COLOR_INFO), BundleableUtils.toNullableBundle(colorInfo)); bundle.putBundle(keyForField(FIELD_COLOR_INFO), BundleableUtil.toNullableBundle(colorInfo));
// Audio specific. // Audio specific.
bundle.putInt(keyForField(FIELD_CHANNEL_COUNT), channelCount); bundle.putInt(keyForField(FIELD_CHANNEL_COUNT), channelCount);
bundle.putInt(keyForField(FIELD_SAMPLE_RATE), sampleRate); bundle.putInt(keyForField(FIELD_SAMPLE_RATE), sampleRate);
@ -1448,7 +1448,7 @@ public final class Format implements Bundleable {
private static Format fromBundle(Bundle bundle) { private static Format fromBundle(Bundle bundle) {
Builder builder = new Builder(); Builder builder = new Builder();
BundleableUtils.ensureClassLoader(bundle); BundleableUtil.ensureClassLoader(bundle);
builder builder
.setId(defaultIfNull(bundle.getString(keyForField(FIELD_ID)), DEFAULT.id)) .setId(defaultIfNull(bundle.getString(keyForField(FIELD_ID)), DEFAULT.id))
.setLabel(defaultIfNull(bundle.getString(keyForField(FIELD_LABEL)), DEFAULT.label)) .setLabel(defaultIfNull(bundle.getString(keyForField(FIELD_LABEL)), DEFAULT.label))
@ -1498,7 +1498,7 @@ public final class Format implements Bundleable {
.setProjectionData(bundle.getByteArray(keyForField(FIELD_PROJECTION_DATA))) .setProjectionData(bundle.getByteArray(keyForField(FIELD_PROJECTION_DATA)))
.setStereoMode(bundle.getInt(keyForField(FIELD_STEREO_MODE), DEFAULT.stereoMode)) .setStereoMode(bundle.getInt(keyForField(FIELD_STEREO_MODE), DEFAULT.stereoMode))
.setColorInfo( .setColorInfo(
BundleableUtils.fromNullableBundle( BundleableUtil.fromNullableBundle(
ColorInfo.CREATOR, bundle.getBundle(keyForField(FIELD_COLOR_INFO)))) ColorInfo.CREATOR, bundle.getBundle(keyForField(FIELD_COLOR_INFO))))
// Audio specific. // Audio specific.
.setChannelCount(bundle.getInt(keyForField(FIELD_CHANNEL_COUNT), DEFAULT.channelCount)) .setChannelCount(bundle.getInt(keyForField(FIELD_CHANNEL_COUNT), DEFAULT.channelCount))

View File

@ -32,7 +32,7 @@ import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.trackselection.TrackSelection; import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.trackselection.TrackSelectionArray; import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters; import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
import com.google.android.exoplayer2.util.BundleableUtils; import com.google.android.exoplayer2.util.BundleableUtil;
import com.google.android.exoplayer2.util.FlagSet; import com.google.android.exoplayer2.util.FlagSet;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoSize; import com.google.android.exoplayer2.video.VideoSize;
@ -607,7 +607,7 @@ public interface Player {
public Bundle toBundle() { public Bundle toBundle() {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putInt(keyForField(FIELD_WINDOW_INDEX), windowIndex); bundle.putInt(keyForField(FIELD_WINDOW_INDEX), windowIndex);
bundle.putBundle(keyForField(FIELD_MEDIA_ITEM), BundleableUtils.toNullableBundle(mediaItem)); bundle.putBundle(keyForField(FIELD_MEDIA_ITEM), BundleableUtil.toNullableBundle(mediaItem));
bundle.putInt(keyForField(FIELD_PERIOD_INDEX), periodIndex); bundle.putInt(keyForField(FIELD_PERIOD_INDEX), periodIndex);
bundle.putLong(keyForField(FIELD_POSITION_MS), positionMs); bundle.putLong(keyForField(FIELD_POSITION_MS), positionMs);
bundle.putLong(keyForField(FIELD_CONTENT_POSITION_MS), contentPositionMs); bundle.putLong(keyForField(FIELD_CONTENT_POSITION_MS), contentPositionMs);
@ -624,7 +624,7 @@ public interface Player {
bundle.getInt(keyForField(FIELD_WINDOW_INDEX), /* defaultValue= */ C.INDEX_UNSET); bundle.getInt(keyForField(FIELD_WINDOW_INDEX), /* defaultValue= */ C.INDEX_UNSET);
@Nullable @Nullable
MediaItem mediaItem = MediaItem mediaItem =
BundleableUtils.fromNullableBundle( BundleableUtil.fromNullableBundle(
MediaItem.CREATOR, bundle.getBundle(keyForField(FIELD_MEDIA_ITEM))); MediaItem.CREATOR, bundle.getBundle(keyForField(FIELD_MEDIA_ITEM)));
int periodIndex = int periodIndex =
bundle.getInt(keyForField(FIELD_PERIOD_INDEX), /* defaultValue= */ C.INDEX_UNSET); bundle.getInt(keyForField(FIELD_PERIOD_INDEX), /* defaultValue= */ C.INDEX_UNSET);

View File

@ -23,7 +23,7 @@ import androidx.annotation.Nullable;
import com.google.android.exoplayer2.Bundleable; import com.google.android.exoplayer2.Bundleable;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.util.BundleableUtils; import com.google.android.exoplayer2.util.BundleableUtil;
import com.google.android.exoplayer2.util.Log; import com.google.android.exoplayer2.util.Log;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@ -123,7 +123,7 @@ public final class TrackGroup implements Bundleable {
public Bundle toBundle() { public Bundle toBundle() {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putParcelableArrayList( bundle.putParcelableArrayList(
keyForField(FIELD_FORMATS), BundleableUtils.toBundleArrayList(Lists.newArrayList(formats))); keyForField(FIELD_FORMATS), BundleableUtil.toBundleArrayList(Lists.newArrayList(formats)));
return bundle; return bundle;
} }
@ -131,7 +131,7 @@ public final class TrackGroup implements Bundleable {
public static final Creator<TrackGroup> CREATOR = public static final Creator<TrackGroup> CREATOR =
bundle -> { bundle -> {
List<Format> formats = List<Format> formats =
BundleableUtils.fromBundleNullableList( BundleableUtil.fromBundleNullableList(
Format.CREATOR, Format.CREATOR,
bundle.getParcelableArrayList(keyForField(FIELD_FORMATS)), bundle.getParcelableArrayList(keyForField(FIELD_FORMATS)),
ImmutableList.of()); ImmutableList.of());

View File

@ -20,7 +20,7 @@ import androidx.annotation.IntDef;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.google.android.exoplayer2.Bundleable; import com.google.android.exoplayer2.Bundleable;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.util.BundleableUtils; import com.google.android.exoplayer2.util.BundleableUtil;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
@ -118,7 +118,7 @@ public final class TrackGroupArray implements Bundleable {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putParcelableArrayList( bundle.putParcelableArrayList(
keyForField(FIELD_TRACK_GROUPS), keyForField(FIELD_TRACK_GROUPS),
BundleableUtils.toBundleArrayList(Lists.newArrayList(trackGroups))); BundleableUtil.toBundleArrayList(Lists.newArrayList(trackGroups)));
return bundle; return bundle;
} }
@ -126,7 +126,7 @@ public final class TrackGroupArray implements Bundleable {
public static final Creator<TrackGroupArray> CREATOR = public static final Creator<TrackGroupArray> CREATOR =
bundle -> { bundle -> {
List<TrackGroup> trackGroups = List<TrackGroup> trackGroups =
BundleableUtils.fromBundleNullableList( BundleableUtil.fromBundleNullableList(
TrackGroup.CREATOR, TrackGroup.CREATOR,
bundle.getParcelableArrayList(keyForField(FIELD_TRACK_GROUPS)), bundle.getParcelableArrayList(keyForField(FIELD_TRACK_GROUPS)),
/* defaultValue= */ ImmutableList.of()); /* defaultValue= */ ImmutableList.of());

View File

@ -18,7 +18,7 @@ package com.google.android.exoplayer2.text;
import android.os.Bundle; import android.os.Bundle;
import android.os.Parcel; import android.os.Parcel;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.BundleableUtils; import com.google.android.exoplayer2.util.BundleableUtil;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import java.util.ArrayList; import java.util.ArrayList;
@ -43,6 +43,6 @@ public final class CueDecoder {
ArrayList<Bundle> bundledCues = ArrayList<Bundle> bundledCues =
Assertions.checkNotNull(bundle.getParcelableArrayList(BUNDLED_CUES)); Assertions.checkNotNull(bundle.getParcelableArrayList(BUNDLED_CUES));
return BundleableUtils.fromBundleList(Cue.CREATOR, bundledCues); return BundleableUtil.fromBundleList(Cue.CREATOR, bundledCues);
} }
} }

View File

@ -17,7 +17,7 @@ package com.google.android.exoplayer2.text;
import android.os.Bundle; import android.os.Bundle;
import android.os.Parcel; import android.os.Parcel;
import com.google.android.exoplayer2.util.BundleableUtils; import com.google.android.exoplayer2.util.BundleableUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -31,7 +31,7 @@ public final class CueEncoder {
* @return The serialized byte array. * @return The serialized byte array.
*/ */
public byte[] encode(List<Cue> cues) { public byte[] encode(List<Cue> cues) {
ArrayList<Bundle> bundledCues = BundleableUtils.toBundleArrayList(cues); ArrayList<Bundle> bundledCues = BundleableUtil.toBundleArrayList(cues);
Bundle allCuesBundle = new Bundle(); Bundle allCuesBundle = new Bundle();
allCuesBundle.putParcelableArrayList(CueDecoder.BUNDLED_CUES, bundledCues); allCuesBundle.putParcelableArrayList(CueDecoder.BUNDLED_CUES, bundledCues);
Parcel parcel = Parcel.obtain(); Parcel parcel = Parcel.obtain();

View File

@ -27,7 +27,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
/** Utilities for {@link Bundleable}. */ /** Utilities for {@link Bundleable}. */
public final class BundleableUtils { public final class BundleableUtil {
/** /**
* Converts a {@link Bundleable} to a {@link Bundle}. It's a convenience wrapper of {@link * Converts a {@link Bundleable} to a {@link Bundle}. It's a convenience wrapper of {@link
@ -142,9 +142,9 @@ public final class BundleableUtils {
*/ */
public static void ensureClassLoader(@Nullable Bundle bundle) { public static void ensureClassLoader(@Nullable Bundle bundle) {
if (bundle != null) { if (bundle != null) {
bundle.setClassLoader(castNonNull(BundleableUtils.class.getClassLoader())); bundle.setClassLoader(castNonNull(BundleableUtil.class.getClassLoader()));
} }
} }
private BundleableUtils() {} private BundleableUtil() {}
} }

View File

@ -25,7 +25,7 @@ import com.google.android.exoplayer2.C.FormatSupport;
import com.google.android.exoplayer2.source.MediaPeriodId; import com.google.android.exoplayer2.source.MediaPeriodId;
import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.BundleableUtils; import com.google.android.exoplayer2.util.BundleableUtil;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import java.io.IOException; import java.io.IOException;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
@ -236,7 +236,7 @@ public final class ExoPlaybackException extends PlaybackException {
rendererIndex = rendererIndex =
bundle.getInt(keyForField(FIELD_RENDERER_INDEX), /* defaultValue= */ C.INDEX_UNSET); bundle.getInt(keyForField(FIELD_RENDERER_INDEX), /* defaultValue= */ C.INDEX_UNSET);
rendererFormat = rendererFormat =
BundleableUtils.fromNullableBundle( BundleableUtil.fromNullableBundle(
Format.CREATOR, bundle.getBundle(keyForField(FIELD_RENDERER_FORMAT))); Format.CREATOR, bundle.getBundle(keyForField(FIELD_RENDERER_FORMAT)));
rendererFormatSupport = rendererFormatSupport =
bundle.getInt( bundle.getInt(
@ -400,7 +400,7 @@ public final class ExoPlaybackException extends PlaybackException {
bundle.putString(keyForField(FIELD_RENDERER_NAME), rendererName); bundle.putString(keyForField(FIELD_RENDERER_NAME), rendererName);
bundle.putInt(keyForField(FIELD_RENDERER_INDEX), rendererIndex); bundle.putInt(keyForField(FIELD_RENDERER_INDEX), rendererIndex);
bundle.putBundle( bundle.putBundle(
keyForField(FIELD_RENDERER_FORMAT), BundleableUtils.toNullableBundle(rendererFormat)); keyForField(FIELD_RENDERER_FORMAT), BundleableUtil.toNullableBundle(rendererFormat));
bundle.putInt(keyForField(FIELD_RENDERER_FORMAT_SUPPORT), rendererFormatSupport); bundle.putInt(keyForField(FIELD_RENDERER_FORMAT_SUPPORT), rendererFormatSupport);
bundle.putBoolean(keyForField(FIELD_IS_RECOVERABLE), isRecoverable); bundle.putBoolean(keyForField(FIELD_IS_RECOVERABLE), isRecoverable);
return bundle; return bundle;

View File

@ -40,7 +40,7 @@ import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
import com.google.android.exoplayer2.source.TrackGroup; import com.google.android.exoplayer2.source.TrackGroup;
import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.BundleableUtils; import com.google.android.exoplayer2.util.BundleableUtil;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import com.google.common.collect.ComparisonChain; import com.google.common.collect.ComparisonChain;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -813,13 +813,13 @@ public class DefaultTrackSelector extends MappingTrackSelector {
bundle.getIntArray( bundle.getIntArray(
Parameters.keyForField(Parameters.FIELD_SELECTION_OVERRIDES_RENDERER_INDEXES)); Parameters.keyForField(Parameters.FIELD_SELECTION_OVERRIDES_RENDERER_INDEXES));
List<TrackGroupArray> trackGroupArrays = List<TrackGroupArray> trackGroupArrays =
BundleableUtils.fromBundleNullableList( BundleableUtil.fromBundleNullableList(
TrackGroupArray.CREATOR, TrackGroupArray.CREATOR,
bundle.getParcelableArrayList( bundle.getParcelableArrayList(
Parameters.keyForField(Parameters.FIELD_SELECTION_OVERRIDES_TRACK_GROUP_ARRAYS)), Parameters.keyForField(Parameters.FIELD_SELECTION_OVERRIDES_TRACK_GROUP_ARRAYS)),
/* defaultValue= */ ImmutableList.of()); /* defaultValue= */ ImmutableList.of());
SparseArray<SelectionOverride> selectionOverrides = SparseArray<SelectionOverride> selectionOverrides =
BundleableUtils.fromBundleNullableSparseArray( BundleableUtil.fromBundleNullableSparseArray(
SelectionOverride.CREATOR, SelectionOverride.CREATOR,
bundle.getSparseParcelableArray( bundle.getSparseParcelableArray(
Parameters.keyForField(Parameters.FIELD_SELECTION_OVERRIDES)), Parameters.keyForField(Parameters.FIELD_SELECTION_OVERRIDES)),
@ -1197,10 +1197,9 @@ public class DefaultTrackSelector extends MappingTrackSelector {
keyForField(FIELD_SELECTION_OVERRIDES_RENDERER_INDEXES), Ints.toArray(rendererIndexes)); keyForField(FIELD_SELECTION_OVERRIDES_RENDERER_INDEXES), Ints.toArray(rendererIndexes));
bundle.putParcelableArrayList( bundle.putParcelableArrayList(
keyForField(FIELD_SELECTION_OVERRIDES_TRACK_GROUP_ARRAYS), keyForField(FIELD_SELECTION_OVERRIDES_TRACK_GROUP_ARRAYS),
BundleableUtils.toBundleArrayList(trackGroupArrays)); BundleableUtil.toBundleArrayList(trackGroupArrays));
bundle.putSparseParcelableArray( bundle.putSparseParcelableArray(
keyForField(FIELD_SELECTION_OVERRIDES), keyForField(FIELD_SELECTION_OVERRIDES), BundleableUtil.toBundleSparseArray(selections));
BundleableUtils.toBundleSparseArray(selections));
} }
} }