library/src/main/java/com/alamkanak/weekview/WeekView.java
/**
     * Expands all the events to maximum possible width. The events will try to occupy maximum
     * space available horizontally.
     *
     * @param collisionGroup The group of events which overlap with each other.
     */
Expands all the events to maximum possible width. The events will try to occupy maximum
space available horizontally.

@param collisionGroup The group of events which overlap with each other.
Expands all the events to maximum possible width . The events will try to occupy maximum space available horizontally . @param collisionGroup The group of events which overlap with each other .
private void expandEventsToMaxWidth(List<EventRect> collisionGroup) {
        List<List<EventRect>> columns = new ArrayList<List<EventRect>>();
        columns.add(new ArrayList<EventRect>());
        for (EventRect eventRect : collisionGroup) {
            boolean isPlaced = false;
            for (List<EventRect> column : columns) {
                if (column.size() == 0) {
                    column.add(eventRect);
                    isPlaced = true;
                } else if (!isEventsCollide(eventRect.event, column.get(column.size() - 1).event)) {
                    column.add(eventRect);
                    isPlaced = true;
                    break;
                }
            }
            if (!isPlaced) {
                List<EventRect> newColumn = new ArrayList<EventRect>();
                newColumn.add(eventRect);
                columns.add(newColumn);
            }
        }
        int maxRowCount = 0;
        for (List<EventRect> column : columns) {
            maxRowCount = Math.max(maxRowCount, column.size());
        }
        for (int i = 0; i < maxRowCount; i++) {
            float j = 0;
            for (List<EventRect> column : columns) {
                if (column.size() >= i + 1) {
                    EventRect eventRect = column.get(i);
                    eventRect.width = 1f / columns.size();
                    eventRect.left = j / columns.size();
                    if (!eventRect.event.isAllDay()) {
                        eventRect.top = eventRect.event.getStartTime().get(Calendar.HOUR_OF_DAY) * 60 + eventRect.event.getStartTime().get(Calendar.MINUTE);
                        eventRect.bottom = eventRect.event.getDuration();
                    } else {
                        eventRect.top = 0;
                        eventRect.bottom = mAllDayEventHeight - mGridThickness * 2 - mEventMargin * 2;
                    }
                    mEventRects.add(eventRect);
                }
                j++;
            }
        }
    }
private void expandEventsToMaxWidth ( List < EventRect > collisionGroup ) { List < List < EventRect > > columns = new ArrayList < List < EventRect > > ( ) ; columns . add ( new ArrayList < EventRect > ( ) ) ; for ( EventRect eventRect : collisionGroup ) { boolean isPlaced = false ; for ( List < EventRect > column : columns ) { if ( column . size ( ) == 0 ) { column . add ( eventRect ) ; isPlaced = true ; } else if ( ! isEventsCollide ( eventRect . event , column . get ( column . size ( ) - 1 ) . event ) ) { column . add ( eventRect ) ; isPlaced = true ; break ; } } if ( ! isPlaced ) { List < EventRect > newColumn = new ArrayList < EventRect > ( ) ; newColumn . add ( eventRect ) ; columns . add ( newColumn ) ; } } int maxRowCount = 0 ; for ( List < EventRect > column : columns ) { maxRowCount = Math . max ( maxRowCount , column . size ( ) ) ; } for ( int i = 0 ; i < maxRowCount ; i ++ ) { float j = 0 ; for ( List < EventRect > column : columns ) { if ( column . size ( ) >= i + 1 ) { EventRect eventRect = column . get ( i ) ; eventRect . width = 1f / columns . size ( ) ; eventRect . left = j / columns . size ( ) ; if ( ! eventRect . event . isAllDay ( ) ) { eventRect . top = eventRect . event . getStartTime ( ) . get ( Calendar . HOUR_OF_DAY ) * 60 + eventRect . event . getStartTime ( ) . get ( Calendar . MINUTE ) ; eventRect . bottom = eventRect . event . getDuration ( ) ; } else { eventRect . top = 0 ; eventRect . bottom = mAllDayEventHeight - mGridThickness * 2 - mEventMargin * 2 ; } mEventRects . add ( eventRect ) ; } j ++ ; } } }
Expands all the events to maximum possible width.
Expands all the events to maximum possible width .
// Expand the events to maximum possible width. // Calculate left and right position for all the events. // Get the maxRowCount by looking in all columns. // Set the left and right values of the event.