private void remeasure(int width,int height){
  MAX_UNEXPANDED_ALLDAY_HEIGHT=(int)(MIN_UNEXPANDED_ALLDAY_EVENT_HEIGHT * 4);
  MAX_UNEXPANDED_ALLDAY_HEIGHT=Math.min(MAX_UNEXPANDED_ALLDAY_HEIGHT,height / 6);
  MAX_UNEXPANDED_ALLDAY_HEIGHT=Math.max(MAX_UNEXPANDED_ALLDAY_HEIGHT,(int)MIN_UNEXPANDED_ALLDAY_EVENT_HEIGHT * 2);
  mMaxUnexpandedAlldayEventCount=(int)(MAX_UNEXPANDED_ALLDAY_HEIGHT / MIN_UNEXPANDED_ALLDAY_EVENT_HEIGHT);
  for (int day=0; day < mNumDays; day++) {
    mEarliestStartHour[day]=25;
    mHasAllDayEvent[day]=false;
  }
  int maxAllDayEvents=mMaxAlldayEvents;
  mMinCellHeight=Math.max((height - DAY_HEADER_HEIGHT) / 24,(int)MIN_EVENT_HEIGHT);
  if (mCellHeight < mMinCellHeight) {
    mCellHeight=mMinCellHeight;
  }
  mFirstCell=DAY_HEADER_HEIGHT;
  int allDayHeight=0;
  if (maxAllDayEvents > 0) {
    int maxAllAllDayHeight=height - DAY_HEADER_HEIGHT - MIN_HOURS_HEIGHT;
    if (maxAllDayEvents == 1) {
      allDayHeight=SINGLE_ALLDAY_HEIGHT;
    }
 else     if (maxAllDayEvents <= mMaxUnexpandedAlldayEventCount) {
      allDayHeight=maxAllDayEvents * MAX_HEIGHT_OF_ONE_ALLDAY_EVENT;
      if (allDayHeight > MAX_UNEXPANDED_ALLDAY_HEIGHT) {
        allDayHeight=MAX_UNEXPANDED_ALLDAY_HEIGHT;
      }
    }
 else {
      if (mAnimateDayHeight != 0) {
        allDayHeight=Math.max(mAnimateDayHeight,MAX_UNEXPANDED_ALLDAY_HEIGHT);
      }
 else {
        allDayHeight=(int)(maxAllDayEvents * MIN_UNEXPANDED_ALLDAY_EVENT_HEIGHT);
        if (!mShowAllAllDayEvents && allDayHeight > MAX_UNEXPANDED_ALLDAY_HEIGHT) {
          allDayHeight=(int)(mMaxUnexpandedAlldayEventCount * MIN_UNEXPANDED_ALLDAY_EVENT_HEIGHT);
        }
 else         if (allDayHeight > maxAllAllDayHeight) {
          allDayHeight=maxAllAllDayHeight;
        }
      }
    }
    mFirstCell=DAY_HEADER_HEIGHT + allDayHeight + ALLDAY_TOP_MARGIN;
  }
 else {
    mSelectionAllday=false;
  }
  mAlldayHeight=allDayHeight;
  mGridAreaHeight=height - mFirstCell;
  int allDayIconWidth=mExpandAlldayDrawable.getIntrinsicWidth();
  mExpandAllDayRect.left=Math.max((mHoursWidth - allDayIconWidth) / 2,EVENT_ALL_DAY_TEXT_LEFT_MARGIN);
  mExpandAllDayRect.right=Math.min(mExpandAllDayRect.left + allDayIconWidth,mHoursWidth - EVENT_ALL_DAY_TEXT_RIGHT_MARGIN);
  mExpandAllDayRect.bottom=mFirstCell - EXPAND_ALL_DAY_BOTTOM_MARGIN;
  mExpandAllDayRect.top=mExpandAllDayRect.bottom - mExpandAlldayDrawable.getIntrinsicHeight();
  mNumHours=mGridAreaHeight / (mCellHeight + HOUR_GAP);
  mEventGeometry.setHourHeight(mCellHeight);
  final long minimumDurationMillis=(long)(MIN_EVENT_HEIGHT * DateUtils.MINUTE_IN_MILLIS / (mCellHeight / 60.0f));
  Event.computePositions(mEvents,minimumDurationMillis);
  mMaxViewStartY=HOUR_GAP + 24 * (mCellHeight + HOUR_GAP) - mGridAreaHeight;
  if (DEBUG) {
    Log.e(TAG,"mViewStartY: " + mViewStartY);
    Log.e(TAG,"mMaxViewStartY: " + mMaxViewStartY);
  }
  if (mViewStartY > mMaxViewStartY) {
    mViewStartY=mMaxViewStartY;
    computeFirstHour();
  }
  if (mFirstHour == -1) {
    initFirstHour();
    mFirstHourOffset=0;
  }
  if (mFirstHourOffset >= mCellHeight + HOUR_GAP) {
    mFirstHourOffset=mCellHeight + HOUR_GAP - 1;
  }
  mViewStartY=mFirstHour * (mCellHeight + HOUR_GAP) - mFirstHourOffset;
  final int eventAreaWidth=mNumDays * (mCellWidth + DAY_GAP);
  if (mSelectedEvent != null && mLastPopupEventID != mSelectedEvent.id) {
    mPopup.dismiss();
  }
  mPopup.setWidth(eventAreaWidth - 20);
  mPopup.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
}

