Skip to content

Commit

Permalink
Change the way of hiding the action bar
Browse files Browse the repository at this point in the history
Change the library version
  • Loading branch information
slavipetrov committed Jan 29, 2018
1 parent b9e3f83 commit 19b6794
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
2 changes: 1 addition & 1 deletion 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.5'
libraryVersion = '0.0.6'
}

version = libraryVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void activateFullscreen() {
updateLayoutParams();

// Hiding the supportToolbar
hideActionBar();
toggleActionBarVisibility(false);

// Hide status bar
toggleSystemUiVisibility(activity.getWindow());
Expand Down Expand Up @@ -105,15 +105,14 @@ public void exitFullscreen() {
Activity activity = (Activity) videoView.getContext();
setOrientation(portraitOrientation.getValue());


UiUtils.showOtherViews(getParent());

ViewGroup.LayoutParams params = videoView.getLayoutParams();
params.width = originalWidth;
params.height = originalHeight;
videoView.setLayoutParams(params);

showActionBar();
toggleActionBarVisibility(true);
toggleSystemUiVisibility(activity.getWindow());
}

Expand All @@ -131,33 +130,23 @@ private static void toggleSystemUiVisibility(Window activityWindow) {
activityWindow.getDecorView().setSystemUiVisibility(newUiOptions);
}

private void showActionBar() {
if (videoView.getContext() instanceof AppCompatActivity) {
ActionBar supportActionBar = ((AppCompatActivity) videoView.getContext())
.getSupportActionBar();
private void toggleActionBarVisibility(boolean visible) {
// AppCompatActivity support action bar
ActionBar supportActionBar = ((AppCompatActivity) videoView.getContext())
.getSupportActionBar();
// Activity action bar
android.app.ActionBar actionBar = ((Activity) videoView.getContext()).getActionBar();
if (visible) {
if (supportActionBar != null) {
supportActionBar.show();
}
}
if (videoView.getContext() instanceof Activity) {
android.app.ActionBar actionBar = ((Activity) videoView.getContext()).getActionBar();
if (actionBar != null) {
actionBar.show();
}
}
}

private void hideActionBar() {
if (videoView.getContext() instanceof AppCompatActivity) {
ActionBar supportActionBar = ((AppCompatActivity) videoView.getContext())
.getSupportActionBar();
} else {
if (supportActionBar != null) {
supportActionBar.hide();
}
}

if (videoView.getContext() instanceof Activity) {
android.app.ActionBar actionBar = ((Activity) videoView.getContext()).getActionBar();
if (actionBar != null) {
actionBar.hide();
}
Expand Down Expand Up @@ -228,7 +217,8 @@ public void onOrientationChanged(int orientation) {
* @return true or false according to whether the rotation is enabled or disabled
*/
private static boolean isRotationEnabled(ContentResolver contentResolver) {
return Settings.System.getInt(contentResolver, Settings.System.ACCELEROMETER_ROTATION, 0) == 1;
return Settings.System.getInt(contentResolver, Settings.System.ACCELEROMETER_ROTATION,
0) == 1;
}

public boolean isLandscape() {
Expand Down

0 comments on commit 19b6794

Please sign in to comment.