package com.hh.arome.common.deviceui;

import android.app.Activity;
import android.content.Intent;

/**
 * K8、F10
 */
public class K8DeviceUI implements IDeviceUI {

    //用volatile关键字确保 instance 在多线程下的可见性
    private static volatile K8DeviceUI instance = null;

    //将构造方法私有化，禁止外部通过构造方法创建实例
    private K8DeviceUI() {}

    //提供一个公共的访问方法，用于获取该类的唯一实例
    public static K8DeviceUI getInstance() {
        //如果instance为空，就进行实例化
        if (instance == null) {
            //保证多线程下只有一个线程进行实例化
            synchronized (K8DeviceUI.class) {
                //第二次判断，避免多线程下创建多个实例
                if (instance == null) {
                    instance = new K8DeviceUI();
                }
            }
        }
        return instance;
    }

    @Override
    public void showNotification(Activity activity) {
        Intent intent = new Intent();
        intent.setAction("com.android.systemui.statusbar.phone.statusopen");
        activity.sendBroadcast(intent);
    }

    @Override
    public void hideNotification(Activity activity) {
        Intent intent = new Intent();
        intent.setAction("com.android.systemui.statusbar.phone.statusclose");
        activity.sendBroadcast(intent);
    }

    @Override
    public void showNavigationBar(Activity activity) {
        Intent intent = new Intent();
        intent.setAction("com.android.internal.policy.impl.showNavigationBar");
        activity.sendBroadcast(intent);
    }

    @Override
    public void hideNavigationBar(Activity activity) {
        Intent intent = new Intent();
        intent.setAction("com.android.internal.policy.impl.hideNavigationBar");
        activity.sendBroadcast(intent);
    }
}
