java类android.util.MonthDisplayHelper的实例源码

CalendarView.java 文件源码 项目:BigApp_Discuz_Android 阅读 50 收藏 0 点赞 0 评论 0
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));
}
CalendarAdapter.java 文件源码 项目:CustomizableCalendarView 阅读 28 收藏 0 点赞 0 评论 0
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();
}
DayGridAdapter.java 文件源码 项目:BonetCalendarView 阅读 29 收藏 0 点赞 0 评论 0
/**
 * 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;
}
GridBtMonthViewProvider.java 文件源码 项目:BonetCalendarView 阅读 26 收藏 0 点赞 0 评论 0
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);

            }
        }
    };

}
GridBtMonthViewProvider.java 文件源码 项目:BonetCalendarView 阅读 26 收藏 0 点赞 0 评论 0
@Override
public void setMonth(BtMonth month) {
    mMonthDisplay = new MonthDisplayHelper(month.getYear(), month.getMonth());

    mAdapter.setMonth(month);

    super.setMonth(month);
}
FlexibleCalendarGridAdapter.java 文件源码 项目:fluidCalendar 阅读 30 收藏 0 点赞 0 评论 0
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);
}
FlexibleCalendarGridAdapter.java 文件源码 项目:fluidCalendar 阅读 26 收藏 0 点赞 0 评论 0
public void setFirstDayOfTheWeek(int firstDayOfTheWeek) {
    monthDisplayHelper = new MonthDisplayHelper(year, month, firstDayOfTheWeek);
    this.notifyDataSetChanged();
}
FlexibleCalendarGridAdapter.java 文件源码 项目:FlexibleCalendar 阅读 24 收藏 0 点赞 0 评论 0
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);
}
FlexibleCalendarGridAdapter.java 文件源码 项目:FlexibleCalendar 阅读 28 收藏 0 点赞 0 评论 0
public void setFirstDayOfTheWeek(int firstDayOfTheWeek) {
    monthDisplayHelper = new MonthDisplayHelper(year, month, firstDayOfTheWeek);
    this.notifyDataSetChanged();
}
DayGridAdapter.java 文件源码 项目:BonetCalendarView 阅读 28 收藏 0 点赞 0 评论 0
public MonthDisplayHelper getDisplayHelper(){
    return mMonthDisplay;
}
FlexibleCalendarHelper.java 文件源码 项目:fluidCalendar 阅读 30 收藏 0 点赞 0 评论 0
/**
 * 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;
}
FlexibleCalendarHelper.java 文件源码 项目:FlexibleCalendar 阅读 27 收藏 0 点赞 0 评论 0
/**
 * 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;
}


问题


面经


文章

微信
公众号

扫码关注公众号