示例#1
0
  public void reset() {
    Config config = Config.get();
    vibrateOn = config.getBoolean("key_vibrate");
    duration = config.getInt("key_vibrate_duration");
    if (vibrateOn && (vibrator == null)) {
      vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    }

    soundOn = config.getBoolean("key_sound");
    volume = config.getFloat("key_sound_volume");
    if (soundOn && (audioManager == null)) {
      audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    }

    isSpeakCommit = config.getBoolean("speak_commit");
    isSpeakKey = config.getBoolean("speak_key");
    if (mTTS == null && (isSpeakCommit || isSpeakKey)) {
      mTTS =
          new TextToSpeech(
              context,
              new TextToSpeech.OnInitListener() {
                public void onInit(int status) {
                  // 初始化結果
                }
              });
    }
  }
示例#2
0
 @Test(expected = NumberFormatException.class)
 public void getFloatNFE() throws Exception {
   final Config config = new Config();
   config.overrideConfig("asynchbase.float", "this can't be parsed to float");
   config.getFloat("asynchbase.float");
 }
示例#3
0
 @Test(expected = NullPointerException.class)
 public void getFloatDoesNotExist() throws Exception {
   final Config config = new Config();
   config.getFloat("asynchbase.nosuchkey");
 }
示例#4
0
 @Test(expected = NullPointerException.class)
 public void getFloatNull() throws Exception {
   final Config config = new Config();
   config.overrideConfig("asynchbase.null", null);
   config.getFloat("asynchbase.null");
 }
示例#5
0
 @Test
 public void getFloatNegative() throws Exception {
   final Config config = new Config();
   config.overrideConfig("asynchbase.float", Float.toString(Float.MIN_VALUE));
   assertEquals(Float.MIN_VALUE, config.getFloat("asynchbase.float"), 0.000001);
 }