// 从设置闹钟周期Activity返回的数据 protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_CODE && resultCode == WeekRepeatActivity.RESULT_CODE) { param.setRepeat(data.getBooleanArrayExtra("repeat")); clockCircleButton.setText("闹钟周期:" + param.getRepeatInfo(param.getRepeat())); } if (requestCode == REQUEST_CODE && resultCode == SelectMusicActivity.RESULT_CODE) { String path = data.getExtras().getString("path"); param.setAudiotype(path); String[] name = path.split("/"); System.out.println("return ring" + path + " name " + name[name.length - 1]); musicButton.setText("铃声:" + name[name.length - 1]); } }
// 初始化各个按钮的文本信息 void initButtonText() { timeButton.setText( "闹钟时间: " + param.getHour() + ":" + (param.getMinute() > 9 ? param.getMinute() : ("0" + param.getMinute()))); clockNameButton.setText("闹钟名称: " + param.getName()); clockCircleButton.setText("闹钟周期: " + param.getRepeatInfo(param.getRepeat())); levelButton.setText("闹钟难度: " + (param.getLevel() == 1 ? "简单-加法" : "困难-乘法")); vibrateButton.setText(param.isIsvabrate() ? "震动: 开启" : "震动: 关闭"); String s = param.getAudiotype(); System.out.println("getAudiotype:" + s); if (s.equals("default")) s = "默认"; else { String[] name = s.split("/"); s = name[name.length - 1]; } musicButton.setText("铃声: " + s); }
// 设置闹钟重复周期 周一到周末 void setRepeatDay() { Intent intent = new Intent(EditClockActivity.this, WeekRepeatActivity.class); intent.putExtra("repeat", param.getRepeat()); startActivityForResult(intent, REQUEST_CODE); }