Skip to content

Commit

Permalink
Merge pull request #10 from dev-labs-bg/develop
Browse files Browse the repository at this point in the history
Refactor part of the logic
  • Loading branch information
slavipetrov authored Nov 13, 2017
2 parents bef43f2 + ed8d915 commit c32b082
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 34 deletions.
3 changes: 1 addition & 2 deletions library/release.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apply from: 'keystore.gradle'
ext {
publishedGroupId = 'bg.devlabs.fullscreenvideoview'
artifactId = 'library'
libraryVersion = '0.0.1'
libraryVersion = '0.0.2'
}

version = libraryVersion
Expand Down Expand Up @@ -58,7 +58,6 @@ if (project.hasProperty("android")) {
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
// options.encoding = 'UTF-8'
}

artifacts {
Expand Down
20 changes: 10 additions & 10 deletions library/src/main/java/bg/devlabs/fullscreenvideoview/Builder.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ void videoFile(@NonNull final File videoFile) {
fullscreenVideoView.setupMediaPlayer(videoFile.getPath());
}

void videoPath(@NonNull final String videoPath) {
fullscreenVideoView.setupMediaPlayer(videoPath);
void videoUrl(@NonNull final String videoUrl) {
fullscreenVideoView.setupMediaPlayer(videoUrl);
}

public Builder autoStartEnabled(boolean isAutoStartEnabled) {
fullscreenVideoView.setAutoStartEnabled(isAutoStartEnabled);
public Builder enableAutoStart() {
fullscreenVideoView.enableAutoStart();
return this;
}

Expand Down Expand Up @@ -130,18 +130,18 @@ public Builder portraitOrientation(PortraitOrientation portraitOrientation) {
return this;
}

public Builder setCanPause(boolean isPauseEnabled) {
videoMediaPlayer.setCanPause(isPauseEnabled);
public Builder canPause(boolean canPause) {
videoMediaPlayer.setPauseEnabled(canPause);
return this;
}

public Builder setCanSeekBackward(boolean isSeekBackwardEnabled) {
videoMediaPlayer.setCanSeekBackward(isSeekBackwardEnabled);
public Builder canSeekBackward(boolean canSeekBackward) {
videoMediaPlayer.setCanSeekBackward(canSeekBackward);
return this;
}

public Builder setCanSeekForward(boolean isSeekForwardEnabled) {
videoMediaPlayer.setCanSeekForward(isSeekForwardEnabled);
public Builder canSeekForward(boolean canSeekForward) {
videoMediaPlayer.setCanSeekForward(canSeekForward);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ public Builder build(File videoFile) {
return builder;
}

public Builder build(String videoPath) {
public Builder build(String videoUrl) {
builder = new Builder(this, controller, orientationDelegate,
videoMediaPlayer);
builder.videoPath(videoPath);
builder.videoUrl(videoUrl);
return builder;
}

Expand Down Expand Up @@ -224,8 +224,8 @@ void toggleFullscreen() {
orientationDelegate.toggleFullscreen();
}

void setAutoStartEnabled(boolean autoStartEnabled) {
videoMediaPlayer.setAutoStartEnabled(autoStartEnabled);
void enableAutoStart() {
videoMediaPlayer.enableAutoStart();
}

private class VideoOnKeyListener implements View.OnKeyListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ private void disableUnsupportedButtons() {
}
} catch (IncompatibleClassChangeError ex) {
// We were given an old version of the interface, that doesn't have
// the setCanPause/canSeekXYZ methods. This is OK, it just means we
// the canPause/canSeekXYZ methods. This is OK, it just means we
// assume the media can be paused and seeked, and so we don't disable
// the buttons.
ex.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,23 @@ void onDetach() {
release();
}

public boolean isAutoStartEnabled() {
boolean isAutoStartEnabled() {
return isAutoStartEnabled;
}

public void setAutoStartEnabled(boolean autoStartEnabled) {
isAutoStartEnabled = autoStartEnabled;
void enableAutoStart() {
isAutoStartEnabled = true;
}

public void setCanPause(boolean canPause) {
void setPauseEnabled(boolean canPause) {
this.canPause = canPause;
}

public void setCanSeekBackward(boolean canSeekBackward) {
void setCanSeekBackward(boolean canSeekBackward) {
this.canSeekBackward = canSeekBackward;
}

public void setCanSeekForward(boolean canSeekForward) {
void setCanSeekForward(boolean canSeekForward) {
this.canSeekForward = canSeekForward;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@SuppressWarnings("unused")
public enum LandscapeOrientation {
SENSOR(SCREEN_ORIENTATION_SENSOR_LANDSCAPE),
LANDSCAPE(SCREEN_ORIENTATION_LANDSCAPE),
DEFAULT(SCREEN_ORIENTATION_LANDSCAPE),
REVERSE(SCREEN_ORIENTATION_LANDSCAPE),
USER(SCREEN_ORIENTATION_USER_LANDSCAPE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public abstract class OrientationDelegate extends OrientationEventListener {
private final ContentResolver contentResolver;
// Orientation
private LandscapeOrientation landscapeOrientation = LandscapeOrientation.SENSOR;
private PortraitOrientation portraitOrientation = PortraitOrientation.PORTRAIT;
private PortraitOrientation portraitOrientation = PortraitOrientation.DEFAULT;
private boolean shouldEnterPortrait;

protected OrientationDelegate(Context context, FullscreenVideoView fullscreenVideoView) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@SuppressWarnings("unused")
public enum PortraitOrientation {
SENSOR(SCREEN_ORIENTATION_SENSOR_PORTRAIT),
PORTRAIT(SCREEN_ORIENTATION_PORTRAIT),
DEFAULT(SCREEN_ORIENTATION_PORTRAIT),
REVERSE(SCREEN_ORIENTATION_REVERSE_PORTRAIT),
USER(SCREEN_ORIENTATION_USER_PORTRAIT);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ class ActionBarActivity : AppCompatActivity() {
supportActionBar?.title = getString(R.string.action_bar_activity)
val videoPath = "http://clips.vorwaerts-gmbh.de/VfE_html5.mp4"

fullscreenVideoView.build(videoPath)
fullscreenVideoView.videoUrl(videoPath)
.progressBarColor(R.color.colorAccent)
.autoStartEnabled(true)
.enableAutoStart()
.landscapeOrientation(LandscapeOrientation.SENSOR)
.portraitOrientation(PortraitOrientation.PORTRAIT)
.setCanSeekBackward(false)
.setCanSeekForward(false)
.portraitOrientation(PortraitOrientation.DEFAULT)
.canSeekForward(false)
.canSeekBackward(false)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ class NoActionBarActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_no_action_bar)
val videoPath = "http://clips.vorwaerts-gmbh.de/VfE_html5.mp4"
fullscreenVideoView.build(videoPath)
fullscreenVideoView.videoUrl(videoPath)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ class RegularActivity : Activity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_regular)
val videoPath = "http://clips.vorwaerts-gmbh.de/VfE_html5.mp4"
fullscreenVideoView.build(videoPath)
fullscreenVideoView.videoUrl(videoPath)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ class ToolbarActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_toolbar)
val videoPath = "http://clips.vorwaerts-gmbh.de/VfE_html5.mp4"
fullscreenVideoView.build(videoPath)
fullscreenVideoView.videoUrl(videoPath)
}
}

0 comments on commit c32b082

Please sign in to comment.