|
|
|
@ -557,8 +557,17 @@ public class NoteEditActivity extends Activity //NOTE: extends--单继承,但
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
|
/**
|
|
|
|
|
* @method: onOptionsItemSelected
|
|
|
|
|
* @description: 覆写了Activity.java里的onOptionsItemSelected,路线是menu-->item,
|
|
|
|
|
* 这里就是处理识别到的item
|
|
|
|
|
* @date: 2023/12/19 23:35
|
|
|
|
|
* @author: zhoukexing
|
|
|
|
|
* @param: [item]
|
|
|
|
|
* @return: boolean
|
|
|
|
|
*/
|
|
|
|
|
int itemId = item.getItemId();
|
|
|
|
|
if (itemId == R.id.menu_new_note) {
|
|
|
|
|
if (itemId == R.id.menu_new_note) { // 从item到itemid,用itemid导向对应的不同的动作 @zhoukexing 2023/12/19 23:38
|
|
|
|
|
createNewNote();
|
|
|
|
|
} else if (itemId == R.id.menu_delete) {
|
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
|
|
@ -623,13 +632,23 @@ public class NoteEditActivity extends Activity //NOTE: extends--单继承,但
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void createNewNote() {
|
|
|
|
|
/**
|
|
|
|
|
* @method: createNewNote
|
|
|
|
|
* @description: 从编辑页面,点击“add note”会进入这个创建便签的方法。
|
|
|
|
|
* 此方法会保存并结束当前便签,用NoteEditActivity类实例化一个新的intent(活动意图),
|
|
|
|
|
* 设置行为和指定报错对象后,启动intent活动意图
|
|
|
|
|
* @date: 2023/12/19 23:03
|
|
|
|
|
* @author: zhoukexing
|
|
|
|
|
* @param: []
|
|
|
|
|
* @return: void
|
|
|
|
|
*/
|
|
|
|
|
// Firstly, save current editing notes
|
|
|
|
|
saveNote();
|
|
|
|
|
|
|
|
|
|
// For safety, start a new NoteEditActivity
|
|
|
|
|
finish();
|
|
|
|
|
Intent intent = new Intent(this, NoteEditActivity.class); //Q: 在类的内部,还没有实现完全时,启动这个类自己?@zkx 2023/12/17
|
|
|
|
|
intent.setAction(Intent.ACTION_INSERT_OR_EDIT);
|
|
|
|
|
intent.setAction(Intent.ACTION_INSERT_OR_EDIT); // 创建便签后,要插入或者编辑。Q: 为什么要插入 @zhoukexing 2023/12/19 22:57
|
|
|
|
|
intent.putExtra(Notes.INTENT_EXTRA_FOLDER_ID, mWorkingNote.getFolderId());
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
}
|
|
|
|
@ -865,8 +884,16 @@ public class NoteEditActivity extends Activity //NOTE: extends--单继承,但
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean saveNote() {
|
|
|
|
|
/**
|
|
|
|
|
* @method: saveNote
|
|
|
|
|
* @description: 获取工作文本,调用真正的保存便签的方法,设置便签在list界面的位置
|
|
|
|
|
* @date: 2023/12/19 23:50
|
|
|
|
|
* @author: zhoukexing
|
|
|
|
|
* @param: []
|
|
|
|
|
* @return: boolean
|
|
|
|
|
*/
|
|
|
|
|
getWorkingText();
|
|
|
|
|
boolean saved = mWorkingNote.saveNote();
|
|
|
|
|
boolean saved = mWorkingNote.saveNote();// TODO: 2023/12/19 工作便签下的saveNote
|
|
|
|
|
if (saved) {
|
|
|
|
|
/**
|
|
|
|
|
* There are two modes from List view to edit view, open one note,
|
|
|
|
@ -875,7 +902,8 @@ public class NoteEditActivity extends Activity //NOTE: extends--单继承,但
|
|
|
|
|
* new node requires to the top of the list. This code
|
|
|
|
|
* {@link #RESULT_OK} is used to identify the create/edit state
|
|
|
|
|
*/
|
|
|
|
|
setResult(RESULT_OK);
|
|
|
|
|
setResult(RESULT_OK); // RESULT_OK指示将该便签保存到list界面的顶端(因为这是新建的便签) @zhoukexing 2023/12/19 23:41
|
|
|
|
|
//Q: 这个setResult只在这里调用了,怎么实现的 @zkx 2023/12/19
|
|
|
|
|
}
|
|
|
|
|
return saved;
|
|
|
|
|
}
|
|
|
|
|