diff --git a/doc/~$软件泛读、标注和维护报告文档.docx b/doc/~$软件泛读、标注和维护报告文档.docx new file mode 100644 index 0000000..ce41eec Binary files /dev/null and b/doc/~$软件泛读、标注和维护报告文档.docx differ diff --git a/doc/开源软件泛读、标注和维护报告文档.docx b/doc/开源软件泛读、标注和维护报告文档.docx index 3e73494..9ea3054 100644 Binary files a/doc/开源软件泛读、标注和维护报告文档.docx and b/doc/开源软件泛读、标注和维护报告文档.docx differ diff --git a/src/main/java/net/micode/notes/ui/NoteEditActivity.java b/src/main/java/net/micode/notes/ui/NoteEditActivity.java index 0171ee3..3c5493d 100644 --- a/src/main/java/net/micode/notes/ui/NoteEditActivity.java +++ b/src/main/java/net/micode/notes/ui/NoteEditActivity.java @@ -175,6 +175,7 @@ public class NoteEditActivity extends Activity //NOTE: extends--单继承,但 if (savedInstanceState == null && !initActivityState(getIntent())) { // savedInstanceState? @zhoukexing 2023/12/20 23:45 + // 表示之前保存的状态,用于还原数据 @lzk 2024/1/3 23:33 finish(); return; } @@ -219,10 +220,10 @@ public class NoteEditActivity extends Activity //NOTE: extends--单继承,但 /** * Starting from the searched result */ + // 高亮搜索内容 @lzk 2024/1/3 10:10 if (intent.hasExtra(SearchManager.EXTRA_DATA_KEY)) { noteId = Long.parseLong(intent.getStringExtra(SearchManager.EXTRA_DATA_KEY)); mUserQuery = intent.getStringExtra(SearchManager.USER_QUERY); - // 高亮搜索内容 @lzk 2024/1/3 10:10 } if (!DataUtils.visibleInNoteDatabase(getContentResolver(), noteId, Notes.TYPE_NOTE)) { @@ -366,6 +367,7 @@ public class NoteEditActivity extends Activity //NOTE: extends--单继承,但 @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); + // 若为搜索事件则设置高亮 if (Intent.ACTION_SEARCH.equals(intent.getAction())) { mUserQuery = intent.getStringExtra(SearchManager.QUERY); mNoteEditor.setText(getHighlightQueryResult(mWorkingNote.getContent(), mUserQuery)); diff --git a/src/main/java/net/micode/notes/ui/NotesListActivity.java b/src/main/java/net/micode/notes/ui/NotesListActivity.java index 26a2f9d..5d46bb3 100644 --- a/src/main/java/net/micode/notes/ui/NotesListActivity.java +++ b/src/main/java/net/micode/notes/ui/NotesListActivity.java @@ -148,6 +148,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt */ setAppInfoFromRawRes(); Intent intent = getIntent(); + // 搜索页面 if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); mNotesListAdapter.setmQuery(query); diff --git a/src/main/java/net/micode/notes/ui/NotesListAdapter.java b/src/main/java/net/micode/notes/ui/NotesListAdapter.java index 42c79f8..1363ba6 100644 --- a/src/main/java/net/micode/notes/ui/NotesListAdapter.java +++ b/src/main/java/net/micode/notes/ui/NotesListAdapter.java @@ -40,7 +40,7 @@ public class NotesListAdapter extends CursorAdapter { private HashMap mSnippetPosition; private int mNotesCount; private boolean mChoiceMode; - private String mQuery; + private String mQuery; // 搜索串 public static class AppWidgetAttribute { public int widgetId; @@ -59,6 +59,7 @@ public class NotesListAdapter extends CursorAdapter { @Override public View getView(int position, View convertView, ViewGroup parent) { View view = super.getView(position, convertView, parent); + // 仅显示便签项中包含搜索串的便签 if(!TextUtils.isEmpty(mQuery) && !mSnippetPosition.get(position).contains(mQuery)) { view.setVisibility(View.GONE); LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(0,1); @@ -180,13 +181,14 @@ public class NotesListAdapter extends CursorAdapter { protected void onContentChanged() { super.onContentChanged(); calcNotesCount(); + updateSnippetMap(); // 在数据发生改变时更新 Snippet 到 Position 的映射 } @Override public void changeCursor(Cursor cursor) { super.changeCursor(cursor); calcNotesCount(); - updateSnippetMap(); + updateSnippetMap(); // 在数据发生改变时更新 Snippet 到 Position 的映射 } private void updateSnippetMap() {