-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move PlayerType into its own class and add documentation
Also replace some `isPlayerOpen` with direct `playerType == null` checks.
- Loading branch information
Showing
11 changed files
with
58 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
app/src/main/java/org/schabi/newpipe/player/PlayerType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.schabi.newpipe.player; | ||
|
||
import static org.schabi.newpipe.player.Player.PLAYER_TYPE; | ||
|
||
import android.content.Intent; | ||
|
||
public enum PlayerType { | ||
MAIN, | ||
AUDIO, | ||
POPUP; | ||
|
||
/** | ||
* @return an integer representing this {@link PlayerType}, to be used to save it in intents | ||
* @see #retrieveFromIntent(Intent) Use retrieveFromIntent() to retrieve and convert player type | ||
* integers from an intent | ||
*/ | ||
public int valueForIntent() { | ||
return ordinal(); | ||
} | ||
|
||
/** | ||
* @param intent the intent to retrieve a player type from | ||
* @return the player type integer retrieved from the intent, converted back into a {@link | ||
* PlayerType}, or {@link PlayerType#MAIN} if there is no player type extra in the | ||
* intent | ||
* @throws ArrayIndexOutOfBoundsException if the intent contains an invalid player type integer | ||
* @see #valueForIntent() Use valueForIntent() to obtain valid player type integers | ||
*/ | ||
public static PlayerType retrieveFromIntent(final Intent intent) { | ||
return values()[intent.getIntExtra(PLAYER_TYPE, MAIN.valueForIntent())]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters