补充 AlarmAlertActivity 注释

chh
MikkoAyaka 2 years ago
parent c7fc0ed3a1
commit ed59798065

@ -43,8 +43,17 @@ import java.io.IOException;
* *
*/ */
public class AlarmAlertActivity extends Activity implements OnClickListener, OnDismissListener { public class AlarmAlertActivity extends Activity implements OnClickListener, OnDismissListener {
/**
* 便ID
*/
private long mNoteId; private long mNoteId;
/**
*
*/
private String mSnippet; private String mSnippet;
/**
*
*/
private static final int SNIPPET_PREW_MAX_LEN = 60; private static final int SNIPPET_PREW_MAX_LEN = 60;
MediaPlayer mPlayer; MediaPlayer mPlayer;
@ -67,22 +76,28 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
| WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR); | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR);
} }
//定义意图对象,调用系统应用
Intent intent = getIntent(); Intent intent = getIntent();
try { try {
// 便签ID
mNoteId = Long.valueOf(intent.getData().getPathSegments().get(1)); mNoteId = Long.valueOf(intent.getData().getPathSegments().get(1));
// 片段名称
mSnippet = DataUtils.getSnippetById(this.getContentResolver(), mNoteId); mSnippet = DataUtils.getSnippetById(this.getContentResolver(), mNoteId);
mSnippet = mSnippet.length() > SNIPPET_PREW_MAX_LEN ? mSnippet.substring(0, mSnippet = mSnippet.length() > SNIPPET_PREW_MAX_LEN ? mSnippet.substring(0,
SNIPPET_PREW_MAX_LEN) + getResources().getString(R.string.notelist_string_info) SNIPPET_PREW_MAX_LEN) + getResources().getString(R.string.notelist_string_info)
: mSnippet; : mSnippet;
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
// 异常处理
e.printStackTrace(); e.printStackTrace();
return; return;
} }
mPlayer = new MediaPlayer(); mPlayer = new MediaPlayer();
if (DataUtils.visibleInNoteDatabase(getContentResolver(), mNoteId, Notes.TYPE_NOTE)) { if (DataUtils.visibleInNoteDatabase(getContentResolver(), mNoteId, Notes.TYPE_NOTE)) {
// 显示弹出窗口
showActionDialog(); showActionDialog();
// 播放提示音
playAlarmSound(); playAlarmSound();
} else { } else {
finish(); finish();
@ -137,12 +152,18 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
*/ */
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);
} }

Loading…
Cancel
Save