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