package com.gingersoft.gsa.cloud.base.utils;

import android.content.Context;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Vibrator;
import com.gingersoft.gsa.cloud.base.R;
import com.gingersoft.gsa.cloud.base.utils.constans.AppConstans;
import com.gingersoft.gsa.cloud.base.utils.other.SPUtils;

/**
 * 作者：ELEGANT_BIN
 * 版本：1.6.0
 * 创建日期：2018/8/2
 * 修订历史：2018/8/2
 * 描述：
 */

public class VibratorUtils {


    public static void pressButtonSound(Context context) {
        SoundPool soundPool = new SoundPool(1, AudioManager.STREAM_SYSTEM, 0);
        soundPool.load(context, R.raw.beep, 1);
        int vibrationProgress = (int) SPUtils.get(context, AppConstans.VIBRATION_PROGRESS,0);
        int presssoundProgress = (int) SPUtils.get(context, AppConstans.PRESSSOUND_PROGRESS,0);
        try {
            Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
            if (vibrationProgress > 0) {
//                vibrator.vibrate(vibrationProgress * 100);
            }
            if (presssoundProgress > 0) {
                soundPool.play(1, 1, 1, 0, 0, 1);
            }
        } catch (Exception e) {
        }
    }
}
