This repository has been archived by the owner on Feb 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #162 from novoda/media_player_surface_holder
Provide both Surface and SurfaceHolder in MediaPlayer
- Loading branch information
Showing
9 changed files
with
196 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.novoda.noplayer.model; | ||
|
||
public abstract class Either<L, R> { | ||
|
||
public static <L, R> Either<L, R> left(L left) { | ||
return new Left<>(left); | ||
} | ||
|
||
public static <L, R> Either<L, R> right(R right) { | ||
return new Right<>(right); | ||
} | ||
|
||
Either() { | ||
// restrict subclasses to the package | ||
} | ||
|
||
public abstract void apply(Consumer<L> leftConsumer, Consumer<R> rightConsumer); | ||
|
||
static class Left<L, R> extends Either<L, R> { | ||
|
||
private final L valueLeft; | ||
|
||
Left(L valueLeft) { | ||
this.valueLeft = valueLeft; | ||
} | ||
|
||
@Override | ||
public void apply(Consumer<L> leftConsumer, Consumer<R> rightConsumer) { | ||
leftConsumer.accept(valueLeft); | ||
} | ||
} | ||
|
||
static class Right<L, R> extends Either<L, R> { | ||
|
||
private final R valueRight; | ||
|
||
Right(R valueRight) { | ||
this.valueRight = valueRight; | ||
} | ||
|
||
@Override | ||
public void apply(Consumer<L> leftConsumer, Consumer<R> rightConsumer) { | ||
rightConsumer.accept(valueRight); | ||
} | ||
} | ||
|
||
public interface Consumer<T> { | ||
void accept(T value); | ||
} | ||
} |
Oops, something went wrong.