Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoobergs committed Aug 6, 2017
2 parents 0336166 + 67d4ee3 commit d5db640
Showing 1 changed file with 2 additions and 38 deletions.
40 changes: 2 additions & 38 deletions library/src/main/java/com/alamkanak/weekview/WeekView.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ private enum Direction {
private Paint mNewEventBackgroundPaint;
private float mHeaderColumnWidth;
private List<EventRect> mEventRects;
private List<? extends WeekViewEvent> mPreviousPeriodEvents;
private List<? extends WeekViewEvent> mCurrentPeriodEvents;
private List<? extends WeekViewEvent> mNextPeriodEvents;
private TextPaint mEventTextPaint;
private TextPaint mNewEventTextPaint;
private Paint mHeaderColumnBackgroundPaint;
Expand Down Expand Up @@ -1246,52 +1243,19 @@ private void getMoreEvents(Calendar day) {
// If a refresh was requested then reset some variables.
if (mRefreshEvents) {
mEventRects.clear();
mPreviousPeriodEvents = null;
mCurrentPeriodEvents = null;
mNextPeriodEvents = null;
mFetchedPeriod = -1;
}

if (mWeekViewLoader != null){
int periodToFetch = (int) mWeekViewLoader.toWeekViewPeriodIndex(day);
if (!isInEditMode() && (mFetchedPeriod < 0 || mFetchedPeriod != periodToFetch || mRefreshEvents)) {
List<? extends WeekViewEvent> previousPeriodEvents = null;
List<? extends WeekViewEvent> currentPeriodEvents = null;
List<? extends WeekViewEvent> nextPeriodEvents = null;

if (mPreviousPeriodEvents != null && mCurrentPeriodEvents != null && mNextPeriodEvents != null){
if (periodToFetch == mFetchedPeriod-1){
currentPeriodEvents = mPreviousPeriodEvents;
nextPeriodEvents = mCurrentPeriodEvents;
}
else if (periodToFetch == mFetchedPeriod){
previousPeriodEvents = mPreviousPeriodEvents;
currentPeriodEvents = mCurrentPeriodEvents;
nextPeriodEvents = mNextPeriodEvents;
}
else if (periodToFetch == mFetchedPeriod+1){
previousPeriodEvents = mCurrentPeriodEvents;
currentPeriodEvents = mNextPeriodEvents;
}
}
if (currentPeriodEvents == null)
currentPeriodEvents = mWeekViewLoader.onLoad(periodToFetch);
if (previousPeriodEvents == null)
previousPeriodEvents = mWeekViewLoader.onLoad(periodToFetch-1);
if (nextPeriodEvents == null)
nextPeriodEvents = mWeekViewLoader.onLoad(periodToFetch+1);

List<? extends WeekViewEvent> newEvents = mWeekViewLoader.onLoad(periodToFetch);

// Clear events.
mEventRects.clear();
sortAndCacheEvents(previousPeriodEvents);
sortAndCacheEvents(currentPeriodEvents);
sortAndCacheEvents(nextPeriodEvents);
sortAndCacheEvents(newEvents);
calculateHeaderHeight();

mPreviousPeriodEvents = previousPeriodEvents;
mCurrentPeriodEvents = currentPeriodEvents;
mNextPeriodEvents = nextPeriodEvents;
mFetchedPeriod = periodToFetch;
}
}
Expand Down

0 comments on commit d5db640

Please sign in to comment.