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();
}
项目:BonetCalendarView
文件:DayGridAdapter.java
/**
* 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;
}
项目:BonetCalendarView
文件:GridBtMonthViewProvider.java
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);
}
}
};
}
项目:BonetCalendarView
文件:GridBtMonthViewProvider.java
项目:fluidCalendar
文件:FlexibleCalendarGridAdapter.java
项目:fluidCalendar
文件:FlexibleCalendarGridAdapter.java
项目:FlexibleCalendar
文件:FlexibleCalendarGridAdapter.java
public void initialize(int year,startDayOfTheWeek);
this.calendar = FlexibleCalendarHelper.getLocalizedCalendar(context);
}
项目:FlexibleCalendar
文件:FlexibleCalendarGridAdapter.java
项目:BonetCalendarView
文件:DayGridAdapter.java
项目:fluidCalendar
文件:FlexibleCalendarHelper.java
/**
* 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 startDayOfTheWeek) {
Calendar cal = Calendar.getInstance();
cal.set(year,1);
MonthdisplayHelper displayHelper = new MonthdisplayHelper(year,startDayOfTheWeek);
return displayHelper.getRowOf(cal.getActualMaximum(Calendar.DAY_OF_MONTH)) + 1;
}
项目:FlexibleCalendar
文件:FlexibleCalendarHelper.java
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。