Skip to content

Commit 4cd57ae

Browse files
authored
Merge pull request #165 from Telephone2019/work
Work
2 parents 0968fa1 + 0e671ab commit 4cd57ae

File tree

3 files changed

+42
-26
lines changed

3 files changed

+42
-26
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ android {
99
minSdkVersion 26
1010
targetSdkVersion 30
1111
versionCode 3
12-
versionName "3.6"
12+
versionName "3.6.1"
1313

1414
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1515

app/src/main/java/com/telephone/coursetable/FunctionMenu.java

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -445,28 +445,7 @@ public void run() {
445445
runOnUiThread(()->{
446446
parent.expandGroup(groupPosition, true);
447447
// parent.smoothScrollToPositionFromTop(groupPosition, 10);
448-
MainActivity.clearRedPoint(
449-
FunctionMenu.this,
450-
(FrameLayout)v.findViewById(R.id.textView_group_text_frame)
451-
);
452-
List<Entry<String, List<List<String>>>> groups = adapter.getGroups();
453-
String origin_key = groups.get(groupPosition).getKey();
454-
List<List<String>> origin_value = groups.get(groupPosition).getValue();
455-
groups.remove(groupPosition);
456-
groups.add(groupPosition, Map.entry(origin_key.trim(), origin_value));
457-
new Thread(()->{
458-
switch (groupPosition){
459-
case 2: // grades
460-
MyApp.getDb_compare().gradeTotalDao().readAll();
461-
break;
462-
case 5: // exam
463-
MyApp.getDb_compare().examTotalDao().readAll();
464-
break;
465-
default:
466-
// do nothing
467-
break;
468-
}
469-
}).start();
448+
clearUnread(FunctionMenu.this, v, adapter, groupPosition);
470449
});
471450
}).start();
472451
}
@@ -512,6 +491,34 @@ public void onClick(DialogInterface dialog, int which) {
512491
}).start();
513492
}
514493

494+
/**
495+
* must be called from ui thread
496+
*/
497+
public static void clearUnread(@NonNull AppCompatActivity activity, @NonNull View groupView, @NonNull FunctionMenuAdapter functionMenuAdapter, int groupPosition){
498+
MainActivity.clearRedPoint(
499+
activity,
500+
(FrameLayout)groupView.findViewById(R.id.textView_group_text_frame)
501+
);
502+
List<Entry<String, List<List<String>>>> groups = functionMenuAdapter.getGroups();
503+
String origin_key = groups.get(groupPosition).getKey();
504+
List<List<String>> origin_value = groups.get(groupPosition).getValue();
505+
groups.remove(groupPosition);
506+
groups.add(groupPosition, Map.entry(origin_key.trim(), origin_value));
507+
new Thread(()->{
508+
switch (groupPosition){
509+
case 2: // grades
510+
MyApp.getDb_compare().gradeTotalDao().readAll();
511+
break;
512+
case 5: // exam
513+
MyApp.getDb_compare().examTotalDao().readAll();
514+
break;
515+
default:
516+
// do nothing
517+
break;
518+
}
519+
}).start();
520+
}
521+
515522
@Override
516523
public boolean onCreateOptionsMenu(Menu menu) {
517524
MenuInflater inflater = getMenuInflater();

app/src/main/java/com/telephone/coursetable/FunctionMenuAdapter.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ public View getGroupView(int i, boolean isExpanded, View view, ViewGroup viewGro
134134
case 2:
135135
((ImageView)view.findViewById(R.id.group_image)).setImageResource(R.drawable.grades);
136136
if (groups.get(i).getValue().isEmpty()){
137-
view.setOnClickListener(v -> Snackbar.make(v, "成绩单为空", BaseTransientBottomBar.LENGTH_SHORT).setTextColor(Color.WHITE).show());
137+
view.setOnClickListener(v -> {
138+
Snackbar.make(v, "成绩单为空", BaseTransientBottomBar.LENGTH_SHORT).setTextColor(Color.WHITE).show();
139+
FunctionMenu.clearUnread(menu, v, FunctionMenuAdapter.this, i);
140+
});
138141
}
139142
break;
140143
case 3:
@@ -146,7 +149,10 @@ public View getGroupView(int i, boolean isExpanded, View view, ViewGroup viewGro
146149
case 5:
147150
((ImageView)view.findViewById(R.id.group_image)).setImageResource(R.drawable.exam);
148151
if (groups.get(i).getValue().isEmpty()){
149-
view.setOnClickListener(v -> Snackbar.make(v, "暂无考试安排", BaseTransientBottomBar.LENGTH_SHORT).setTextColor(Color.WHITE).show());
152+
view.setOnClickListener(v -> {
153+
Snackbar.make(v, "暂无考试安排", BaseTransientBottomBar.LENGTH_SHORT).setTextColor(Color.WHITE).show();
154+
FunctionMenu.clearUnread(menu, v, FunctionMenuAdapter.this, i);
155+
});
150156
}
151157
break;
152158
case 6:
@@ -155,7 +161,10 @@ public View getGroupView(int i, boolean isExpanded, View view, ViewGroup viewGro
155161
case 7:
156162
((ImageView)view.findViewById(R.id.group_image)).setImageResource(R.drawable.cet);
157163
if (groups.get(i).getValue().isEmpty()){
158-
view.setOnClickListener(v -> Snackbar.make(v, "未查询到等级考试成绩", BaseTransientBottomBar.LENGTH_SHORT).setTextColor(Color.WHITE).show());
164+
view.setOnClickListener(v -> {
165+
Snackbar.make(v, "未查询到等级考试成绩", BaseTransientBottomBar.LENGTH_SHORT).setTextColor(Color.WHITE).show();
166+
FunctionMenu.clearUnread(menu, v, FunctionMenuAdapter.this, i);
167+
});
159168
}
160169
break;
161170
case 8:

0 commit comments

Comments
 (0)