From cad24a856969b31ae7cbd4e0870774cf3384865a Mon Sep 17 00:00:00 2001 From: Julien Guerinet Date: Mon, 9 Feb 2015 23:42:31 +0100 Subject: [PATCH 1/2] Fixed crash reported on Google Play, where there was an NPE on the class list. --- .../fragment/ScheduleFragment.java | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/MyMartlet/src/ca/appvelopers/mcgillmobile/fragment/ScheduleFragment.java b/MyMartlet/src/ca/appvelopers/mcgillmobile/fragment/ScheduleFragment.java index 1bc21c2cb..423369672 100644 --- a/MyMartlet/src/ca/appvelopers/mcgillmobile/fragment/ScheduleFragment.java +++ b/MyMartlet/src/ca/appvelopers/mcgillmobile/fragment/ScheduleFragment.java @@ -148,13 +148,7 @@ public View loadView(int orientation){ * @return The starting date */ private DateTime getStartingDate(){ - //Clear the current course list, add the courses that are for this semester - mClassList.clear(); - for(ClassItem classItem : App.getClasses()){ - if(classItem.getTerm().equals(mTerm)){ - mClassList.add(classItem); - } - } + fillClassList(); //Date is by default set to today DateTime date = DateTime.now(); @@ -171,6 +165,19 @@ private DateTime getStartingDate(){ return date; } + /** + * Fills the class list with the current term's classes + */ + private void fillClassList(){ + //Clear the current course list, add the courses that are for this semester + mClassList.clear(); + for(ClassItem classItem : App.getClasses()){ + if(classItem.getTerm().equals(mTerm)){ + mClassList.add(classItem); + } + } + } + //Downloads the list of classes for the given term private void executeClassDownloader(){ new ClassDownloader(mActivity, mTerm){ @@ -196,6 +203,12 @@ protected void onPostExecute(Boolean loadInfo) { public List getClassesForDate(Day day, DateTime date){ List courses = new ArrayList(); + //Make sure the class list is initialized + if(mClassList == null){ + mClassList = new ArrayList(); + fillClassList(); + } + //Go through the list of courses, find which ones have the same day and are for the given date for(ClassItem course : mClassList){ if(course.isForDate(date) && course.getDays().contains(day)){ From ff64c28db4fa42d07beef47e5c750fac67ac8189 Mon Sep 17 00:00:00 2001 From: Julien Guerinet Date: Mon, 9 Feb 2015 23:43:01 +0100 Subject: [PATCH 2/2] Bumped version number. --- MyMartlet/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MyMartlet/AndroidManifest.xml b/MyMartlet/AndroidManifest.xml index 8b2c15251..fc8e2235c 100644 --- a/MyMartlet/AndroidManifest.xml +++ b/MyMartlet/AndroidManifest.xml @@ -1,7 +1,7 @@