cmt: track onCreateNewNote 30%

zhengkunpeng_branch
zkx 2 years ago
parent fd192ae055
commit 7552054c2c

@ -187,16 +187,24 @@ public class WorkingNote {
return new WorkingNote(context, id, 0); return new WorkingNote(context, id, 0);
} }
public synchronized boolean saveNote() { public synchronized boolean saveNote() {// TODO: 2023/12/19 要仔细溯源看看
if (isWorthSaving()) { /**
if (!existInDatabase()) { * @method: saveNote
* @description: 便true
* @date: 2023/12/19 23:44
* @author: zhoukexing
* @param: []
* @return: boolean
*/
if (isWorthSaving()) { // 判断是否有新内容-->是否值得注释 @zhoukexing 2023/12/19 23:45
if (!existInDatabase()) { // 判断是否在数据库里存在==是新便签还是已有便签 @zhoukexing 2023/12/19 23:45
if ((mNoteId = Note.getNewNoteId(mContext, mFolderId)) == 0) { if ((mNoteId = Note.getNewNoteId(mContext, mFolderId)) == 0) {
Log.e(TAG, "Create new note fail with id:" + mNoteId); Log.e(TAG, "Create new note fail with id:" + mNoteId);
return false; return false;
} }
} }
mNote.syncNote(mContext, mNoteId); mNote.syncNote(mContext, mNoteId); // 和远程同步 @zhoukexing 2023/12/19 23:46
/** /**
* Update widget content if there exist any widget of this note * Update widget content if there exist any widget of this note
@ -208,7 +216,7 @@ public class WorkingNote {
} }
return true; return true;
} else { } else {
return false; return false; // 没有需要保存的就返回false @zhoukexing 2023/12/19 23:46
} }
} }

@ -557,8 +557,17 @@ public class NoteEditActivity extends Activity //NOTE: extends--单继承,但
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
/**
* @method: onOptionsItemSelected
* @description: Activity.javaonOptionsItemSelected线menu-->item
* item
* @date: 2023/12/19 23:35
* @author: zhoukexing
* @param: [item]
* @return: boolean
*/
int itemId = item.getItemId(); 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(); createNewNote();
} else if (itemId == R.id.menu_delete) { } else if (itemId == R.id.menu_delete) {
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
@ -623,13 +632,23 @@ public class NoteEditActivity extends Activity //NOTE: extends--单继承,但
} }
private void createNewNote() { private void createNewNote() {
/**
* @method: createNewNote
* @description: add note便
* 便NoteEditActivityintent
* intent
* @date: 2023/12/19 23:03
* @author: zhoukexing
* @param: []
* @return: void
*/
// Firstly, save current editing notes // Firstly, save current editing notes
saveNote(); saveNote();
// For safety, start a new NoteEditActivity // For safety, start a new NoteEditActivity
finish(); finish();
Intent intent = new Intent(this, NoteEditActivity.class); //Q: 在类的内部,还没有实现完全时,启动这个类自己?@zkx 2023/12/17 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()); intent.putExtra(Notes.INTENT_EXTRA_FOLDER_ID, mWorkingNote.getFolderId());
startActivity(intent); startActivity(intent);
} }
@ -865,8 +884,16 @@ public class NoteEditActivity extends Activity //NOTE: extends--单继承,但
} }
private boolean saveNote() { private boolean saveNote() {
/**
* @method: saveNote
* @description: 便便list
* @date: 2023/12/19 23:50
* @author: zhoukexing
* @param: []
* @return: boolean
*/
getWorkingText(); getWorkingText();
boolean saved = mWorkingNote.saveNote(); boolean saved = mWorkingNote.saveNote();// TODO: 2023/12/19 工作便签下的saveNote
if (saved) { if (saved) {
/** /**
* There are two modes from List view to edit view, open one note, * 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 * new node requires to the top of the list. This code
* {@link #RESULT_OK} is used to identify the create/edit state * {@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; return saved;
} }

Loading…
Cancel
Save