private void remeasure ( int width , int height ) { MAX_UNEXPANDED_ALLDAY_HEIGHT = ( int ) ( MIN_UNEXPANDED_ALLDAY_EVENT_HEIGHT * 4 ) ; MAX_UNEXPANDED_ALLDAY_HEIGHT = Math . min ( MAX_UNEXPANDED_ALLDAY_HEIGHT , height / 6 ) ; MAX_UNEXPANDED_ALLDAY_HEIGHT = Math . max ( MAX_UNEXPANDED_ALLDAY_HEIGHT , ( int ) MIN_UNEXPANDED_ALLDAY_EVENT_HEIGHT * 2 ) ; mMaxUnexpandedAlldayEventCount = ( int ) ( MAX_UNEXPANDED_ALLDAY_HEIGHT / MIN_UNEXPANDED_ALLDAY_EVENT_HEIGHT ) ; for ( int day = 0 ; day < mNumDays ; day ++ ) { mEarliestStartHour [ day ] = 25 ; mHasAllDayEvent [ day ] = false ; } int maxAllDayEvents = mMaxAlldayEvents ; mMinCellHeight = Math . max ( ( height - DAY_HEADER_HEIGHT ) / 24 , ( int ) MIN_EVENT_HEIGHT ) ; if ( mCellHeight < mMinCellHeight ) { mCellHeight = mMinCellHeight ; } mFirstCell = DAY_HEADER_HEIGHT ; int allDayHeight = 0 ; if ( maxAllDayEvents > 0 ) { int maxAllAllDayHeight = height - DAY_HEADER_HEIGHT - MIN_HOURS_HEIGHT ; if ( maxAllDayEvents == 1 ) { allDayHeight = SINGLE_ALLDAY_HEIGHT ; } else if ( maxAllDayEvents <= mMaxUnexpandedAlldayEventCount ) { allDayHeight = maxAllDayEvents * MAX_HEIGHT_OF_ONE_ALLDAY_EVENT ; if ( allDayHeight > MAX_UNEXPANDED_ALLDAY_HEIGHT ) { allDayHeight = MAX_UNEXPANDED_ALLDAY_HEIGHT ; } } else { if ( mAnimateDayHeight != 0 ) { allDayHeight = Math . max ( mAnimateDayHeight , MAX_UNEXPANDED_ALLDAY_HEIGHT ) ; } else { allDayHeight = ( int ) ( maxAllDayEvents * MIN_UNEXPANDED_ALLDAY_EVENT_HEIGHT ) ; if ( ! mShowAllAllDayEvents && allDayHeight > MAX_UNEXPANDED_ALLDAY_HEIGHT ) { allDayHeight = ( int ) ( mMaxUnexpandedAlldayEventCount * MIN_UNEXPANDED_ALLDAY_EVENT_HEIGHT ) ; } else if ( allDayHeight > maxAllAllDayHeight ) { allDayHeight = maxAllAllDayHeight ; } } } mFirstCell = DAY_HEADER_HEIGHT + allDayHeight + ALLDAY_TOP_MARGIN ; } else { mSelectionAllday = false ; } mAlldayHeight = allDayHeight ; mGridAreaHeight = height - mFirstCell ; int allDayIconWidth = mExpandAlldayDrawable . getIntrinsicWidth ( ) ; mExpandAllDayRect . left = Math . max ( ( mHoursWidth - allDayIconWidth ) / 2 , EVENT_ALL_DAY_TEXT_LEFT_MARGIN ) ; mExpandAllDayRect . right = Math . min ( mExpandAllDayRect . left + allDayIconWidth , mHoursWidth - EVENT_ALL_DAY_TEXT_RIGHT_MARGIN ) ; mExpandAllDayRect . bottom = mFirstCell - EXPAND_ALL_DAY_BOTTOM_MARGIN ; mExpandAllDayRect . top = mExpandAllDayRect . bottom - mExpandAlldayDrawable . getIntrinsicHeight ( ) ; mNumHours = mGridAreaHeight / ( mCellHeight + HOUR_GAP ) ; mEventGeometry . setHourHeight ( mCellHeight ) ; final long minimumDurationMillis = ( long ) ( MIN_EVENT_HEIGHT * DateUtils . MINUTE_IN_MILLIS / ( mCellHeight / 60.0f ) ) ; Event . computePositions ( mEvents , minimumDurationMillis ) ; mMaxViewStartY = HOUR_GAP + 24 * ( mCellHeight + HOUR_GAP ) - mGridAreaHeight ; if ( DEBUG ) { Log . e ( TAG , "mViewStartY: " + mViewStartY ) ; Log . e ( TAG , "mMaxViewStartY: " + mMaxViewStartY ) ; } if ( mViewStartY > mMaxViewStartY ) { mViewStartY = mMaxViewStartY ; computeFirstHour ( ) ; } if ( mFirstHour == - 1 ) { initFirstHour ( ) ; mFirstHourOffset = 0 ; } if ( mFirstHourOffset >= mCellHeight + HOUR_GAP ) { mFirstHourOffset = mCellHeight + HOUR_GAP - 1 ; } mViewStartY = mFirstHour * ( mCellHeight + HOUR_GAP ) - mFirstHourOffset ; final int eventAreaWidth = mNumDays * ( mCellWidth + DAY_GAP ) ; if ( mSelectedEvent != null && mLastPopupEventID != mSelectedEvent . id ) { mPopup . dismiss ( ) ; } mPopup . setWidth ( eventAreaWidth - 20 ) ; mPopup . setHeight ( WindowManager . LayoutParams . WRAP_CONTENT ) ; }
measures the space needed for various parts of the view after loading new events . this can change if there are all - day events .
