1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805
|
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.widget;
import android.annotation.AttrRes;
import android.annotation.ColorInt;
import android.annotation.DrawableRes;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.StyleRes;
import android.annotation.TestApi;
import android.annotation.UnsupportedAppUsage;
import android.annotation.Widget;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.icu.util.Calendar;
import android.icu.util.TimeZone;
import android.util.AttributeSet;
import android.util.Log;
import android.view.inspector.InspectableProperty;
import com.android.internal.R;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
/**
* This class is a calendar widget for displaying and selecting dates. The
* range of dates supported by this calendar is configurable.
* <p>
* The exact appearance and interaction model of this widget may vary between
* OS versions and themes (e.g. Holo versus Material), but in general a user
* can select a date by tapping on it and can scroll or fling the calendar to a
* desired date.
*
* @attr ref android.R.styleable#CalendarView_showWeekNumber
* @attr ref android.R.styleable#CalendarView_firstDayOfWeek
* @attr ref android.R.styleable#CalendarView_minDate
* @attr ref android.R.styleable#CalendarView_maxDate
* @attr ref android.R.styleable#CalendarView_shownWeekCount
* @attr ref android.R.styleable#CalendarView_selectedWeekBackgroundColor
* @attr ref android.R.styleable#CalendarView_focusedMonthDateColor
* @attr ref android.R.styleable#CalendarView_unfocusedMonthDateColor
* @attr ref android.R.styleable#CalendarView_weekNumberColor
* @attr ref android.R.styleable#CalendarView_weekSeparatorLineColor
* @attr ref android.R.styleable#CalendarView_selectedDateVerticalBar
* @attr ref android.R.styleable#CalendarView_weekDayTextAppearance
* @attr ref android.R.styleable#CalendarView_dateTextAppearance
*/
@Widget
public class CalendarView extends FrameLayout {
private static final String LOG_TAG = "CalendarView";
private static final int MODE_HOLO = 0;
private static final int MODE_MATERIAL = 1;
@UnsupportedAppUsage
private final CalendarViewDelegate mDelegate;
/**
* The callback used to indicate the user changes the date.
*/
public interface OnDateChangeListener {
/**
* Called upon change of the selected day.
*
* @param view The view associated with this listener.
* @param year The year that was set.
* @param month The month that was set [0-11].
* @param dayOfMonth The day of the month that was set.
*/
void onSelectedDayChange(@NonNull CalendarView view, int year, int month, int dayOfMonth);
}
public CalendarView(@NonNull Context context) {
this(context, null);
}
public CalendarView(@NonNull Context context, @Nullable AttributeSet attrs) {
this(context, attrs, R.attr.calendarViewStyle);
}
public CalendarView(@NonNull Context context, @Nullable AttributeSet attrs,
@AttrRes int defStyleAttr) {
this(context, attrs, defStyleAttr, 0);
}
public CalendarView(@NonNull Context context, @Nullable AttributeSet attrs,
@AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
final TypedArray a = context.obtainStyledAttributes(
attrs, R.styleable.CalendarView, defStyleAttr, defStyleRes);
saveAttributeDataForStyleable(context, R.styleable.CalendarView,
attrs, a, defStyleAttr, defStyleRes);
final int mode = a.getInt(R.styleable.CalendarView_calendarViewMode, MODE_HOLO);
a.recycle();
switch (mode) {
case MODE_HOLO:
mDelegate = new CalendarViewLegacyDelegate(
this, context, attrs, defStyleAttr, defStyleRes);
break;
case MODE_MATERIAL:
mDelegate = new CalendarViewMaterialDelegate(
this, context, attrs, defStyleAttr, defStyleRes);
break;
default:
throw new IllegalArgumentException("invalid calendarViewMode attribute");
}
}
/**
* Sets the number of weeks to be shown.
*
* @param count The shown week count.
*
* @attr ref android.R.styleable#CalendarView_shownWeekCount
* @deprecated No longer used by Material-style CalendarView.
*/
@Deprecated
public void setShownWeekCount(int count) {
mDelegate.setShownWeekCount(count);
}
/**
* Gets the number of weeks to be shown.
*
* @return The shown week count.
*
* @attr ref android.R.styleable#CalendarView_shownWeekCount
* @deprecated No longer used by Material-style CalendarView.
*/
@InspectableProperty
@Deprecated
public int getShownWeekCount() {
return mDelegate.getShownWeekCount();
}
/**
* Sets the background color for the selected week.
*
* @param color The week background color.
*
* @attr ref android.R.styleable#CalendarView_selectedWeekBackgroundColor
* @deprecated No longer used by Material-style CalendarView.
*/
@Deprecated
public void setSelectedWeekBackgroundColor(@ColorInt int color) {
mDelegate.setSelectedWeekBackgroundColor(color);
}
/**
* Gets the background color for the selected week.
*
* @return The week background color.
*
* @attr ref android.R.styleable#CalendarView_selectedWeekBackgroundColor
* @deprecated No longer used by Material-style CalendarView.
*/
@InspectableProperty
@ColorInt
@Deprecated
public int getSelectedWeekBackgroundColor() {
return mDelegate.getSelectedWeekBackgroundColor();
}
/**
* Sets the color for the dates of the focused month.
*
* @param color The focused month date color.
*
* @attr ref android.R.styleable#CalendarView_focusedMonthDateColor
* @deprecated No longer used by Material-style CalendarView.
*/
@Deprecated
public void setFocusedMonthDateColor(@ColorInt int color) {
mDelegate.setFocusedMonthDateColor(color);
}
/**
* Gets the color for the dates in the focused month.
*
* @return The focused month date color.
*
* @attr ref android.R.styleable#CalendarView_focusedMonthDateColor
* @deprecated No longer used by Material-style CalendarView.
*/
@InspectableProperty
@ColorInt
@Deprecated
public int getFocusedMonthDateColor() {
return mDelegate.getFocusedMonthDateColor();
}
/**
* Sets the color for the dates of a not focused month.
*
* @param color A not focused month date color.
*
* @attr ref android.R.styleable#CalendarView_unfocusedMonthDateColor
* @deprecated No longer used by Material-style CalendarView.
*/
@Deprecated
public void setUnfocusedMonthDateColor(@ColorInt int color) {
mDelegate.setUnfocusedMonthDateColor(color);
}
/**
* Gets the color for the dates in a not focused month.
*
* @return A not focused month date color.
*
* @attr ref android.R.styleable#CalendarView_unfocusedMonthDateColor
* @deprecated No longer used by Material-style CalendarView.
*/
@InspectableProperty
@ColorInt
@Deprecated
public int getUnfocusedMonthDateColor() {
return mDelegate.getUnfocusedMonthDateColor();
}
/**
* Sets the color for the week numbers.
*
* @param color The week number color.
*
* @attr ref android.R.styleable#CalendarView_weekNumberColor
* @deprecated No longer used by Material-style CalendarView.
*/
@Deprecated
public void setWeekNumberColor(@ColorInt int color) {
mDelegate.setWeekNumberColor(color);
}
/**
* Gets the color for the week numbers.
*
* @return The week number color.
*
* @attr ref android.R.styleable#CalendarView_weekNumberColor
* @deprecated No longer used by Material-style CalendarView.
*/
@InspectableProperty
@ColorInt
@Deprecated
public int getWeekNumberColor() {
return mDelegate.getWeekNumberColor();
}
/**
* Sets the color for the separator line between weeks.
*
* @param color The week separator color.
*
* @attr ref android.R.styleable#CalendarView_weekSeparatorLineColor
* @deprecated No longer used by Material-style CalendarView.
*/
@Deprecated
public void setWeekSeparatorLineColor(@ColorInt int color) {
mDelegate.setWeekSeparatorLineColor(color);
}
/**
* Gets the color for the separator line between weeks.
*
* @return The week separator color.
*
* @attr ref android.R.styleable#CalendarView_weekSeparatorLineColor
* @deprecated No longer used by Material-style CalendarView.
*/
@ColorInt
@Deprecated
@InspectableProperty
public int getWeekSeparatorLineColor() {
return mDelegate.getWeekSeparatorLineColor();
}
/**
* Sets the drawable for the vertical bar shown at the beginning and at
* the end of the selected date.
*
* @param resourceId The vertical bar drawable resource id.
*
* @attr ref android.R.styleable#CalendarView_selectedDateVerticalBar
* @deprecated No longer used by Material-style CalendarView.
*/
@Deprecated
public void setSelectedDateVerticalBar(@DrawableRes int resourceId) {
mDelegate.setSelectedDateVerticalBar(resourceId);
}
/**
* Sets the drawable for the vertical bar shown at the beginning and at
* the end of the selected date.
*
* @param drawable The vertical bar drawable.
*
* @attr ref android.R.styleable#CalendarView_selectedDateVerticalBar
* @deprecated No longer used by Material-style CalendarView.
*/
@Deprecated
public void setSelectedDateVerticalBar(Drawable drawable) {
mDelegate.setSelectedDateVerticalBar(drawable);
}
/**
* Gets the drawable for the vertical bar shown at the beginning and at
* the end of the selected date.
*
* @return The vertical bar drawable.
* @deprecated No longer used by Material-style CalendarView.
*/
@InspectableProperty
@Deprecated
public Drawable getSelectedDateVerticalBar() {
return mDelegate.getSelectedDateVerticalBar();
}
/**
* Sets the text appearance for the week day abbreviation of the calendar header.
*
* @param resourceId The text appearance resource id.
*
* @attr ref android.R.styleable#CalendarView_weekDayTextAppearance
*/
public void setWeekDayTextAppearance(@StyleRes int resourceId) {
mDelegate.setWeekDayTextAppearance(resourceId);
}
/**
* Gets the text appearance for the week day abbreviation of the calendar header.
*
* @return The text appearance resource id.
*
* @attr ref android.R.styleable#CalendarView_weekDayTextAppearance
*/
@InspectableProperty
public @StyleRes int getWeekDayTextAppearance() {
return mDelegate.getWeekDayTextAppearance();
}
/**
* Sets the text appearance for the calendar dates.
*
* @param resourceId The text appearance resource id.
*
* @attr ref android.R.styleable#CalendarView_dateTextAppearance
*/
public void setDateTextAppearance(@StyleRes int resourceId) {
mDelegate.setDateTextAppearance(resourceId);
}
/**
* Gets the text appearance for the calendar dates.
*
* @return The text appearance resource id.
*
* @attr ref android.R.styleable#CalendarView_dateTextAppearance
*/
@InspectableProperty
public @StyleRes int getDateTextAppearance() {
return mDelegate.getDateTextAppearance();
}
/**
* Gets the minimal date supported by this {@link CalendarView} in milliseconds
* since January 1, 1970 00:00:00 in {@link TimeZone#getDefault()} time
* zone.
* <p>
* Note: The default minimal date is 01/01/1900.
* <p>
*
* @return The minimal supported date.
*
* @attr ref android.R.styleable#CalendarView_minDate
*/
@InspectableProperty
public long getMinDate() {
return mDelegate.getMinDate();
}
/**
* Sets the minimal date supported by this {@link CalendarView} in milliseconds
* since January 1, 1970 00:00:00 in {@link TimeZone#getDefault()} time
* zone.
*
* @param minDate The minimal supported date.
*
* @attr ref android.R.styleable#CalendarView_minDate
*/
public void setMinDate(long minDate) {
mDelegate.setMinDate(minDate);
}
/**
* Gets the maximal date supported by this {@link CalendarView} in milliseconds
* since January 1, 1970 00:00:00 in {@link TimeZone#getDefault()} time
* zone.
* <p>
* Note: The default maximal date is 01/01/2100.
* <p>
*
* @return The maximal supported date.
*
* @attr ref android.R.styleable#CalendarView_maxDate
*/
@InspectableProperty
public long getMaxDate() {
return mDelegate.getMaxDate();
}
/**
* Sets the maximal date supported by this {@link CalendarView} in milliseconds
* since January 1, 1970 00:00:00 in {@link TimeZone#getDefault()} time
* zone.
*
* @param maxDate The maximal supported date.
*
* @attr ref android.R.styleable#CalendarView_maxDate
*/
public void setMaxDate(long maxDate) {
mDelegate.setMaxDate(maxDate);
}
/**
* Sets whether to show the week number.
*
* @param showWeekNumber True to show the week number.
* @deprecated No longer used by Material-style CalendarView.
*
* @attr ref android.R.styleable#CalendarView_showWeekNumber
*/
@Deprecated
public void setShowWeekNumber(boolean showWeekNumber) {
mDelegate.setShowWeekNumber(showWeekNumber);
}
/**
* Gets whether to show the week number.
*
* @return True if showing the week number.
* @deprecated No longer used by Material-style CalendarView.
*
* @attr ref android.R.styleable#CalendarView_showWeekNumber
*/
@InspectableProperty
@Deprecated
public boolean getShowWeekNumber() {
return mDelegate.getShowWeekNumber();
}
/**
* Gets the first day of week.
*
* @return The first day of the week conforming to the {@link CalendarView}
* APIs.
* @see Calendar#MONDAY
* @see Calendar#TUESDAY
* @see Calendar#WEDNESDAY
* @see Calendar#THURSDAY
* @see Calendar#FRIDAY
* @see Calendar#SATURDAY
* @see Calendar#SUNDAY
*
* @attr ref android.R.styleable#CalendarView_firstDayOfWeek
*/
@InspectableProperty
public int getFirstDayOfWeek() {
return mDelegate.getFirstDayOfWeek();
}
/**
* Sets the first day of week.
*
* @param firstDayOfWeek The first day of the week conforming to the
* {@link CalendarView} APIs.
* @see Calendar#MONDAY
* @see Calendar#TUESDAY
* @see Calendar#WEDNESDAY
* @see Calendar#THURSDAY
* @see Calendar#FRIDAY
* @see Calendar#SATURDAY
* @see Calendar#SUNDAY
*
* @attr ref android.R.styleable#CalendarView_firstDayOfWeek
*/
public void setFirstDayOfWeek(int firstDayOfWeek) {
mDelegate.setFirstDayOfWeek(firstDayOfWeek);
}
/**
* Sets the listener to be notified upon selected date change.
*
* @param listener The listener to be notified.
*/
public void setOnDateChangeListener(OnDateChangeListener listener) {
mDelegate.setOnDateChangeListener(listener);
}
/**
* Gets the selected date in milliseconds since January 1, 1970 00:00:00 in
* {@link TimeZone#getDefault()} time zone.
*
* @return The selected date.
*/
public long getDate() {
return mDelegate.getDate();
}
/**
* Sets the selected date in milliseconds since January 1, 1970 00:00:00 in
* {@link TimeZone#getDefault()} time zone.
*
* @param date The selected date.
*
* @throws IllegalArgumentException of the provided date is before the
* minimal or after the maximal date.
*
* @see #setDate(long, boolean, boolean)
* @see #setMinDate(long)
* @see #setMaxDate(long)
*/
public void setDate(long date) {
mDelegate.setDate(date);
}
/**
* Sets the selected date in milliseconds since January 1, 1970 00:00:00 in
* {@link TimeZone#getDefault()} time zone.
*
* @param date The date.
* @param animate Whether to animate the scroll to the current date.
* @param center Whether to center the current date even if it is already visible.
*
* @throws IllegalArgumentException of the provided date is before the
* minimal or after the maximal date.
*
* @see #setMinDate(long)
* @see #setMaxDate(long)
*/
public void setDate(long date, boolean animate, boolean center) {
mDelegate.setDate(date, animate, center);
}
/**
* Retrieves the screen bounds for the specific date in the coordinate system of this
* view. If the passed date is being currently displayed, this method returns true and
* the caller can query the fields of the passed {@link Rect} object. Otherwise the
* method returns false and does not touch the passed {@link Rect} object.
*
* @hide
*/
@TestApi
public boolean getBoundsForDate(long date, Rect outBounds) {
return mDelegate.getBoundsForDate(date, outBounds);
}
@Override
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
mDelegate.onConfigurationChanged(newConfig);
}
@Override
public CharSequence getAccessibilityClassName() {
return CalendarView.class.getName();
}
/**
* A delegate interface that defined the public API of the CalendarView. Allows different
* CalendarView implementations. This would need to be implemented by the CalendarView delegates
* for the real behavior.
*/
private interface CalendarViewDelegate {
void setShownWeekCount(int count);
int getShownWeekCount();
void setSelectedWeekBackgroundColor(@ColorInt int color);
@ColorInt int getSelectedWeekBackgroundColor();
void setFocusedMonthDateColor(@ColorInt int color);
@ColorInt int getFocusedMonthDateColor();
void setUnfocusedMonthDateColor(@ColorInt int color);
@ColorInt int getUnfocusedMonthDateColor();
void setWeekNumberColor(@ColorInt int color);
@ColorInt int getWeekNumberColor();
void setWeekSeparatorLineColor(@ColorInt int color);
@ColorInt int getWeekSeparatorLineColor();
void setSelectedDateVerticalBar(@DrawableRes int resourceId);
void setSelectedDateVerticalBar(Drawable drawable);
Drawable getSelectedDateVerticalBar();
void setWeekDayTextAppearance(@StyleRes int resourceId);
@StyleRes int getWeekDayTextAppearance();
void setDateTextAppearance(@StyleRes int resourceId);
@StyleRes int getDateTextAppearance();
void setMinDate(long minDate);
long getMinDate();
void setMaxDate(long maxDate);
long getMaxDate();
void setShowWeekNumber(boolean showWeekNumber);
boolean getShowWeekNumber();
void setFirstDayOfWeek(int firstDayOfWeek);
int getFirstDayOfWeek();
void setDate(long date);
void setDate(long date, boolean animate, boolean center);
long getDate();
boolean getBoundsForDate(long date, Rect outBounds);
void setOnDateChangeListener(OnDateChangeListener listener);
void onConfigurationChanged(Configuration newConfig);
}
/**
* An abstract class which can be used as a start for CalendarView implementations
*/
abstract static class AbstractCalendarViewDelegate implements CalendarViewDelegate {
/** The default minimal date. */
protected static final String DEFAULT_MIN_DATE = "01/01/1900";
/** The default maximal date. */
protected static final String DEFAULT_MAX_DATE = "01/01/2100";
protected CalendarView mDelegator;
protected Context mContext;
protected Locale mCurrentLocale;
AbstractCalendarViewDelegate(CalendarView delegator, Context context) {
mDelegator = delegator;
mContext = context;
// Initialization based on locale
setCurrentLocale(Locale.getDefault());
}
protected void setCurrentLocale(Locale locale) {
if (locale.equals(mCurrentLocale)) {
return;
}
mCurrentLocale = locale;
}
@Override
public void setShownWeekCount(int count) {
// Deprecated.
}
@Override
public int getShownWeekCount() {
// Deprecated.
return 0;
}
@Override
public void setSelectedWeekBackgroundColor(@ColorInt int color) {
// Deprecated.
}
@ColorInt
@Override
public int getSelectedWeekBackgroundColor() {
return 0;
}
@Override
public void setFocusedMonthDateColor(@ColorInt int color) {
// Deprecated.
}
@ColorInt
@Override
public int getFocusedMonthDateColor() {
return 0;
}
@Override
public void setUnfocusedMonthDateColor(@ColorInt int color) {
// Deprecated.
}
@ColorInt
@Override
public int getUnfocusedMonthDateColor() {
return 0;
}
@Override
public void setWeekNumberColor(@ColorInt int color) {
// Deprecated.
}
@ColorInt
@Override
public int getWeekNumberColor() {
// Deprecated.
return 0;
}
@Override
public void setWeekSeparatorLineColor(@ColorInt int color) {
// Deprecated.
}
@ColorInt
@Override
public int getWeekSeparatorLineColor() {
// Deprecated.
return 0;
}
@Override
public void setSelectedDateVerticalBar(@DrawableRes int resId) {
// Deprecated.
}
@Override
public void setSelectedDateVerticalBar(Drawable drawable) {
// Deprecated.
}
@Override
public Drawable getSelectedDateVerticalBar() {
// Deprecated.
return null;
}
@Override
public void setShowWeekNumber(boolean showWeekNumber) {
// Deprecated.
}
@Override
public boolean getShowWeekNumber() {
// Deprecated.
return false;
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
// Nothing to do here, configuration changes are already propagated
// by ViewGroup.
}
}
/** String for parsing dates. */
private static final String DATE_FORMAT = "MM/dd/yyyy";
/** Date format for parsing dates. */
private static final DateFormat DATE_FORMATTER = new SimpleDateFormat(DATE_FORMAT);
/**
* Utility method for the date format used by CalendarView's min/max date.
*
* @hide Use only as directed. For internal use only.
*/
public static boolean parseDate(String date, Calendar outDate) {
if (date == null || date.isEmpty()) {
return false;
}
try {
final Date parsedDate = DATE_FORMATTER.parse(date);
outDate.setTime(parsedDate);
return true;
} catch (ParseException e) {
Log.w(LOG_TAG, "Date: " + date + " not in format: " + DATE_FORMAT);
return false;
}
}
}
|