private void init() { resetHomeDate();

// Scrolling initialization.
mGestureDetector = new GestureDetectorCompat(context, mGestureListener);
mScroller = new OverScroller(context, new FastOutLinearInInterpolator());

mMinimumFlingVelocity = ViewConfiguration.get(context).getScaledMinimumFlingVelocity();
mScaledTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

// Measure settings for time column.
timeTextPaint.setTextSize(textSize);
timeTextPaint.setColor(headerColumnTextColor);
timeTextPaint.setTypeface(typeface);

Rect rect = new Rect();
String exampleTime = (timeColumnResolution % 60 != 0) ? '00:00 PM' : '00 PM';
timeTextPaint.getTextBounds(exampleTime, 0, exampleTime.length(), rect);
timeTextHeight = rect.height();
initTextTimeWidth();

//handle sideTitleTextPaint
sideTitleTextPaint.setColor(headerColumnTextColor);
sideTitleTextPaint.setTypeface(typeface);
sideTitleTextPaint.setTextSize(headerWeekDayTitleTextSize);
// handle sideSubtitleTextPaint
sideSubtitleTextPaint.setTextSize(headerWeekDaySubtitleTextSize);
sideSubtitleTextPaint.setColor(headerColumnTextColor);
sideSubtitleTextPaint.setTypeface(typeface);

//handle allDaySideTitleTextPaint
allDaySideTitleTextPaint.setTextSize(textSize);
allDaySideTitleTextPaint.setColor(allDaySideTitleTextColor);
allDaySideTitleTextPaint.setTypeface(typeface);

// Measure settings for header row.
//TODO measure the text that will actually be used, based on the locale and dates. Important because various characters might look different.
String sampleText = "ABCDEFGHIKLMNOPQRSTUVWXYZabcdefghiklmnopqrstuvwxyz0123456789";
mHeaderWeekDayTitleTextPaint.setColor(headerColumnTextColor);
mHeaderWeekDayTitleTextPaint.setTextSize(headerWeekDayTitleTextSize);
mHeaderWeekDayTitleTextPaint.setTypeface(typeface);
mHeaderWeekDayTitleTextPaint.getTextBounds(sampleText, 0, sampleText.length(), rect);
headerWeekDayTitleTextHeight = rect.height();

//measure settings for header subtitle
mHeaderWeekDaySubtitleTextPaint.setColor(headerColumnTextColor);
mHeaderWeekDaySubtitleTextPaint.setTextSize(headerWeekDaySubtitleTextSize);
mHeaderWeekDaySubtitleTextPaint.setTypeface(typeface);
mHeaderWeekDaySubtitleTextPaint.getTextBounds(sampleText, 0, sampleText.length(), rect);
headerWeekDaySubtitleTextHeight = rect.height();

// Prepare header background paint.
mHeaderBackgroundPaint.setColor(headerRowBackgroundColor);

// Prepare day background color paint.
mDayBackgroundPaint.setColor(dayBackgroundColor);
mFutureBackgroundPaint.setColor(futureBackgroundColor);
mPastBackgroundPaint.setColor(pastBackgroundColor);
mFutureWeekendBackgroundPaint.setColor(futureWeekendBackgroundColor);
mPastWeekendBackgroundPaint.setColor(pastWeekendBackgroundColor);

// Prepare hour separator color paint.
mHourSeparatorPaint.setStrokeWidth(hourSeparatorHeight);
mHourSeparatorPaint.setColor(hourSeparatorColor);

// Prepare the "now" line color paint
mNowLinePaint.setStrokeWidth(nowLineThickness);
mNowLinePaint.setColor(nowLineColor);

// Prepare today background color paint.
mTodayColumnBackgroundPaint.setColor(todayColumnBackgroundColor);

// Prepare today header text color paint.

mHeaderWeekDayTitleTodayTextPaint.setTextSize(headerWeekDayTitleTextSize);
mHeaderWeekDayTitleTodayTextPaint.setTypeface(typeface);
mHeaderWeekDayTitleTodayTextPaint.setColor(todayHeaderTextColor);

mHeaderWeekDaySubtitleTodayTextPaint.setTextSize(headerWeekDaySubtitleTextSize);
mHeaderWeekDaySubtitleTodayTextPaint.setTypeface(typeface);
mHeaderWeekDaySubtitleTodayTextPaint.setColor(todayHeaderTextColor);

// Prepare event background color.
mEventBackgroundPaint.setColor(Color.rgb(174, 208, 238));
// Prepare empty event background color.
mNewEventBackgroundPaint.setColor(Color.rgb(60, 147, 217));

// Prepare event text size and color.
mEventTextPaint.setColor(eventTextColor);
mEventTextPaint.setTextSize(eventTextSize);
mEventTextPaint.setTypeface(typeface);


// Set default event color.
defaultEventColor = 0xff9fc6e7;
// Set default empty event color.
newEventColor = 0xff3c93d9;

}

Convert Kotlin Class to Java Code: Setting Up Week View

原文地址: https://www.cveoy.top/t/topic/ftNV 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录