Google Summer of Code – week # 9

One of the most important and necessary feature for the application is ‘Schedule’ section and as I mentioned in my last week blog post, this week wandered around working on implementation of ‘Schedule’. Though it’s work in progress and may take another week for completing it’s implementation but the basic, most-needed and challenging part is completed. Let’s take a look at this..



Just like the Abstracts, organization had changed the format of Schedule and it’s data model so the previous data-model, JSON Parser and previous implementation wasn’t going to work anymore So, I had to work in Schedule from scratch. The new Schedule Model JSON file can be found online here.  In the new data model, Schedule has 3 different components which you can see in data file too. Let me describe the different schedule components:

1 – EventBasically an Event is what the name says. It can for example be a talk, a coffe break a workshop.
2 – TrackA track is a collection of events (at least one) that happen after each other.
3 – Session: A session is a collection of tracks that might take place at the same time.

This can be bit complicated to understand but here’s the illustration (provided to me by my mentor) on how these are all related:


I hope above posted illustration makes the relation among these components clear. Since we now have 3 different components, I had to make 3 different classes. (each for one schedule component i.e. event, track and schedule). Thus, I created 3 Classes:, and The interesting is here is ‘some nesting in classes’  because Track consists of events so the Track Class has an array of Events (EventScheduleItem) for maintaining the events for the track. And the Session Class has an array of Tracks (TrackScheduleItem) and Track class as I just mentioned has array of Events (EventScheduleItem).  Instead of storing the schedule data into Database after parsing, I stored all the schedule stuff into the 3 Arraylists – each for a schedule component maintaining the events, tracks and sessions. Those arraylists will be populated during the process of JSON parsing.

Besides these 3 classes, I required another class for maintaining the order and relationship of all schedule components as per the data source. That class was required for maintaining the index of schedule item on it’s respective arraylist, that’s to be displayed. For example, after the schedule would be parsed and arraylists will be populated – events have own arraylist holding events one after another but that’s not the case for main schedule. An event can be followed by an Track or Session or vice versa so some sort of mechanism was required that what’s to be fetched next and that’s why I created an class This maintains the type of schedule component, it’s index on respective array and date on that Schedule Components respective ArrayList. This would tell e.g first schedule component is ‘event’ and located on ‘event’s arraylist at index 0’, second schedule component is ‘session’ and located on ‘session’s arraylist at index 3’ etc.

So uptill now, I have talked about the 4 Arraylists that get’s populated while the JSON is being parsed. The ListView adapter get’s the ArrayList of ScheduleItemRecords and then uses that to bring the content to be displayed from it’s respective ArrayList.

Schedule implementation has been most challenging part uptill now. Unfortunately it’s code is much complex and consists of more than Thousand lines so I can’t write that all here. But the Good part is, its done finally :)

All the code is available on Github and you are most welcome to explore and ask me questions if you don’t understand any part of it. Github Link:

Here are the final Screenshots of Schedule section:

As you can sport the ‘Tabbed Layout’ in screenshots above, this was the most challenging part and took most time in implementation of the Schedule. Just to summarize it’s implementation, I first wrote a function for grouping the events according to the Date. And then the ScheduleTabsAdapter manages fetching the respective list of events itself. Once again, because of it’s complexity and little mess I can’t go to it’s whole detail here. The important thing is the function that does grouping of events according to date so here’s code for that function:

void groupEventsByDate() {

	Log.i(LOG_TAG, "in groupEvents func");
	List<String> differentDatesForGroups = new ArrayList<String>();
	int indexOfCurrentDate;

	for(int i=0; i<scheduleRecordsArray.size(); i++) {
		Log.i(LOG_TAG, "in groupEvents func for loop ");
		//get current event record from indexes array
		ScheduleItemRecord temperoryScheduleItem = scheduleRecordsArray.get(i);

		String dateOfCurrentEventItem = temperoryScheduleItem.getEvent_date();

		if(!differentDatesForGroups.contains(dateOfCurrentEventItem)) {
			//if date is not already in record, add it

			indexOfCurrentDate = differentDatesForGroups.size() -1;
		} else {
			//get index of the date
			indexOfCurrentDate = differentDatesForGroups.indexOf(dateOfCurrentEventItem);
		//now check the List of GroupEvents for this Index

		DateWiseEventsRecord tempDateGroup;

		try {
			tempDateGroup = dateWiseEventsRecordList.get(indexOfCurrentDate);
		} catch (IndexOutOfBoundsException e) {
			// TODO: handle exception
			dateWiseEventsRecordList.add(new DateWiseEventsRecord(dateOfCurrentEventItem));
			tempDateGroup = dateWiseEventsRecordList.get(indexOfCurrentDate);

		if(tempDateGroup == null ) {
			dateWiseEventsRecordList.add(new DateWiseEventsRecord(dateOfCurrentEventItem));
			tempDateGroup = dateWiseEventsRecordList.get(indexOfCurrentDate);
		} //end if condition for null

		//add the index of this event item into the group eventsForThisDate

		//Update the main list
		dateWiseEventsRecordList.set(indexOfCurrentDate, tempDateGroup);

	} //end outer for loop - iterating for indexes array
} //end function groupEventsByDate

So that’s all for this week – if you have any question about the code or related, feel free to ask in comments and do share your thoughts and feedback on it in comments below. I’ll be looking forward to any suggestions or feedback.

GSoC Week # 9 – (14 July 2014 – 20 July 2014)

2 thoughts on “Google Summer of Code – week # 9

  1. Why not use iterators instead of for loops?

    for(ScheduleItemRecord temperoryScheduleItem : scheduleRecordsArray){

    Saves you the trouble of declaring temporary variables. 😀

Leave a Reply