private void initCalendarView() { mRightNow = Calendar.getInstance(); mHelper = new MonthDisplayHelper(mRightNow.get(Calendar.YEAR), mRightNow.get(Calendar.MONTH), mRightNow.getFirstDayOfWeek()); mBackgroundColor = new Paint(); mBackgroundColorToday = new Paint(); mBackgroundColorTouched = new Paint(); mWeekTitle = new Paint(Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); mLinePaint = new Paint(); mLinePaint2 = new Paint(); mBackgroundColor.setColor(Color.WHITE); mBackgroundColorToday.setColor(Color.RED); mBackgroundColorToday.setAlpha(100); mBackgroundColorTouched.setColor(Color.BLUE); mBackgroundColorTouched.setAlpha(100); mWeekTitle.setColor(Color.rgb(135, 135, 135)); mLinePaint.setColor(Color.BLACK); mLinePaint2.setColor(Color.rgb(90, 90, 90)); }
public final void setDate(Date date) { mCurrentDate = date; Calendar cal = Calendar.getInstance(); cal.setTime(date); MonthDisplayHelper monthHelper = new MonthDisplayHelper(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH)); cal.set(Calendar.DAY_OF_MONTH, monthHelper.getDayAt(0, 0)); if (monthHelper.getDayAt(0, 0) > 1) { cal.add(Calendar.MONTH, -1); } mDates = new CalendarHelper[6 * getAmountDaysInWeek()]; int j = 0; for (int i = 0; i < 6; i++) { int n[] = monthHelper.getDigitsForRow(i); for (int d = 0; d < n.length; d++) { CalendarHelper tmp = new CalendarHelper(cal.getTime(), monthHelper.isWithinCurrentMonth(i, d), i == 0 || i == 6); if (mShowWeekends || (!mShowWeekends && (d > 0 && d < 6))) { mDates[j] = tmp; j++; } cal.add(Calendar.DATE, 1); } } notifyDataSetChanged(); }
/** * Changes the content data to display the given month * @param month */ public void setMonth(BtMonth month) { Log.d("",month+""); mMonth = month; // Starts at Sunday mMonthDisplay = new MonthDisplayHelper(mMonth.getYear(), mMonth.getMonth()); // number of cells is 7 times the row of the last day plus 1. mNumCells = (mMonthDisplay.getRowOf(mMonthDisplay.getNumberOfDaysInMonth())+1) * 7; }
public GridBtMonthViewProvider(Context context, BtMonth month) { super(month); mContext = context; Log.d("", "Criando DayGridAdapter"); mAdapter = new DayGridAdapter(context,month,getMinDate(),getMaxDate()); mMonthDisplay = new MonthDisplayHelper(month.getYear(), month.getMonth()); mGridItemClickedListener = new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapter, View arg1, int position, long arg3) { int fp = mMonthDisplay.getRowOf(1)*7+mMonthDisplay.getColumnOf(1); int lp = fp+ mMonthDisplay.getNumberOfDaysInMonth(); // Checks to see if the position selected represents a date within the month if(position >= fp && position <lp) { BtDate day; // Checks to see if the selected date is within the defined bounds if( (day = getMonth().getDate(position+1-fp)).isWithinBounds(getMinDate(),getMaxDate())) selectDay(day); } } }; }
@Override public void setMonth(BtMonth month) { mMonthDisplay = new MonthDisplayHelper(month.getYear(), month.getMonth()); mAdapter.setMonth(month); super.setMonth(month); }
public void initialize(int year, int month, int startDayOfTheWeek) { this.year = year; this.month = month; this.monthDisplayHelper = new MonthDisplayHelper(year, month, startDayOfTheWeek); this.calendar = FlexibleCalendarHelper.getLocalizedCalendar(context); }
public void setFirstDayOfTheWeek(int firstDayOfTheWeek) { monthDisplayHelper = new MonthDisplayHelper(year, month, firstDayOfTheWeek); this.notifyDataSetChanged(); }
public MonthDisplayHelper getDisplayHelper(){ return mMonthDisplay; }
/** * Get the number of rows for the provided month * * @param year year * @param month month * @return number of rows */ public static int getNumOfRowsForTheMonth(int year, int month, int startDayOfTheWeek) { Calendar cal = Calendar.getInstance(); cal.set(year, month, 1); MonthDisplayHelper displayHelper = new MonthDisplayHelper(year, month, startDayOfTheWeek); return displayHelper.getRowOf(cal.getActualMaximum(Calendar.DAY_OF_MONTH)) + 1; }