From c05e787672fa4eccf92c044a2be08f05733f1ac0 Mon Sep 17 00:00:00 2001 From: zfman <13937267417@139.com> Date: Mon, 3 Sep 2018 11:07:19 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=AE=8C=E5=96=84=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E7=AE=97=E6=B3=95=EF=BC=8CWeekView=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=AF=B9curWeek=E7=9A=84=E6=A0=A1=E9=AA=8C=EF=BC=8C?= =?UTF-8?q?=E7=A6=81=E6=AD=A2=E8=B6=8A=E7=95=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.idea/caches/build_file_checksums.ser | Bin 589 -> 589 bytes AndroidTimetableView/.idea/misc.xml | 2 +- .../timetable/model/ScheduleSupport.java | 54 +----------------- .../timetable/operater/SimpleOperater.java | 15 +++-- .../zhuangfei/timetable/view/WeekView.java | 3 + .../views/BaseFuncActivity.java | 2 +- 6 files changed, 18 insertions(+), 58 deletions(-) diff --git a/AndroidTimetableView/.idea/caches/build_file_checksums.ser b/AndroidTimetableView/.idea/caches/build_file_checksums.ser index 542884df22577900ca3647baadf31d7f4da3c066..26af507372aeb6476dde98e8f1a78ba31b37ea92 100644 GIT binary patch delta 36 ucmV+<0Nek~1kD7Hm;{|R&TFxpasd$P9D#lG*f)uH0ejul44)8_9s(~dst - + diff --git a/AndroidTimetableView/TimetableView/src/com/zhuangfei/timetable/model/ScheduleSupport.java b/AndroidTimetableView/TimetableView/src/com/zhuangfei/timetable/model/ScheduleSupport.java index 20b6e2f..edfad23 100644 --- a/AndroidTimetableView/TimetableView/src/com/zhuangfei/timetable/model/ScheduleSupport.java +++ b/AndroidTimetableView/TimetableView/src/com/zhuangfei/timetable/model/ScheduleSupport.java @@ -263,48 +263,21 @@ public static List getAllSubjectsWithDay(List scheduleList, */ public static List findSubjects(Schedule subject, List data) { List result = new ArrayList<>(); + if(subject==null||data==null) return result; for (int i = 0; i < data.size(); i++) { Schedule bean = data.get(i); if (bean.getStart() >= subject.getStart() && bean.getStart() < (subject.getStart() + subject.getStep())) result.add(data.get(i)); - } return result; } - /** - * 返回index处的课程,注意他的真实位置可能并不是index - * - * @param curWeek - * @return - */ - public static Schedule findRealSubject(int start, int curWeek, List scheduleList) { - List list = new ArrayList<>(); - for (int i = 0; i < scheduleList.size(); i++) { - Schedule subject = scheduleList.get(i); - if (subject.getStart() == start) { - list.add(subject); - } - } - - for (int i = 0; i < list.size(); i++) { - Schedule temp = list.get(i); - if (isThisWeek(temp, curWeek)) { - return temp; - } - } - if (list.size() > 0) return list.get(0); - return null; - } - /** * 按照上课节次排序 * * @param data */ public static void sortList(List[] data) { - int min; - Schedule tmp; for (int i = 0; i < data.length; i++) sortList(data[i]); } @@ -345,29 +318,11 @@ public static boolean isThisWeek(Schedule subject, int cur_week) { * @return */ public static List fliterSchedule(List data, int curWeek, boolean isShowNotCurWeek) { - List filterData = new ArrayList<>(); - if (data == null) return filterData; - - if (isShowNotCurWeek) filterData = data; - else { - for (Schedule schedule : data) { - if (ScheduleSupport.isThisWeek(schedule, curWeek)) { - filterData.add(schedule); - } - } - } + if (data == null) return new ArrayList<>(); Set result = new HashSet<>(); - for (int i = 0; i < filterData.size(); i++) { - Schedule s = filterData.get(i); - if (s != null) { - s.putExtras("zfman_count", 0); - } - } - if (data.size() >= 1) { result.add(data.get(0)); } - for (int i = 1; i < data.size(); i++) { Schedule s = data.get(i); for (int j = 0; j < i; j++) { @@ -378,11 +333,6 @@ public static List fliterSchedule(List data, int curWeek, bo result.remove(s2); result.add(s); } - } else { - if (ScheduleSupport.isThisWeek(s, curWeek)) { - s.putExtras("zfman_count", (int) (s.getExtras().get("zfman_count")) + 1); - s2.putExtras("zfman_count", (int) (s2.getExtras().get("zfman_count")) + 1); - } } } else { result.add(s); diff --git a/AndroidTimetableView/TimetableView/src/com/zhuangfei/timetable/operater/SimpleOperater.java b/AndroidTimetableView/TimetableView/src/com/zhuangfei/timetable/operater/SimpleOperater.java index 4d28355..1bb1d2a 100644 --- a/AndroidTimetableView/TimetableView/src/com/zhuangfei/timetable/operater/SimpleOperater.java +++ b/AndroidTimetableView/TimetableView/src/com/zhuangfei/timetable/operater/SimpleOperater.java @@ -139,7 +139,7 @@ public void newSlideView(LinearLayout slidelayout) { * @param curWeek 当前周 * @return View */ - private View newItemView(final List data, final Schedule subject, Schedule pre, int i, int curWeek) { + private View newItemView(final List originData, final List data, final Schedule subject, Schedule pre, int i, int curWeek) { //宽高 int width = LinearLayout.LayoutParams.MATCH_PARENT; int height = mView.itemHeight() * subject.getStep() + mView.marTop() * (subject.getStep() - 1); @@ -179,7 +179,14 @@ private View newItemView(final List data, final Schedule subject, Sche gd.setColor(mView.colorPool().getColorAutoWithAlpha(subject.getColorRandom(), mView.itemAlpha())); gd.setCornerRadius(mView.corner(true)); - int count = (int) subject.getExtras().get("zfman_count"); + List clist = ScheduleSupport.findSubjects(subject, originData); + int count =0; + if(clist!=null){ + for(int k=0;k 1) { countTextView.setVisibility(View.VISIBLE); countTextView.setText(count + ""); @@ -196,7 +203,7 @@ private View newItemView(final List data, final Schedule subject, Sche textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - List result = ScheduleSupport.findSubjects(subject, data); + List result = ScheduleSupport.findSubjects(subject, originData); mView.onItemClickListener().onItemClick(v, result); } }); @@ -229,7 +236,7 @@ private void addToLayout(LinearLayout layout, final List data, int cur layout.setTag(filter.size()); for (int i = 0; i < filter.size(); i++) { final Schedule subject = filter.get(i); - View view = newItemView(filter, subject, pre, i, curWeek); + View view = newItemView(data,filter, subject, pre, i, curWeek); if (view != null) { layout.addView(view); pre = subject; diff --git a/AndroidTimetableView/TimetableView/src/com/zhuangfei/timetable/view/WeekView.java b/AndroidTimetableView/TimetableView/src/com/zhuangfei/timetable/view/WeekView.java index 308fdf8..37396dc 100644 --- a/AndroidTimetableView/TimetableView/src/com/zhuangfei/timetable/view/WeekView.java +++ b/AndroidTimetableView/TimetableView/src/com/zhuangfei/timetable/view/WeekView.java @@ -180,6 +180,9 @@ private void initView() { */ @Override public WeekView showView() { + if(curWeek<1) curWeek(1); + if(curWeek>itemCount()) curWeek=itemCount; + container.removeAllViews(); layouts=new ArrayList<>(); textViews=new ArrayList<>(); diff --git a/AndroidTimetableView/app/src/main/java/com/zhuangfei/android_timetableview/views/BaseFuncActivity.java b/AndroidTimetableView/app/src/main/java/com/zhuangfei/android_timetableview/views/BaseFuncActivity.java index f0cc333..59e98b6 100644 --- a/AndroidTimetableView/app/src/main/java/com/zhuangfei/android_timetableview/views/BaseFuncActivity.java +++ b/AndroidTimetableView/app/src/main/java/com/zhuangfei/android_timetableview/views/BaseFuncActivity.java @@ -199,7 +199,7 @@ public void onClick(DialogInterface dialog, int which) { protected void display(List beans) { String str = ""; for (Schedule bean : beans) { - str += bean.getName() + "、"; + str += bean.getName() + ","+bean.getWeekList().toString()+","+bean.getStart()+","+bean.getStep()+"\n"; } Toast.makeText(this, str, Toast.LENGTH_SHORT).show(); } From cef62cfdd364785ecb862440b39cd29fdaddd61d Mon Sep 17 00:00:00 2001 From: zfman <13937267417@139.com> Date: Mon, 3 Sep 2018 11:22:09 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=B8=8A=E6=AC=A1v2.0.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AndroidTimetableView/.idea/misc.xml | 2 +- .../TimetableView/build.gradle | 2 +- .../app/release/app-release.apk | Bin 2204912 -> 2204716 bytes 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AndroidTimetableView/.idea/misc.xml b/AndroidTimetableView/.idea/misc.xml index 8a3b864..0b49cfc 100644 --- a/AndroidTimetableView/.idea/misc.xml +++ b/AndroidTimetableView/.idea/misc.xml @@ -1,7 +1,7 @@ -