类android.util.MonthDisplayHelper源码实例Demo

下面列出了怎么用android.util.MonthDisplayHelper的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: BigApp_Discuz_Android   文件: CalendarView.java
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));
}
 
源代码2 项目: 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;
}
 
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();
}
 
源代码7 项目: BonetCalendarView   文件: DayGridAdapter.java
public MonthDisplayHelper getDisplayHelper(){
	return mMonthDisplay;
}
 
源代码8 项目: FlexibleCalendar   文件: 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 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;
}