wlx_real_branch
王岚馨 1 year ago
parent 7fd470c603
commit 20c7adb309

@ -0,0 +1,29 @@
g
java:S1301"KReplace this "switch" statement by "if" statements to increase readability.(öÛ«°þÿÿÿÿ
X
java:S18749"=Remove this use of "FLAG_SHOW_WHEN_LOCKED"; it is deprecated.(÷±µÁúÿÿÿÿ
Q
java:S1874=";Remove this use of "FLAG_TURN_SCREEN_ON"; it is deprecated.(ƒìýè
Z
java:S1874?"?Remove this use of "FLAG_LAYOUT_INSET_DECOR"; it is deprecated.(‹”‡Ñúÿÿÿÿ
H
java:S1874["2Remove this use of "isScreenOn"; it is deprecated.(¤® ²
O
java:S1874e":Remove this use of "setAudioStreamType"; it is deprecated.(¡Ìé0
U
java:S1874g":Remove this use of "setAudioStreamType"; it is deprecated.(†Å¨ªùÿÿÿÿ
`
java:S2147q"ECombine this catch with the one at line 110, which has the same body.(ÿëÛßúÿÿÿÿ
[
java:S2147t"ECombine this catch with the one at line 113, which has the same body.(‚ùïÄ
[
java:S2147w"ECombine this catch with the one at line 116, which has the same body.(ï­£Ä
M
java:S1135o"2Complete the task associated to this TODO comment.(ÕÌ<C395>®þÿÿÿÿ
M
java:S1135r"2Complete the task associated to this TODO comment.(ÕÌ<C395>®þÿÿÿÿ
M
java:S1135u"2Complete the task associated to this TODO comment.(ÕÌ<C395>®þÿÿÿÿ
M
java:S1135x"2Complete the task associated to this TODO comment.(ÕÌ<C395>®þÿÿÿÿ

@ -0,0 +1,11 @@
t
java:S2293)"YReplace the type specification in this constructor call with the diamond operator ("<>").(<28>½ñäÿÿÿÿÿ
P
java:S1118":Add a private constructor to hide the implicit public one.(ãÛÒÛ
q
java:S3252!"VUse static access with "android.provider.ContactsContract$DataColumns" for "MIMETYPE".(‡ù¯–ÿÿÿÿÿ
r
java:S3252""\Use static access with "android.provider.ContactsContract$DataColumns" for "RAW_CONTACT_ID".(Ðäç÷
t
java:S32524"^Use static access with "android.provider.ContactsContract$ContactsColumns" for "DISPLAY_NAME".(Úÿ†Ø

@ -0,0 +1,9 @@
m
java:S37764"RRefactor this method to reduce its Cognitive Complexity from 16 to the 15 allowed.(üßú–ùÿÿÿÿ
O
java:S1874@"9Remove this use of "setTextAppearance"; it is deprecated.(¤ñÝ×
O
java:S1874G"9Remove this use of "setTextAppearance"; it is deprecated.(Á†<C381>ö
O
java:S1874Q"9Remove this use of "setTextAppearance"; it is deprecated.(¤ñÝ×

@ -0,0 +1,16 @@
V java:S125"<This block of commented-out lines of code should be removed.(Í<C38D>¸ýÿÿÿÿ

java:S3008&"eRename this field "GTASK_SYNC_NOTIFICATION_ID" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(ëíÅÍúÿÿÿÿ
L
java:S1874$"1Remove this use of "AsyncTask"; it is deprecated.(¯ÚÔËúÿÿÿÿ
N
java:S3878A"8Remove this array creation and simply pass the elements.(‘Àߎ
M
java:S1874A"7Remove this use of "publishProgress"; it is deprecated.(‘Àߎ
e
java:S1874f"JDon't override a deprecated method or explicitly mark it as "@Deprecated".(ë•·ÿÿÿÿÿ
e
java:S1874n"JDon't override a deprecated method or explicitly mark it as "@Deprecated".(÷ችûÿÿÿÿ
H
java:S1068."2Remove this unused "mNotifiManager" private field.(ºíØÛ

@ -0,0 +1,39 @@
t
java:S22930"YReplace the type specification in this constructor call with the diamond operator ("<>").(àÉ™âùÿÿÿÿ
o
java:S2293d"YReplace the type specification in this constructor call with the diamond operator ("<>").(œ€ÄÑ
o
java:S2293t"YReplace the type specification in this constructor call with the diamond operator ("<>").(¾<>Ȫ
J
java:S1066\"/Merge this if statement with the enclosing one.(ßÚ§µúÿÿÿÿ
ˆ
java:S1319c"mThe return type of this method should be an interface such as "Set" rather than the implementation "HashSet".(“Ÿóßûÿÿÿÿ
ˆ
java:S1319s"mThe return type of this method should be an interface such as "Set" rather than the implementation "HashSet".(•Ñòóýÿÿÿÿ
j
java:S1104*"TMake widgetId a static final constant or non-public and provide accessors if needed.(åÇŽ<C387>
q
java:S1104+"VMake widgetType a static final constant or non-public and provide accessors if needed.(ö漬þÿÿÿÿ
C
java:S5411f"(Use a primitive boolean expression here.(ɯÀÐüÿÿÿÿ
C
java:S5411v"(Use a primitive boolean expression here.(ɯÀÐüÿÿÿÿ
D
java:S5411˜"(Use a primitive boolean expression here.( „Œ¢ùÿÿÿÿ
7
java:S1116,"Remove this empty statement.(ôŸŽìúÿÿÿÿ
D
java:S1874/".Remove this use of "<init>"; it is deprecated.(ÌÖçü
J
java:S2864e"4Iterate over the "entrySet" instead of the "keySet".(਷â
B
java:S1125f"'Remove the unnecessary boolean literal.(ɯÀÐüÿÿÿÿ
J
java:S2864u"4Iterate over the "entrySet" instead of the "keySet".(਷â
B
java:S1125v"'Remove the unnecessary boolean literal.(ɯÀÐüÿÿÿÿ
B
java:S1168ƒ"+Return an empty collection instead of null.(¥¹ï<C2B9>
C
java:S1125˜"'Remove the unnecessary boolean literal.( „Œ¢ùÿÿÿÿ

@ -0,0 +1,13 @@
f
java:S11929"KDefine a constant instead of duplicating this literal "content://" 4 times.(š¨ú¯üÿÿÿÿ
U
java:S11181":Add a private constructor to hide the implicit public one.(ž’Í“úÿÿÿÿ
^
java:S1214@"CMove constants defined in this interfaces to another class or enum.(É⸫úÿÿÿÿ
Z
java:S1214ª"CMove constants defined in this interfaces to another class or enum.(ŠÉôŸ
V
java:S1118ô":Add a private constructor to hide the implicit public one.(<28>ˆþÿÿÿÿ
Q
java:S1118":Add a private constructor to hide the implicit public one.(߀°•

@ -1,72 +1,74 @@
w
java:S2293ˆ"YReplace the type specification in this constructor call with the diamond operator ("<>").(艥ð8—©æÛª1
java:S2293¡"YReplace the type specification in this constructor call with the diamond operator ("<>").(艥ð8Ž³”‚¬1
n
java:S1301"KReplace this "switch" statement by "if" statements to increase readability.(ד¾ñùÿÿÿÿ8ž©æÛª1
java:S1301Ï"KReplace this "switch" statement by "if" statements to increase readability.(ד¾ñùÿÿÿÿ8‘³”‚¬1
>
java:S1116e"Remove this empty statement.(ôŸŽìúÿÿÿÿ8ŪæÛª1
java:S1116e"Remove this empty statement.(ôŸŽìúÿÿÿÿ8ü´”‚¬1
h
java:S1124Œ"EReorder the modifiers to comply with the Java Language Specification.(¹úæµûÿÿÿÿ8ǪæÛª1
java:S1124Œ"EReorder the modifiers to comply with the Java Language Specification.(¹úæµûÿÿÿÿ8ý´”‚¬1
b
java:S1124<18>"EReorder the modifiers to comply with the Java Language Specification.(ìѾk8ǪæÛª1
java:S1124<18>"EReorder the modifiers to comply with the Java Language Specification.(ìѾk8ý´”‚¬1
u
java:S3776¥"RRefactor this method to reduce its Cognitive Complexity from 17 to the 15 allowed.(áé–Þÿÿÿÿÿ8ѪæÛª1
java:S3776¥"RRefactor this method to reduce its Cognitive Complexity from 17 to the 15 allowed.(áé–Þÿÿÿÿÿ8ÿ´”‚¬1
9
java:S3626"Remove this redundant jump.(ûÁÝ…8ѪæÛª1
java:S3626"Remove this redundant jump.(ûÁÝ…8€µ”‚¬1
9
java:S3626º"Remove this redundant jump.(ûÁÝ…8ѪæÛª1
java:S3626º"Remove this redundant jump.(ûÁÝ…8€µ”‚¬1
9
java:S3626Î"Remove this redundant jump.(ûÁÝ…8ÒªæÛª1
java:S3626Î"Remove this redundant jump.(ûÁÝ…8€µ”‚¬1
W
java:S1874¦"9Remove this use of "PreferenceManager"; it is deprecated.(­©Ð8ÕªæÛª1
java:S1874¦"9Remove this use of "PreferenceManager"; it is deprecated.(­©Ð8€µ”‚¬1
a
java:S1874¦"CRemove this use of "getDefaultSharedPreferences"; it is deprecated.(­©Ð8ÖªæÛª1
java:S1874¦"CRemove this use of "getDefaultSharedPreferences"; it is deprecated.(­©Ð8€µ”‚¬1
U
java:S1135À"2Complete the task associated to this TODO comment.(ÕÌ<C395>®þÿÿÿÿ8ÞªæÛª1
java:S1135À"2Complete the task associated to this TODO comment.(ÕÌ<C395>®þÿÿÿÿ8…µ”‚¬1
M
java:S2093ª"*Change this "try" to a try-with-resources.(¡»¢üùÿÿÿÿ8ÞªæÛª1
java:S2093ª"*Change this "try" to a try-with-resources.(¡»¢üùÿÿÿÿ8…µ”‚¬1
v
java:S1450ò"XRemove the "mMoveMenu" field and declare it as a local variable in the relevant methods.(ž¢—ò8ëªæÛª1
java:S1450ò"XRemove the "mMoveMenu" field and declare it as a local variable in the relevant methods.(ž¢—ò8‹µ”‚¬1
u
java:S3252ï"RUse static access with "android.widget.AbsListView" for "MultiChoiceModeListener".(¦Ûî„úÿÿÿÿ8íªæÛª1
java:S3252ï"RUse static access with "android.widget.AbsListView" for "MultiChoiceModeListener".(¦Ûî„úÿÿÿÿ8‹µ”‚¬1
U
java:S1135§"2Complete the task associated to this TODO comment.(» æžÿÿÿÿÿ8«æÛª1
java:S1135«"2Complete the task associated to this TODO comment.(» æžÿÿÿÿÿ8“µ”¬1
U
java:S1135¬"2Complete the task associated to this TODO comment.(» æžÿÿÿÿÿ8Œ«æÛª1
java:S1135°"2Complete the task associated to this TODO comment.(» æžÿÿÿÿÿ8“µ”¬1
\
java:S1874ç"9Remove this use of "getDefaultDisplay"; it is deprecated.(ĸ¬Ìýÿÿÿÿ8—«æÛª1
java:S1874ó"9Remove this use of "getDefaultDisplay"; it is deprecated.(ĸ¬Ìýÿÿÿÿ8œµ”¬1
T
java:S1874è"1Remove this use of "getHeight"; it is deprecated.(·¡ªÃýÿÿÿÿ8˜«æÛª1
java:S1874ô"1Remove this use of "getHeight"; it is deprecated.(·¡ªÃýÿÿÿÿ8œµ”¬1
?
java:S1116ž"Remove this empty statement.(ôŸŽìúÿÿÿÿ8<>«æÛª1
java:S1116ª"Remove this empty statement.(ôŸŽìúÿÿÿÿ8Ÿµ”¬1
p
java:S3776Ý"RRefactor this method to reduce its Cognitive Complexity from 20 to the 15 allowed.(ãìîí8ª«æÛª1
java:S3776ö"RRefactor this method to reduce its Cognitive Complexity from 20 to the 15 allowed.(ãìîí8³µ”¬1
J
java:S1874Þ".Remove this use of "<init>"; it is deprecated.(ýî?8¬«æÛª1
F java:S108ä")Either remove or fill this block of code.(žûÊ¥8°«æÛª1
java:S1874÷".Remove this use of "<init>"; it is deprecated.(ýî?8³µ”¬1
F java:S108ý")Either remove or fill this block of code.(žûÊ¥8´µ”¬1
h
java:S1874<18>"JDon't override a deprecated method or explicitly mark it as "@Deprecated".(§Í¿Â8ö©è߬1
R
java:S1874ÿ"/Remove this use of "execute"; it is deprecated.( å«<C3A5>ûÿÿÿÿ8²«æÛª1
java:S1874˜"/Remove this use of "execute"; it is deprecated.( å«<C3A5>ûÿÿÿÿ8¶µ”¬1
o
java:S3776Ë"RRefactor this method to reduce its Cognitive Complexity from 17 to the 15 allowed.(ÅôÉ#8¾«æÛª1
java:S3776ä"RRefactor this method to reduce its Cognitive Complexity from 17 to the 15 allowed.(ÅôÉ#8¾µ”¬1
U
java:S1135<EFBFBD>"2Complete the task associated to this TODO comment.(» æžÿÿÿÿÿ8Í«æÛª1
java:S1135¦"2Complete the task associated to this TODO comment.(» æžÿÿÿÿÿ8Ƶ”¬1
e
java:S1126"BReplace this if-then-else statement by a single method invocation.(玒¦ýÿÿÿÿ8ΫæÛª1
java:S1126«"BReplace this if-then-else statement by a single method invocation.(玒¦ýÿÿÿÿ8ǵ”¬1
U
java:S1135š"2Complete the task associated to this TODO comment.(» æžÿÿÿÿÿ8ЫæÛª1
java:S1135³"2Complete the task associated to this TODO comment.(» æžÿÿÿÿÿ8ǵ”¬1
Q
java:S1874Â".Remove this use of "<init>"; it is deprecated.(ЧðÛýÿÿÿÿ8æ«æÛª1
java:S1874Û".Remove this use of "<init>"; it is deprecated.(ЧðÛýÿÿÿÿ8Öµ”¬1
m
java:S1874Ê"JDon't override a deprecated method or explicitly mark it as "@Deprecated".(÷ችûÿÿÿÿ8è«æÛª1
java:S1874ã"JDon't override a deprecated method or explicitly mark it as "@Deprecated".(÷ችûÿÿÿÿ8æÊØà¬1
R
java:S1874ç"/Remove this use of "execute"; it is deprecated.( å«<C3A5>ûÿÿÿÿ8í«æÛª1
java:S1874"/Remove this use of "execute"; it is deprecated.( å«<C3A5>ûÿÿÿÿ8Ùµ”¬1
o
java:S3776ö"RRefactor this method to reduce its Cognitive Complexity from 18 to the 15 allowed.(ôŒùb8ó«æÛª1
java:S3776<EFBFBD>"RRefactor this method to reduce its Cognitive Complexity from 18 to the 15 allowed.(ôŒùb8Ûµ”¬1
C
java:S3398Ý"%Move this method into "ModeCallback".(ãìîí8ý«æÛª1
java:S3398ö"%Move this method into "ModeCallback".(ãìîí8ൔ¬1
H
java:S3398<EFBFBD>"%Move this method into "ModeCallback".(“ðÉçýÿÿÿÿ8ý«æÛª1
java:S3398"%Move this method into "ModeCallback".(“ðÉçýÿÿÿÿ8ൔ¬1
R
java:S3398Á"/Move this method into "BackgroundQueryHandler".(—÷õŽüÿÿÿÿ8ý«æÛª1
java:S3398Ú"/Move this method into "BackgroundQueryHandler".(—÷õŽüÿÿÿÿ8ൔ¬1
N
java:S3398<EFBFBD>"0Move this method into "OnListItemClickListener".(‘ðð¡8ý«æÛª1
java:S3398"0Move this method into "OnListItemClickListener".(‘ðð¡8ൔ¬1

@ -0,0 +1,11 @@
s
java:S4144Á"\Update this method so that its implementation is not identical to "getParentId" on line 185.(ø¦¯ÿ
>
java:S1125T"(Remove the unnecessary boolean literals.(ú«€É
m
java:S3776p"RRefactor this method to reduce its Cognitive Complexity from 18 to the 15 allowed.(Ñý¨úýÿÿÿÿ
C
java:S1125q"(Remove the unnecessary boolean literals.(¢´—Öÿÿÿÿÿ
>
java:S1125r"(Remove the unnecessary boolean literals.(ãêÛì

@ -7,3 +7,17 @@ Tapp/src/main/java/com/example/notes_master/src/net/micode/notes/ui/DropdownMenu
build.gradle,f\0\f07866736216be0ee2aba49e392191aeae700a35
@
local.properties,0\7\0712df971a99ac4d2fccb8e0fb19f377f3374cca
<EFBFBD>
Qapp/src/main/java/com/example/notes_master/src/net/micode/notes/data/Contact.java,0\8\08962fe591286696ecd017e3adc4630c1217309b
<EFBFBD>
`app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/remote/GTaskASyncTask.java,1\a\1a4e3da7b86cbac8cbaa0189939fbddcc15fe216
Š
Zapp/src/main/java/com/example/notes_master/src/net/micode/notes/ui/AlarmAlertActivity.java,0\4\0443b0f98e2a8a605b866a1b1bef7e47c8c8ea8e

Tapp/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NoteItemData.java,d\6\d63b8495246ee14beb91a1f887d1ff4a009634d3
ˆ
Xapp/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NotesListAdapter.java,3\2\32e993b9c4de8af917eefa04505aeda3d70c1aff

Oapp/src/main/java/com/example/notes_master/src/net/micode/notes/data/Notes.java,4\1\41b8b7f348f46f3b57551e41c1bbe95463dbc90e

Uapp/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NotesListItem.java,1\9\19661b4b3ff75e064358871f8409e1a1eef63bf6

@ -7,3 +7,17 @@ Tapp/src/main/java/com/example/notes_master/src/net/micode/notes/ui/DropdownMenu
build.gradle,f\0\f07866736216be0ee2aba49e392191aeae700a35
@
local.properties,0\7\0712df971a99ac4d2fccb8e0fb19f377f3374cca
<EFBFBD>
Qapp/src/main/java/com/example/notes_master/src/net/micode/notes/data/Contact.java,0\8\08962fe591286696ecd017e3adc4630c1217309b
<EFBFBD>
`app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/remote/GTaskASyncTask.java,1\a\1a4e3da7b86cbac8cbaa0189939fbddcc15fe216
Š
Zapp/src/main/java/com/example/notes_master/src/net/micode/notes/ui/AlarmAlertActivity.java,0\4\0443b0f98e2a8a605b866a1b1bef7e47c8c8ea8e

Tapp/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NoteItemData.java,d\6\d63b8495246ee14beb91a1f887d1ff4a009634d3

Oapp/src/main/java/com/example/notes_master/src/net/micode/notes/data/Notes.java,4\1\41b8b7f348f46f3b57551e41c1bbe95463dbc90e
ˆ
Xapp/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NotesListAdapter.java,3\2\32e993b9c4de8af917eefa04505aeda3d70c1aff

Uapp/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NotesListItem.java,1\9\19661b4b3ff75e064358871f8409e1a1eef63bf6

@ -218,6 +218,11 @@ public class NoteItemData {
return (mParentId == Notes.ID_CALL_RECORD_FOLDER && !TextUtils.isEmpty(mPhoneNumber));
}
/**
* 便
* @param cursor
* @return
*/
public static int getNoteType(Cursor cursor) {
return cursor.getInt(TYPE_COLUMN);
}

@ -84,9 +84,9 @@ import java.util.HashSet;
public class NotesListActivity extends AppCompatActivity implements OnClickListener, OnItemLongClickListener {
private static final int FOLDER_NOTE_LIST_QUERY_TOKEN = 0;
private static final int FOLDER_NOTE_LIST_QUERY_TOKEN = 0;//查询文件夹中的便签列表
private static final int FOLDER_LIST_QUERY_TOKEN = 1;
private static final int FOLDER_LIST_QUERY_TOKEN = 1;//查询文件夹列表
private static final int MENU_FOLDER_DELETE = 0;
@ -217,17 +217,17 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
private void initResources() {
mContentResolver = this.getContentResolver();
mBackgroundQueryHandler = new BackgroundQueryHandler(this.getContentResolver());
mCurrentFolderId = Notes.ID_ROOT_FOLDER;
mCurrentFolderId = Notes.ID_ROOT_FOLDER;//0
mNotesListView = (ListView) findViewById(R.id.notes_list);
mNotesListView.addFooterView(LayoutInflater.from(this).inflate(R.layout.note_list_footer, null),
null, false);
mNotesListView.setOnItemClickListener(new OnListItemClickListener());
mNotesListView.setOnItemLongClickListener(this);
mNotesListView.setOnItemClickListener(new OnListItemClickListener());//单击监听器
mNotesListView.setOnItemLongClickListener(this);//长按监听器
mNotesListAdapter = new NotesListAdapter(this);
mNotesListView.setAdapter(mNotesListAdapter);
mAddNewNote = (Button) findViewById(R.id.btn_new_note);
mAddNewNote.setOnClickListener(this);
mAddNewNote.setOnTouchListener(new NewNoteOnTouchListener());
mAddNewNote.setOnClickListener(this);//“添加便签”按钮的监听器
mAddNewNote.setOnTouchListener(new NewNoteOnTouchListener());//给按钮绑定自定义的触摸监听器
mDispatch = false;
mDispatchY = 0;
mOriginY = 0;
@ -235,14 +235,15 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
mState = ListEditState.NOTE_LIST;
mModeCallBack = new ModeCallback();
}
//内部类
private class ModeCallback implements ListView.MultiChoiceModeListener, OnMenuItemClickListener {
private DropdownMenu mDropDownMenu;
private ActionMode mActionMode;
private MenuItem mMoveMenu;
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
getMenuInflater().inflate(R.menu.note_list_options, menu);
getMenuInflater().inflate(R.menu.note_list_options, menu);//通过调用 getMenuInflater().inflate() 方法加载菜单布局文件 R.menu.note_list_options
// 并将菜单项添加到 menu 中。
menu.findItem(R.id.delete).setOnMenuItemClickListener(this);
mMoveMenu = menu.findItem(R.id.move);
if (mFocusNoteDataItem.getParentId() == Notes.ID_CALL_RECORD_FOLDER
@ -253,8 +254,8 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
mMoveMenu.setOnMenuItemClickListener(this);
}
mActionMode = mode;
mNotesListAdapter.setChoiceMode(true);
mNotesListView.setLongClickable(false);
mNotesListAdapter.setChoiceMode(true);//设置列表适配器的选择模式为 true以启用多选模式。
mNotesListView.setLongClickable(false);//将列表视图的长按点击功能禁用。
mAddNewNote.setVisibility(View.GONE);
View customView = LayoutInflater.from(NotesListActivity.this).inflate(
@ -274,10 +275,13 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
return true;
}
/**
*
*/
private void updateMenu() {
int selectedCount = mNotesListAdapter.getSelectedCount();
int selectedCount = mNotesListAdapter.getSelectedCount();//多选时选的项数
// Update dropdown menu
String format = getResources().getString(R.string.menu_select_title, selectedCount);
String format = getResources().getString(R.string.menu_select_title, selectedCount);//第二个参数是换第一个参数的占位符的
mDropDownMenu.setTitle(format);
MenuItem item = mDropDownMenu.findItem(R.id.action_select_all);
if (item != null) {
@ -286,7 +290,7 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
item.setTitle(R.string.menu_deselect_all);
} else {
item.setChecked(false);
item.setTitle(R.string.menu_select_all);
item.setTitle(R.string.menu_select_all);//全选
}
}
}
@ -311,6 +315,14 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
mActionMode.finish();
}
/**
* hashmapvalueboolean
* @param mode The {@link ActionMode} providing the selection mode
* @param position Adapter position of the item that was checked or unchecked
* @param id Adapter ID of the item that was checked or unchecked
* @param checked <code>true</code> if the item is now checked, <code>false</code>
* if the item is now unchecked.
*/
public void onItemCheckedStateChanged(ActionMode mode, int position, long id,
boolean checked) {
mNotesListAdapter.setCheckedItem(position, checked);
@ -320,11 +332,11 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
public boolean onMenuItemClick(MenuItem item) {
if (mNotesListAdapter.getSelectedCount() == 0) {
Toast.makeText(NotesListActivity.this, getString(R.string.menu_select_none),
Toast.LENGTH_SHORT).show();
Toast.LENGTH_SHORT).show();//没有选中项,操作无效
return true;
}
switch (item.getItemId()) {
switch (item.getItemId()) {//选中的下拉菜单中的菜单项
case R.id.delete:
AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this);
builder.setTitle(getString(R.string.alert_title_delete));
@ -422,19 +434,32 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
}, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC");
}
/*
线
*/
private final class BackgroundQueryHandler extends AsyncQueryHandler {
public BackgroundQueryHandler(ContentResolver contentResolver) {
super(contentResolver);
}
/**
* token
* cookie
* cursor Cursor
* @param token the token to identify the query, passed in from
* {@link #startQuery}.
* @param cookie the cookie object passed in from {@link #startQuery}.
* @param cursor The cursor holding the results from the query.
*/
@Override
protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
switch (token) {
case FOLDER_NOTE_LIST_QUERY_TOKEN:
case FOLDER_NOTE_LIST_QUERY_TOKEN://0 对文件夹内的笔记列表进行查询操作
mNotesListAdapter.changeCursor(cursor);
break;
case FOLDER_LIST_QUERY_TOKEN:
if (cursor != null && cursor.getCount() > 0) {
case FOLDER_LIST_QUERY_TOKEN://1 对文件夹列表进行查询操作
if (cursor != null && cursor.getCount() > 0) {//有文件夹
showFolderListMenu(cursor);
} else {
Log.e(TAG, "Query folder failed");
@ -448,7 +473,7 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
private void showFolderListMenu(Cursor cursor) {
AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this);
builder.setTitle(R.string.menu_title_select_folder);
builder.setTitle(R.string.menu_title_select_folder);//选择文件夹
final FoldersListAdapter adapter = new FoldersListAdapter(this, cursor);
builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
@ -458,9 +483,9 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
Toast.makeText(
NotesListActivity.this,
getString(R.string.format_move_notes_to_folder,
mNotesListAdapter.getSelectedCount(),
mNotesListAdapter.getSelectedCount(),//选中的要移到的便签数量
adapter.getFolderName(NotesListActivity.this, which)),
Toast.LENGTH_SHORT).show();
Toast.LENGTH_SHORT).show();//当把文件夹中的便签移到文件夹外时显示Toast消息“”已将所选+n+条便签移到上一级文件夹
mModeCallBack.finishActionMode();
}
});
@ -886,21 +911,21 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (view instanceof NotesListItem) {
NoteItemData item = ((NotesListItem) view).getItemData();
if (mNotesListAdapter.isInChoiceMode()) {
if (item.getType() == Notes.TYPE_NOTE) {
if (mNotesListAdapter.isInChoiceMode()) {//处于选择状态
if (item.getType() == Notes.TYPE_NOTE) {//是便签被选中,则修改它的被选择的状态
position = position - mNotesListView.getHeaderViewsCount();
mModeCallBack.onItemCheckedStateChanged(null, position, id,
!mNotesListAdapter.isSelectedItem(position));
}
return;
}
//以下是不处于选择模式
switch (mState) {
case NOTE_LIST:
if (item.getType() == Notes.TYPE_FOLDER
if (item.getType() == Notes.TYPE_FOLDER//是文件夹被选中,则打开文件夹
|| item.getType() == Notes.TYPE_SYSTEM) {
openFolder(item);
} else if (item.getType() == Notes.TYPE_NOTE) {
} else if (item.getType() == Notes.TYPE_NOTE) {//是便签被选中,则打开该便签
openNode(item);
} else {
Log.e(TAG, "Wrong note type in NOTE_LIST");

@ -35,7 +35,7 @@ public class NotesListAdapter extends CursorAdapter {
private static final String TAG = "NotesListAdapter";
private Context mContext;
private HashMap<Integer, Boolean> mSelectedIndex;
private int mNotesCount;
private int mNotesCount;//文件夹外的便签数量
private boolean mChoiceMode;
public static class AppWidgetAttribute {
@ -55,6 +55,13 @@ public class NotesListAdapter extends CursorAdapter {
return new NotesListItem(context);
}
/**
* bindView() Cursor TextViewImageView
* @param view Existing view, returned earlier by newView
* @param context Interface to application's global information
* @param cursor The cursor from which to get the data. The cursor is already
* moved to the correct position.
*/
@Override
public void bindView(View view, Context context, Cursor cursor) {
if (view instanceof NotesListItem) {
@ -128,12 +135,18 @@ public class NotesListAdapter extends CursorAdapter {
return itemSet;
}
/**
*便mSelectedIndexvaluetrue
* @return
*/
public int getSelectedCount() {
Collection<Boolean> values = mSelectedIndex.values();
Collection<Boolean> values = mSelectedIndex.values();//在 HashMap 中,每个键都关联一个值。
// values 方法返回的是所有键值对中的值组成的集合,而不包括键。
// 该集合是一个 Collection 类型,可以遍历、迭代或进行其他操作。
if (null == values) {
return 0;
}
Iterator<Boolean> iter = values.iterator();
Iterator<Boolean> iter = values.iterator();//返回一个迭代器对象Iterator类型用于遍历集合中的元素
int count = 0;
while (iter.hasNext()) {
if (true == iter.next()) {
@ -164,15 +177,15 @@ public class NotesListAdapter extends CursorAdapter {
@Override
public void changeCursor(Cursor cursor) {
super.changeCursor(cursor);
calcNotesCount();
calcNotesCount();//为了给mNotesCount赋值也就是计算出便签数量
}
private void calcNotesCount() {
mNotesCount = 0;
for (int i = 0; i < getCount(); i++) {
mNotesCount = 0;//便签数量先赋为0
for (int i = 0; i < getCount(); i++) {//getCount()方法是CursorAdapter中的方法用于返回游标集中元素个数
Cursor c = (Cursor) getItem(i);
if (c != null) {
if (NoteItemData.getNoteType(c) == Notes.TYPE_NOTE) {
if (NoteItemData.getNoteType(c) == Notes.TYPE_NOTE) {//0。是单纯的便签就便签数量++
mNotesCount++;
}
} else {

Loading…
Cancel
Save