Skip to content

Commit

Permalink
Rename Player.EventFlags -> Player.Event
Browse files Browse the repository at this point in the history
IntDef names (like enums) are normally singular, and this isn't a 'flag'
IntDef.

PiperOrigin-RevId: 383659574
  • Loading branch information
icbaker authored and kim-vde committed Jul 9, 2021
1 parent e828dfb commit 20d67eb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
1 change: 1 addition & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* Explicitly mark several methods on `SimpleExoPlayer` as `@Deprecated`.
These methods are all overrides and are already deprecated on `Player`
and the respective `ExoPlayer` component classes (since 2.14.0).
* Rename `Player.EventFlags` IntDef to `Player.Event`.
* Remove deprecated symbols:
* Remove `Player.getPlaybackError`. Use `Player.getPlayerError` instead.
* Remove `Player.getCurrentTag`. Use `Player.getCurrentMediaItem` and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,37 +392,37 @@ default void onSeekProcessed() {}
default void onEvents(Player player, Events events) {}
}

/** A set of {@link EventFlags}. */
/** A set of {@link Event events}. */
final class Events {

private final FlagSet flags;

/**
* Creates an instance.
*
* @param flags The {@link FlagSet} containing the {@link EventFlags} in the set.
* @param flags The {@link FlagSet} containing the {@link Event events}.
*/
public Events(FlagSet flags) {
this.flags = flags;
}

/**
* Returns whether the given event occurred.
* Returns whether the given {@link Event} occurred.
*
* @param event The {@link EventFlags event}.
* @return Whether the event occurred.
* @param event The {@link Event}.
* @return Whether the {@link Event} occurred.
*/
public boolean contains(@EventFlags int event) {
public boolean contains(@Event int event) {
return flags.contains(event);
}

/**
* Returns whether any of the given events occurred.
* Returns whether any of the given {@link Event events} occurred.
*
* @param events The {@link EventFlags events}.
* @return Whether any of the events occurred.
* @param events The {@link Event events}.
* @return Whether any of the {@link Event events} occurred.
*/
public boolean containsAny(@EventFlags int... events) {
public boolean containsAny(@Event int... events) {
return flags.containsAny(events);
}

Expand All @@ -432,16 +432,16 @@ public int size() {
}

/**
* Returns the {@link EventFlags event} at the given index.
* Returns the {@link Event} at the given index.
*
* <p>Although index-based access is possible, it doesn't imply a particular order of these
* events.
*
* @param index The index. Must be between 0 (inclusive) and {@link #size()} (exclusive).
* @return The {@link EventFlags event} at the given index.
* @return The {@link Event} at the given index.
* @throws IndexOutOfBoundsException If index is outside the allowed range.
*/
@EventFlags
@Event
public int get(int index) {
return flags.get(index);
}
Expand Down Expand Up @@ -1084,7 +1084,7 @@ default void onMetadata(Metadata metadata) {}
/**
* Events that can be reported via {@link Listener#onEvents(Player, Events)}.
*
* <p>One of the {@link Player}{@code .EVENT_*} flags.
* <p>One of the {@link Player}{@code .EVENT_*} values.
*/
@Documented
@Retention(RetentionPolicy.SOURCE)
Expand All @@ -1110,7 +1110,7 @@ default void onMetadata(Metadata metadata) {}
EVENT_SEEK_BACK_INCREMENT_CHANGED,
EVENT_MAX_SEEK_TO_PREVIOUS_POSITION_CHANGED
})
@interface EventFlags {}
@interface Event {}
/** {@link #getCurrentTimeline()} changed. */
int EVENT_TIMELINE_CHANGED = 0;
/** {@link #getCurrentMediaItem()} changed or the player started repeating the current item. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10752,8 +10752,7 @@ private static void deliverBroadcast(Intent intent) {
shadowOf(Looper.getMainLooper()).idle();
}

private static boolean containsEvent(
List<Player.Events> eventsList, @Player.EventFlags int event) {
private static boolean containsEvent(List<Player.Events> eventsList, @Player.Event int event) {
for (Player.Events events : eventsList) {
if (events.contains(event)) {
return true;
Expand Down

0 comments on commit 20d67eb

Please sign in to comment.