a
554325746@qq.com
2019-12-25 38492bbaa63586e2f4877da0eaa01a082fd565a6
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package com.basic.security.widget;
 
import android.content.Context;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListPopupWindow;
import android.widget.ListView;
import android.widget.MediaController;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.TextView;
 
import com.basic.security.activity.MainActivity;
import com.basic.security.base.BaseApplication;
 
import java.lang.reflect.Field;
 
public class MyMediaController extends MediaController
{
    private FrameLayout anchorView;
 
    public void hideSystemUI() {
        try {
            Field f = this.getClass().getSuperclass().getDeclaredField("mRoot");
            f.setAccessible(true);
            View mRoot  = (View) f.get(this);
 
            if (mRoot != null) {
                mRoot.setBackgroundColor(0x33000000);
            }
 
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            Field f = this.getClass().getSuperclass().getDeclaredField("mWindow");
            f.setAccessible(true);
            Window window  = (Window) f.get(this);
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                    | View.SYSTEM_UI_FLAG_IMMERSIVE);
 
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        if (event.getKeyCode() == KeyEvent.KEYCODE_BACK ) {
            ((MainActivity)BaseApplication.getApplication().activity).exit_fullscreen();
            return true;
        }
        return super.dispatchKeyEvent(event);
    }
    public MyMediaController(Context context, FrameLayout anchorView)
    {
        super(context);
        this.anchorView = anchorView;
        hideSystemUI();
    }
 
    @Override
    protected void onSizeChanged(int xNew, int yNew, int xOld, int yOld)
    {
        super.onSizeChanged(xNew, yNew, xOld, yOld);
 
        RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) anchorView.getLayoutParams();
        lp.setMargins(0, 0, 0, yNew);
 
        anchorView.setLayoutParams(lp);
        anchorView.requestLayout();
    }
 
    @Override
    public void show(int timeout) {
        super.show(0);
        hideSystemUI();
    }
}