From b105412a410709ba689ea9930d3199d6e4ac1ed8 Mon Sep 17 00:00:00 2001 From: gyumin Date: Thu, 30 Sep 2021 03:31:13 +0100 Subject: [PATCH] Rename BundleableUtils to BundleableUtil for consistency All utility classes in the common module has the same naming convention. PiperOrigin-RevId: 399831748 --- .../java/com/google/android/exoplayer2/Format.java | 8 ++++---- .../java/com/google/android/exoplayer2/Player.java | 6 +++--- .../google/android/exoplayer2/source/TrackGroup.java | 6 +++--- .../android/exoplayer2/source/TrackGroupArray.java | 6 +++--- .../google/android/exoplayer2/text/CueDecoder.java | 4 ++-- .../google/android/exoplayer2/text/CueEncoder.java | 4 ++-- .../{BundleableUtils.java => BundleableUtil.java} | 6 +++--- .../android/exoplayer2/ExoPlaybackException.java | 6 +++--- .../trackselection/DefaultTrackSelector.java | 11 +++++------ 9 files changed, 28 insertions(+), 29 deletions(-) rename library/common/src/main/java/com/google/android/exoplayer2/util/{BundleableUtils.java => BundleableUtil.java} (97%) diff --git a/library/common/src/main/java/com/google/android/exoplayer2/Format.java b/library/common/src/main/java/com/google/android/exoplayer2/Format.java index 150505ddcd..909c759c85 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/Format.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/Format.java @@ -20,7 +20,7 @@ import androidx.annotation.IntDef; import androidx.annotation.Nullable; import com.google.android.exoplayer2.drm.DrmInitData; 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.Util; 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.putByteArray(keyForField(FIELD_PROJECTION_DATA), projectionData); 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. bundle.putInt(keyForField(FIELD_CHANNEL_COUNT), channelCount); bundle.putInt(keyForField(FIELD_SAMPLE_RATE), sampleRate); @@ -1448,7 +1448,7 @@ public final class Format implements Bundleable { private static Format fromBundle(Bundle bundle) { Builder builder = new Builder(); - BundleableUtils.ensureClassLoader(bundle); + BundleableUtil.ensureClassLoader(bundle); builder .setId(defaultIfNull(bundle.getString(keyForField(FIELD_ID)), DEFAULT.id)) .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))) .setStereoMode(bundle.getInt(keyForField(FIELD_STEREO_MODE), DEFAULT.stereoMode)) .setColorInfo( - BundleableUtils.fromNullableBundle( + BundleableUtil.fromNullableBundle( ColorInfo.CREATOR, bundle.getBundle(keyForField(FIELD_COLOR_INFO)))) // Audio specific. .setChannelCount(bundle.getInt(keyForField(FIELD_CHANNEL_COUNT), DEFAULT.channelCount)) diff --git a/library/common/src/main/java/com/google/android/exoplayer2/Player.java b/library/common/src/main/java/com/google/android/exoplayer2/Player.java index 45f181d47e..367194350b 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/Player.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/Player.java @@ -32,7 +32,7 @@ import com.google.android.exoplayer2.text.Cue; import com.google.android.exoplayer2.trackselection.TrackSelection; import com.google.android.exoplayer2.trackselection.TrackSelectionArray; 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.Util; import com.google.android.exoplayer2.video.VideoSize; @@ -607,7 +607,7 @@ public interface Player { public Bundle toBundle() { Bundle bundle = new Bundle(); 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.putLong(keyForField(FIELD_POSITION_MS), positionMs); 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); @Nullable MediaItem mediaItem = - BundleableUtils.fromNullableBundle( + BundleableUtil.fromNullableBundle( MediaItem.CREATOR, bundle.getBundle(keyForField(FIELD_MEDIA_ITEM))); int periodIndex = bundle.getInt(keyForField(FIELD_PERIOD_INDEX), /* defaultValue= */ C.INDEX_UNSET); diff --git a/library/common/src/main/java/com/google/android/exoplayer2/source/TrackGroup.java b/library/common/src/main/java/com/google/android/exoplayer2/source/TrackGroup.java index 4f9f93fc33..5e5eae2837 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/source/TrackGroup.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/source/TrackGroup.java @@ -23,7 +23,7 @@ import androidx.annotation.Nullable; import com.google.android.exoplayer2.Bundleable; import com.google.android.exoplayer2.C; 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.common.collect.ImmutableList; import com.google.common.collect.Lists; @@ -123,7 +123,7 @@ public final class TrackGroup implements Bundleable { public Bundle toBundle() { Bundle bundle = new Bundle(); bundle.putParcelableArrayList( - keyForField(FIELD_FORMATS), BundleableUtils.toBundleArrayList(Lists.newArrayList(formats))); + keyForField(FIELD_FORMATS), BundleableUtil.toBundleArrayList(Lists.newArrayList(formats))); return bundle; } @@ -131,7 +131,7 @@ public final class TrackGroup implements Bundleable { public static final Creator CREATOR = bundle -> { List formats = - BundleableUtils.fromBundleNullableList( + BundleableUtil.fromBundleNullableList( Format.CREATOR, bundle.getParcelableArrayList(keyForField(FIELD_FORMATS)), ImmutableList.of()); diff --git a/library/common/src/main/java/com/google/android/exoplayer2/source/TrackGroupArray.java b/library/common/src/main/java/com/google/android/exoplayer2/source/TrackGroupArray.java index 0af14a5fdc..6ddff84e38 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/source/TrackGroupArray.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/source/TrackGroupArray.java @@ -20,7 +20,7 @@ import androidx.annotation.IntDef; import androidx.annotation.Nullable; import com.google.android.exoplayer2.Bundleable; 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.Lists; import java.lang.annotation.Documented; @@ -118,7 +118,7 @@ public final class TrackGroupArray implements Bundleable { Bundle bundle = new Bundle(); bundle.putParcelableArrayList( keyForField(FIELD_TRACK_GROUPS), - BundleableUtils.toBundleArrayList(Lists.newArrayList(trackGroups))); + BundleableUtil.toBundleArrayList(Lists.newArrayList(trackGroups))); return bundle; } @@ -126,7 +126,7 @@ public final class TrackGroupArray implements Bundleable { public static final Creator CREATOR = bundle -> { List trackGroups = - BundleableUtils.fromBundleNullableList( + BundleableUtil.fromBundleNullableList( TrackGroup.CREATOR, bundle.getParcelableArrayList(keyForField(FIELD_TRACK_GROUPS)), /* defaultValue= */ ImmutableList.of()); diff --git a/library/common/src/main/java/com/google/android/exoplayer2/text/CueDecoder.java b/library/common/src/main/java/com/google/android/exoplayer2/text/CueDecoder.java index d986c32f6e..78e7107bb6 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/text/CueDecoder.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/text/CueDecoder.java @@ -18,7 +18,7 @@ package com.google.android.exoplayer2.text; import android.os.Bundle; import android.os.Parcel; 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 java.util.ArrayList; @@ -43,6 +43,6 @@ public final class CueDecoder { ArrayList bundledCues = Assertions.checkNotNull(bundle.getParcelableArrayList(BUNDLED_CUES)); - return BundleableUtils.fromBundleList(Cue.CREATOR, bundledCues); + return BundleableUtil.fromBundleList(Cue.CREATOR, bundledCues); } } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/text/CueEncoder.java b/library/common/src/main/java/com/google/android/exoplayer2/text/CueEncoder.java index 773ec5aecf..4f7d3c4a22 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/text/CueEncoder.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/text/CueEncoder.java @@ -17,7 +17,7 @@ package com.google.android.exoplayer2.text; import android.os.Bundle; 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.List; @@ -31,7 +31,7 @@ public final class CueEncoder { * @return The serialized byte array. */ public byte[] encode(List cues) { - ArrayList bundledCues = BundleableUtils.toBundleArrayList(cues); + ArrayList bundledCues = BundleableUtil.toBundleArrayList(cues); Bundle allCuesBundle = new Bundle(); allCuesBundle.putParcelableArrayList(CueDecoder.BUNDLED_CUES, bundledCues); Parcel parcel = Parcel.obtain(); diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/BundleableUtils.java b/library/common/src/main/java/com/google/android/exoplayer2/util/BundleableUtil.java similarity index 97% rename from library/common/src/main/java/com/google/android/exoplayer2/util/BundleableUtils.java rename to library/common/src/main/java/com/google/android/exoplayer2/util/BundleableUtil.java index 932a3e8f7b..978095354b 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/BundleableUtils.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/BundleableUtil.java @@ -27,7 +27,7 @@ import java.util.ArrayList; import java.util.List; /** 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 @@ -142,9 +142,9 @@ public final class BundleableUtils { */ public static void ensureClassLoader(@Nullable Bundle bundle) { if (bundle != null) { - bundle.setClassLoader(castNonNull(BundleableUtils.class.getClassLoader())); + bundle.setClassLoader(castNonNull(BundleableUtil.class.getClassLoader())); } } - private BundleableUtils() {} + private BundleableUtil() {} } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlaybackException.java b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlaybackException.java index 778999d2cb..f78441bda1 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlaybackException.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlaybackException.java @@ -25,7 +25,7 @@ import com.google.android.exoplayer2.C.FormatSupport; import com.google.android.exoplayer2.source.MediaPeriodId; import com.google.android.exoplayer2.source.MediaSource; 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 java.io.IOException; import java.lang.annotation.Documented; @@ -236,7 +236,7 @@ public final class ExoPlaybackException extends PlaybackException { rendererIndex = bundle.getInt(keyForField(FIELD_RENDERER_INDEX), /* defaultValue= */ C.INDEX_UNSET); rendererFormat = - BundleableUtils.fromNullableBundle( + BundleableUtil.fromNullableBundle( Format.CREATOR, bundle.getBundle(keyForField(FIELD_RENDERER_FORMAT))); rendererFormatSupport = bundle.getInt( @@ -400,7 +400,7 @@ public final class ExoPlaybackException extends PlaybackException { bundle.putString(keyForField(FIELD_RENDERER_NAME), rendererName); bundle.putInt(keyForField(FIELD_RENDERER_INDEX), rendererIndex); 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.putBoolean(keyForField(FIELD_IS_RECOVERABLE), isRecoverable); return bundle; diff --git a/library/core/src/main/java/com/google/android/exoplayer2/trackselection/DefaultTrackSelector.java b/library/core/src/main/java/com/google/android/exoplayer2/trackselection/DefaultTrackSelector.java index 7f3389ffe7..b0112d34ae 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/trackselection/DefaultTrackSelector.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/trackselection/DefaultTrackSelector.java @@ -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.TrackGroupArray; 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.common.collect.ComparisonChain; import com.google.common.collect.ImmutableList; @@ -813,13 +813,13 @@ public class DefaultTrackSelector extends MappingTrackSelector { bundle.getIntArray( Parameters.keyForField(Parameters.FIELD_SELECTION_OVERRIDES_RENDERER_INDEXES)); List trackGroupArrays = - BundleableUtils.fromBundleNullableList( + BundleableUtil.fromBundleNullableList( TrackGroupArray.CREATOR, bundle.getParcelableArrayList( Parameters.keyForField(Parameters.FIELD_SELECTION_OVERRIDES_TRACK_GROUP_ARRAYS)), /* defaultValue= */ ImmutableList.of()); SparseArray selectionOverrides = - BundleableUtils.fromBundleNullableSparseArray( + BundleableUtil.fromBundleNullableSparseArray( SelectionOverride.CREATOR, bundle.getSparseParcelableArray( Parameters.keyForField(Parameters.FIELD_SELECTION_OVERRIDES)), @@ -1197,10 +1197,9 @@ public class DefaultTrackSelector extends MappingTrackSelector { keyForField(FIELD_SELECTION_OVERRIDES_RENDERER_INDEXES), Ints.toArray(rendererIndexes)); bundle.putParcelableArrayList( keyForField(FIELD_SELECTION_OVERRIDES_TRACK_GROUP_ARRAYS), - BundleableUtils.toBundleArrayList(trackGroupArrays)); + BundleableUtil.toBundleArrayList(trackGroupArrays)); bundle.putSparseParcelableArray( - keyForField(FIELD_SELECTION_OVERRIDES), - BundleableUtils.toBundleSparseArray(selections)); + keyForField(FIELD_SELECTION_OVERRIDES), BundleableUtil.toBundleSparseArray(selections)); } }