Skip to content

Commit

Permalink
Merge pull request #18 from zfman/dev
Browse files Browse the repository at this point in the history
v2.0.5完善课程过滤算法
  • Loading branch information
zfman authored Sep 3, 2018
2 parents a21d2fd + fc87507 commit ed8324b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
Binary file modified AndroidTimetableView/.idea/caches/build_file_checksums.ser
Binary file not shown.
2 changes: 1 addition & 1 deletion AndroidTimetableView/TimetableView/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ publish {
repoName='Maven'
groupId = 'com.zhuangfei'//jcenter上的路径
artifactId = 'TimetableView'//项目名称
publishVersion = '2.0.4'//版本号
publishVersion = '2.0.5'//版本号
desc = 'A beautiful Android based curriculum schedule widget'//描述,不重要
website = 'https://github.com/zfman/TimetableView'//网站,不重要;尽量模拟github上的地址,例如我这样的;当然你有地址最好了
}
Original file line number Diff line number Diff line change
Expand Up @@ -320,24 +320,34 @@ public static boolean isThisWeek(Schedule subject, int cur_week) {
public static List<Schedule> fliterSchedule(List<Schedule> data, int curWeek, boolean isShowNotCurWeek) {
if (data == null) return new ArrayList<>();
Set<Schedule> result = new HashSet<>();
if (data.size() >= 1) {

if(!isShowNotCurWeek){
List<Schedule> filter=new ArrayList<>();
for(int i=0;i<data.size();i++){
Schedule s=data.get(i);
if(ScheduleSupport.isThisWeek(s,curWeek)) filter.add(s);
}
data=filter;
}
if(data.size()>=1){
result.add(data.get(0));
}
for (int i = 1; i < data.size(); i++) {
Schedule s = data.get(i);
boolean is=true;
for (int j = 0; j < i; j++) {
Schedule s2 = data.get(j);
if (s.getStart() <= (s2.getStart() + s2.getStep() - 1)) {
if (!ScheduleSupport.isThisWeek(s2, curWeek)) {
if (ScheduleSupport.isThisWeek(s, curWeek)) {
result.remove(s2);
result.add(s);
}
if(s.getStart()>=s2.getStart()&&s.getStart()<=(s2.getStart()+s2.getStep()-1)){
is=false;
if(isThisWeek(s2,curWeek)){
break;
}else if(isThisWeek(s,curWeek)){
result.remove(s2);
result.add(s);
}
} else {
result.add(s);
}
}
if(is) result.add(s);
}
List<Schedule> list = new ArrayList<>(result);
sortList(list);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,11 @@ private void addToLayout(LinearLayout layout, final List<Schedule> data, int cur
layout.removeAllViews();

//遍历
Schedule pre = data.get(0);
List<Schedule> filter = ScheduleSupport.fliterSchedule(data, curWeek,mView.isShowNotCurWeek());
layout.setTag(filter.size());
Schedule pre=null;
if(filter.size()>0){
pre = filter.get(0);
}
for (int i = 0; i < filter.size(); i++) {
final Schedule subject = filter.get(i);
View view = newItemView(data,filter, subject, pre, i, curWeek);
Expand Down Expand Up @@ -358,6 +360,7 @@ public void showView() {
initPanel();
}

mView.hideFlaglayout();
LinearLayout.LayoutParams lp=new LinearLayout.LayoutParams(mView.monthWidth(), LinearLayout.LayoutParams.MATCH_PARENT);
weekPanel.setLayoutParams(lp);
flagLayout.setBackgroundColor(mView.flagBgcolor());
Expand Down
Binary file modified AndroidTimetableView/app/release/app-release.apk
Binary file not shown.

0 comments on commit ed8324b

Please sign in to comment.