diff --git a/library/src/main/java/com/alamkanak/weekview/WeekView.java b/library/src/main/java/com/alamkanak/weekview/WeekView.java index f0ba1add8..9d4ee6079 100755 --- a/library/src/main/java/com/alamkanak/weekview/WeekView.java +++ b/library/src/main/java/com/alamkanak/weekview/WeekView.java @@ -93,9 +93,6 @@ private enum Direction { private Paint mNewEventBackgroundPaint; private float mHeaderColumnWidth; private List mEventRects; - private List mPreviousPeriodEvents; - private List mCurrentPeriodEvents; - private List mNextPeriodEvents; private TextPaint mEventTextPaint; private TextPaint mNewEventTextPaint; private Paint mHeaderColumnBackgroundPaint; @@ -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 previousPeriodEvents = null; - List currentPeriodEvents = null; - List 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 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; } }