From 3a3b4bb57cf663f15efcdf18c40618cc9cdd389d Mon Sep 17 00:00:00 2001 From: Domingos Lopes Date: Sun, 20 Mar 2016 15:02:54 -0400 Subject: [PATCH] Add ordering relations to PlayerStatus --- .../core/service/playback/PlayerStatus.java | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlayerStatus.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlayerStatus.java index 7c666abd5..8a222d7ec 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlayerStatus.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlayerStatus.java @@ -1,24 +1,33 @@ package de.danoeh.antennapod.core.service.playback; public enum PlayerStatus { - INDETERMINATE, // player is currently changing its state, listeners should wait until the player has left this state. - ERROR, - PREPARING, - PAUSED, - PLAYING, - STOPPED, - PREPARED, - SEEKING, - INITIALIZING, // playback service is loading the Playable's metadata - INITIALIZED; // playback service was started, data source of media player was set. + INDETERMINATE(0), // player is currently changing its state, listeners should wait until the player has left this state. + ERROR(-1), + PREPARING(19), + PAUSED(30), + PLAYING(40), + STOPPED(5), + PREPARED(20), + SEEKING(29), + INITIALIZING(9), // playback service is loading the Playable's metadata + INITIALIZED(10); // playback service was started, data source of media player was set. + private int statusValue; private static final PlayerStatus[] fromOrdinalLookup; static { fromOrdinalLookup = PlayerStatus.values(); } + PlayerStatus(int val) { + statusValue = val; + } + public static PlayerStatus fromOrdinal(int o) { return fromOrdinalLookup[o]; } + + public boolean isAtLeast(PlayerStatus other) { + return other == null || this.statusValue>=other.statusValue; + } }