Source:
<code>public void init(MonthDescriptor month, List<List<MonthCellDescriptor>> cells) { Logr.d("Initializing MonthView (%d) for %s", System.identityHashCode(this), month); long start = System.currentTimeMillis(); title.setText(month.getLabel()); final int numRows = cells.size(); grid.setNumRows(numRows); for (int i = 0; i < 6; i++) { CalendarRowView weekRow = (CalendarRowView) grid.getChildAt(i + 1); weekRow.setListener(listener); if (i < numRows) { weekRow.setVisibility(VISIBLE); List<MonthCellDescriptor> week = cells.get(i); for (int c = 0; c < week.size(); c++) { MonthCellDescriptor cell = week.get(c); CalendarCellView cellView = (CalendarCellView) weekRow.getChildAt(c); <START> if (cellView != null) { <END> cellView.setText(Integer.toString(cell.getValue())); cellView.setEnabled(cell.isCurrentMonth()); cellView.setBackgroundResource(R.drawable.calendar_bg_selector); if (cell.isToday()) { cellView.setTextColor(getContext().getResources().getColor(R.color.calendar_text_selected)); } else { cellView.setTextColor(getContext().getResources().getColor(R.color.calendar_text_active)); } if (cell.getEvent() != null) { cellView.setBackgroundResource(cell.getEvent().getColor()); cellView.setTextColor(getContext().getResources().getColor(android.R.color.white)); } cellView.setSelectable(cell.isSelectable()); cellView.setSelected(cell.isSelected()); cellView.setCurrentMonth(cell.isCurrentMonth()); cellView.setToday(cell.isToday()); cellView.setRangeState(cell.getRangeState()); cellView.setTag(cell); } } } else { weekRow.setVisibility(GONE); } } Logr.d("MonthView.init took %d ms", System.currentTimeMillis() - start); }</code><technical_language>changed this needs null checked</technical_language>

Target:
public void init(MonthDescriptor month, List<List<MonthCellDescriptor>> cells) { Logr.d("Initializing MonthView (%d) for %s", System.identityHashCode(this), month); long start = System.currentTimeMillis(); title.setText(month.getLabel()); final int numRows = cells.size(); grid.setNumRows(numRows); for (int i = 0; i < 6; i++) { CalendarRowView weekRow = (CalendarRowView) grid.getChildAt(i + 1); weekRow.setListener(listener); if (i < numRows) { weekRow.setVisibility(VISIBLE); List<MonthCellDescriptor> week = cells.get(i); for (int c = 0; c < week.size(); c++) { MonthCellDescriptor cell = week.get(c); CalendarCellView cellView = (CalendarCellView) weekRow.getChildAt(c); cellView.setText(Integer.toString(cell.getValue())); cellView.setEnabled(cell.isCurrentMonth()); cellView.setBackgroundResource(R.drawable.calendar_bg_selector); if (cell.getEvent() != null) { cellView.setBackgroundColor(cell.getEvent().getColor()); cellView.setTextColor(cell.getEvent().getTextColor()); } else { if (cell.isToday()) { cellView.setTextColor( getContext().getResources().getColor(R.color.calendar_text_selected)); } else { cellView.setTextColor( getContext().getResources().getColor(R.color.calendar_text_active)); } } cellView.setSelectable(cell.isSelectable()); cellView.setSelected(cell.isSelected()); cellView.setCurrentMonth(cell.isCurrentMonth()); cellView.setToday(cell.isToday()); cellView.setRangeState(cell.getRangeState()); cellView.setTag(cell); } } else { weekRow.setVisibility(GONE); } } Logr.d("MonthView.init took %d ms", System.currentTimeMillis() - start); }