这是我的一些关于ui理解的注释

lrx_branch
LiuRuiXuan 2 years ago
parent 18d865f5a5
commit eb8a75d94b

@ -38,7 +38,10 @@ import net.micode.notes.data.Notes;
import net.micode.notes.tool.DataUtils;
import java.io.IOException;
/*
author:
2023-4-12
*/
public class AlarmAlertActivity extends Activity implements OnClickListener, OnDismissListener {
private long mNoteId;
@ -48,23 +51,23 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);//创建实例
requestWindowFeature(Window.FEATURE_NO_TITLE);//没有标题
final Window win = getWindow();
win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
final Window win = getWindow();//获取一个窗口对象
win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);//允许应用程序在设备处于锁定状态时显示窗口,如果该标志被设置,则即使用户没有解锁设备,该应用程序仍然可以正常运行。
if (!isScreenOn()) {
win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
| WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
| WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR);
if (!isScreenOn()) {//在屏幕是关闭的情况下
win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON//保持屏幕常亮,以防止设备进入休眠状态。
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON//在锁定状态下唤醒屏幕。如果该标志被设置,则当 Activity 启动时,系统将唤醒设备并点亮屏幕。
| WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON//允许在屏幕常亮时锁定设备。
| WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR);//允许布局扩展到屏幕装饰区域(例如状态栏)之下。
}
Intent intent = getIntent();
Intent intent = getIntent();//获取页面
try {
mNoteId = Long.valueOf(intent.getData().getPathSegments().get(1));
mNoteId = Long.valueOf(intent.getData().getPathSegments().get(1));//
mSnippet = DataUtils.getSnippetById(this.getContentResolver(), mNoteId);
mSnippet = mSnippet.length() > SNIPPET_PREW_MAX_LEN ? mSnippet.substring(0,
SNIPPET_PREW_MAX_LEN) + getResources().getString(R.string.notelist_string_info)
@ -89,11 +92,12 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
}
private void playAlarmSound() {
//获取系统中当前默认的闹钟铃声所对应的 Uri并将其赋值给 url 变量
Uri url = RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_ALARM);
//获取当前系统中哪些音频流会受到静音模式的影响
int silentModeStreams = Settings.System.getInt(getContentResolver(),
Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0);
//如果STREAM_ALARM受到影响那么就将音频流形式设置为silentModeStreams
if ((silentModeStreams & (1 << AudioManager.STREAM_ALARM)) != 0) {
mPlayer.setAudioStreamType(silentModeStreams);
} else {
@ -101,7 +105,7 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
}
try {
mPlayer.setDataSource(this, url);
mPlayer.prepare();
mPlayer.prepare();//于为音频播放做一些准备工作。具体来说,该方法会解析音频数据、分离音频轨道、获取音频格式信息等操作
mPlayer.setLooping(true);
mPlayer.start();
} catch (IllegalArgumentException e) {
@ -121,22 +125,22 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
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);
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.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.setAction(Intent.ACTION_VIEW);//显示页面
intent.putExtra(Intent.EXTRA_UID, mNoteId);//放入对应的数据库中
startActivity(intent);//运行该页面
break;
default:
break;
@ -144,14 +148,14 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
}
public void onDismiss(DialogInterface dialog) {
stopAlarmSound();
finish();
stopAlarmSound();//关闭闹钟铃声
finish();//该页面结束
}
private void stopAlarmSound() {
if (mPlayer != null) {
mPlayer.stop();
mPlayer.release();
if (mPlayer != null) {//如果该播放器存在
mPlayer.stop();//停下
mPlayer.release();//释放资源
mPlayer = null;
}
}

@ -430,7 +430,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
if (id == R.id.btn_set_bg_color) {
mNoteBgColorSelector.setVisibility(View.VISIBLE);
findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(
- View.VISIBLE);
View.VISIBLE);
} else if (sBgSelectorBtnsMap.containsKey(id)) {
findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(
View.GONE);

Loading…
Cancel
Save