use of android.icu.util.Calendar in project android_frameworks_base by ResurrectionRemix.
the class CalendarViewLegacyDelegate method setMaxDate.
@Override
public void setMaxDate(long maxDate) {
mTempDate.setTimeInMillis(maxDate);
if (isSameDate(mTempDate, mMaxDate)) {
return;
}
mMaxDate.setTimeInMillis(maxDate);
// reinitialize the adapter since its range depends on max date
mAdapter.init();
Calendar date = mAdapter.mSelectedDate;
if (date.after(mMaxDate)) {
setDate(mMaxDate.getTimeInMillis());
} else {
// we go to the current date to force the ListView to query its
// adapter for the shown views since we have changed the adapter
// range and the base from which the later calculates item indices
// note that calling setDate will not work since the date is the same
goTo(date, false, true, false);
}
}
use of android.icu.util.Calendar in project android_frameworks_base by ResurrectionRemix.
the class DatePickerSpinnerDelegate method getMaxDate.
@Override
public Calendar getMaxDate() {
final Calendar maxDate = Calendar.getInstance();
maxDate.setTimeInMillis(mCalendarView.getMaxDate());
return maxDate;
}
use of android.icu.util.Calendar in project android_frameworks_base by ResurrectionRemix.
the class DatePickerSpinnerDelegate method getMinDate.
@Override
public Calendar getMinDate() {
final Calendar minDate = Calendar.getInstance();
minDate.setTimeInMillis(mCalendarView.getMinDate());
return minDate;
}
use of android.icu.util.Calendar in project android_frameworks_base by DirtyUnicorns.
the class CalendarViewLegacyDelegate method onScroll.
/**
* Updates the title and selected month if the <code>view</code> has moved to a new
* month.
*/
private void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
WeekView child = (WeekView) view.getChildAt(0);
if (child == null) {
return;
}
// Figure out where we are
long currScroll = view.getFirstVisiblePosition() * child.getHeight() - child.getBottom();
// If we have moved since our last call update the direction
if (currScroll < mPreviousScrollPosition) {
mIsScrollingUp = true;
} else if (currScroll > mPreviousScrollPosition) {
mIsScrollingUp = false;
} else {
return;
}
// Use some hysteresis for checking which month to highlight. This
// causes the month to transition when two full weeks of a month are
// visible when scrolling up, and when the first day in a month reaches
// the top of the screen when scrolling down.
int offset = child.getBottom() < mWeekMinVisibleHeight ? 1 : 0;
if (mIsScrollingUp) {
child = (WeekView) view.getChildAt(SCROLL_HYST_WEEKS + offset);
} else if (offset != 0) {
child = (WeekView) view.getChildAt(offset);
}
if (child != null) {
// Find out which month we're moving into
int month;
if (mIsScrollingUp) {
month = child.getMonthOfFirstWeekDay();
} else {
month = child.getMonthOfLastWeekDay();
}
// And how it relates to our current highlighted month
int monthDiff;
if (mCurrentMonthDisplayed == 11 && month == 0) {
monthDiff = 1;
} else if (mCurrentMonthDisplayed == 0 && month == 11) {
monthDiff = -1;
} else {
monthDiff = month - mCurrentMonthDisplayed;
}
// selected month
if ((!mIsScrollingUp && monthDiff > 0) || (mIsScrollingUp && monthDiff < 0)) {
Calendar firstDay = child.getFirstDay();
if (mIsScrollingUp) {
firstDay.add(Calendar.DAY_OF_MONTH, -DAYS_PER_WEEK);
} else {
firstDay.add(Calendar.DAY_OF_MONTH, DAYS_PER_WEEK);
}
setMonthDisplayed(firstDay);
}
}
mPreviousScrollPosition = currScroll;
mPreviousScrollState = mCurrentScrollState;
}
use of android.icu.util.Calendar in project android_frameworks_base by DirtyUnicorns.
the class CalendarViewLegacyDelegate method setMinDate.
@Override
public void setMinDate(long minDate) {
mTempDate.setTimeInMillis(minDate);
if (isSameDate(mTempDate, mMinDate)) {
return;
}
mMinDate.setTimeInMillis(minDate);
// make sure the current date is not earlier than
// the new min date since the latter is used for
// calculating the indices in the adapter thus
// avoiding out of bounds error
Calendar date = mAdapter.mSelectedDate;
if (date.before(mMinDate)) {
mAdapter.setSelectedDay(mMinDate);
}
// reinitialize the adapter since its range depends on min date
mAdapter.init();
if (date.before(mMinDate)) {
setDate(mTempDate.getTimeInMillis());
} else {
// we go to the current date to force the ListView to query its
// adapter for the shown views since we have changed the adapter
// range and the base from which the later calculates item indices
// note that calling setDate will not work since the date is the same
goTo(date, false, true, false);
}
}
Aggregations