diff --git a/lib/api/parser/ap_parser.dart b/lib/api/parser/ap_parser.dart index 11f8779c..e5bee4b0 100644 --- a/lib/api/parser/ap_parser.dart +++ b/lib/api/parser/ap_parser.dart @@ -428,19 +428,20 @@ Map roomCourseTableQueryParser(dynamic html) { //the second talbe. //make timetable - var secondTable = - document.getElementsByTagName("table")[1].getElementsByTagName("tr"); - try { - //remark:Best split is regex but... Chinese have some difficulty Q_Q - for (int i = 1; i < secondTable.length; i++) { - var _temptext = - secondTable[i].getElementsByTagName('td')[0].text.replaceAll(" ", ""); + var secondTable = document.getElementsByTagName("table"); + if (secondTable.length > 0) + try { + final td = secondTable[1].getElementsByTagName("tr"); + //remark:Best split is regex but... Chinese have some difficulty Q_Q + for (int i = 1; i < td.length; i++) { + var _temptext = + td[i].getElementsByTagName('td')[0].text.replaceAll(" ", ""); - data['coursetable']['timeCodes'].add(_temptext - .substring(0, _temptext.length - 10) - .replaceAll(String.fromCharCode(160), "")); - } - } on Exception catch (e) {} + data['coursetable']['timeCodes'].add(_temptext + .substring(0, _temptext.length - 10) + .replaceAll(String.fromCharCode(160), "")); + } + } on Exception catch (e) {} //make each day. List keyName = [ 'Monday', diff --git a/lib/pages/study/room_course_page.dart b/lib/pages/study/room_course_page.dart index d242775c..ed20c2b8 100644 --- a/lib/pages/study/room_course_page.dart +++ b/lib/pages/study/room_course_page.dart @@ -80,7 +80,10 @@ class _EmptyRoomPageState extends State { onSuccess: (CourseData data) { courseData = data; setState(() { - state = CourseState.finish; + if (courseData.courses.length != 0) + state = CourseState.finish; + else + state = CourseState.empty; }); }, onFailure: (DioError e) async {