add comments

zhengkunpeng_branch
parent 4067865c54
commit 5fc15752f5

@ -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));

@ -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);

@ -40,7 +40,7 @@ public class NotesListAdapter extends CursorAdapter {
private HashMap<Integer, String> 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() {

Loading…
Cancel
Save