Merge pull request '注释了onClick方法,onDismiss方法和stopAlarmSound方法' (#18) from g_merge_branch into g_branch

pull/17/head
p2ow6hvl5 3 months ago
commit 19e924f9cd

@ -169,29 +169,51 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
dialog.show().setOnDismissListener(this);
}
/**
*
* @param dialog
* @param which
*/
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case DialogInterface.BUTTON_NEGATIVE:
// 当点击否定按钮(如"进入"按钮)时:
// 1. 创建跳转到笔记编辑页面的Intent
Intent intent = new Intent(this, NoteEditActivity.class);
// 2. 设置动作为查看
intent.setAction(Intent.ACTION_VIEW);
// 3. 传入当前笔记ID作为额外数据
intent.putExtra(Intent.EXTRA_UID, mNoteId);
// 4. 启动笔记编辑Activity
startActivity(intent);
break;
default:
// 其他按钮(如确定按钮)不做特殊处理
break;
}
}
/**
*
* @param dialog
*/
public void onDismiss(DialogInterface dialog) {
// 1. 停止闹铃声音
stopAlarmSound();
// 2. 关闭当前Activity
finish();
}
/**
*
*/
private void stopAlarmSound() {
if (mPlayer != null) {
// 停止播放
mPlayer.stop();
// 释放播放器资源
mPlayer.release();
// 将播放器引用置空,防止内存泄漏
mPlayer = null;
}
}
}

Loading…
Cancel
Save