forked from PierfrancescoSoffritti/android-youtube-player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FullscreenHelper.java
66 lines (54 loc) · 1.64 KB
/
FullscreenHelper.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package com.pierfrancescosoffritti.androidyoutubeplayer.core.sampleapp.utils;
import android.app.Activity;
import android.view.View;
/**
* Class responsible for changing the view from full screen to non-full screen and vice versa.
*
* @author Pierfrancesco Soffritti
*/
public class FullscreenHelper {
private final Activity context;
private final View[] views;
/**
* @param context
* @param views to hide/show
*/
public FullscreenHelper(Activity context, View... views) {
this.context = context;
this.views = views;
}
/**
* call this method to enter full screen
*/
public void enterFullscreen() {
View decorView = context.getWindow().getDecorView();
hideSystemUi(decorView);
for (View view : views) {
view.setVisibility(View.GONE);
view.invalidate();
}
}
/**
* call this method to exit full screen
*/
public void exitFullscreen() {
View decorView = context.getWindow().getDecorView();
showSystemUi(decorView);
for (View view : views) {
view.setVisibility(View.VISIBLE);
view.invalidate();
}
}
private void hideSystemUi(View mDecorView) {
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
private void showSystemUi(View mDecorView) {
mDecorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
}
}