Signed-off-by: rtc <rtc@qq.com>

pull/34/head
rtc 2 years ago
parent 5092d1458c
commit b7dfe3a9fb

@ -117,42 +117,38 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
} }
try { try {
mPlayer.setDataSource(this, url); // 设置媒体放器的数据源为闹钟铃声的URI mPlayer.setDataSource(this, url); // 设置媒体放器的数据源为闹钟铃声的URI
mPlayer.prepare(); mPlayer.prepare(); // 准备异步播放
mPlayer.setLooping(true); mPlayer.setLooping(true); // 设置循环播放
mPlayer.start(); mPlayer.start(); // 开始播放
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) { // 处理参数异常
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} catch (SecurityException e) { } catch (SecurityException e) { // 处理安全异常
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} catch (IllegalStateException e) { } catch (IllegalStateException e) { // 处理状态异常
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} catch (IOException e) { } catch (IOException e) { // 处理IO异常
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }
private void showActionDialog() { private void showActionDialog() {
AlertDialog.Builder dialog = new AlertDialog.Builder(this); AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setTitle(R.string.app_name); dialog.setTitle(R.string.app_name); // 设置对话框标题
dialog.setMessage(mSnippet); dialog.setMessage(mSnippet); // 设置对话框消息内容
dialog.setPositiveButton(R.string.notealert_ok, this); dialog.setPositiveButton(R.string.notealert_ok, this); // 设置对话框的确定按钮和点击事件
if (isScreenOn()) { if (isScreenOn()) { // 判断屏幕是否亮屏
dialog.setNegativeButton(R.string.notealert_enter, this); dialog.setNegativeButton(R.string.notealert_enter, this); // 设置对话框的取消按钮和点击事件
} }
dialog.show().setOnDismissListener(this); dialog.show().setOnDismissListener(this); // 显示对话框,并设置对话框消失时的监听器
} }
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
switch (which) { switch (which) {
case DialogInterface.BUTTON_NEGATIVE: case DialogInterface.BUTTON_NEGATIVE:
Intent intent = new Intent(this, NoteEditActivity.class); Intent intent = new Intent(this, NoteEditActivity.class); // 创建一个Intent对象跳转到NoteEditActivity
intent.setAction(Intent.ACTION_VIEW); intent.setAction(Intent.ACTION_VIEW); // 设置Intent的操作为查看操作
intent.putExtra(Intent.EXTRA_UID, mNoteId); intent.putExtra(Intent.EXTRA_UID, mNoteId); // 设置Intent的额外数据
startActivity(intent); startActivity(intent); // 启动Activity
break; break;
default: default:
break; break;
@ -160,15 +156,14 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
} }
public void onDismiss(DialogInterface dialog) { public void onDismiss(DialogInterface dialog) {
stopAlarmSound(); stopAlarmSound(); // 停止播放铃声
finish(); finish(); // 结束当前Activity
} }
private void stopAlarmSound() { private void stopAlarmSound() {
if (mPlayer != null) { if (mPlayer != null) {
mPlayer.stop(); mPlayer.stop(); // 停止播放
mPlayer.release(); mPlayer.release(); // 释放资源
mPlayer = null; mPlayer = null; // 置空
} }
} }
} }

Loading…
Cancel
Save