<commit_before>// Copyright 2012 Square, Inc.
package com.squareup.calendar;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.Toast;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import static java.util.Calendar.DATE;
import static java.util.Calendar.DAY_OF_MONTH;
import static java.util.Calendar.DAY_OF_WEEK;
import static java.util.Calendar.HOUR_OF_DAY;
import static java.util.Calendar.MILLISECOND;
import static java.util.Calendar.MINUTE;
import static java.util.Calendar.MONTH;
import static java.util.Calendar.SECOND;
import static java.util.Calendar.SUNDAY;
import static java.util.Calendar.YEAR;

/**
 * Android component to allow picking a date from a calendar view (a list of months).  Must be
 * initialized after inflation with {@link #init(java.util.Date, java.util.Date, java.util.Date)}.
 * The currently selected date can be retrieved with {@link #getSelectedDate()} or {@link
 * #getSelectedDateMillis()}.
 */
public class CalendarPickerView extends ListView {
  private final CalendarPickerView.MonthAdapter adapter;
  private final DateFormat monthNameFormat;
  private final DateFormat weekdayNameFormat;
  private final DateFormat fullDateFormat;
  final List<MonthDescriptor> months = new ArrayList<MonthDescriptor>();
  final List<List<List<MonthCellDescriptor>>> cells =
      new ArrayList<List<List<MonthCellDescriptor>>>();

  private MonthCellDescriptor selectedCell;
  final Calendar today = Calendar.getInstance();
  private final Calendar selectedCal = Calendar.getInstance();
  private final Calendar minCal = Calendar.getInstance();
  private final Calendar maxCal = Calendar.getInstance();
  private final Calendar monthCounter = Calendar.getInstance();

  private final MonthView.Listener listener = new CellClickedListener();

  public CalendarPickerView(Context context, AttributeSet attrs) {
    super(context, attrs);
    adapter = new MonthAdapter();
    setDivider(null);
    setDividerHeight(0);
    setAdapter(adapter);
    final int bg = getResources().getColor(R.color.calendar_bg);
    setBackgroundColor(bg);
    setCacheColorHint(bg);
    monthNameFormat = new SimpleDateFormat(context.getString(R.string.month_name_format));
    weekdayNameFormat = new SimpleDateFormat(context.getString(R.string.day_name_format));
    fullDateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
  }

  /**
   * All date parameters must be non-null and their {@link java.util.Date#getTime()} must not
   * return 0.  Time of day will be ignored.  For instance, if you pass in minDate as 11/16/2012
   * 5:15pm and maxDate as 11/16/2013 4:30am, 11/16/2012 will be the first selectable date and
   * 11/15/2013 will be the last selectable date (maxDate is exclusive).
   *
   * @param selectedDate The initially selected date.  Must be between minDate and maxDate.
   * @param minDate The earliest selectable date, inclusive. Must be earlier than maxDate.
   * @param maxDate The latest selectable date, exclusive.  Must be later than minDate.
   */
  public void init(Date selectedDate, Date minDate, Date maxDate) {
    if (selectedDate == null || minDate == null || maxDate == null) {
      throw new IllegalArgumentException(
          "All dates must be non-null.  " + dbg(selectedDate, minDate, maxDate));
    }
    if (selectedDate.getTime() == 0 || minDate.getTime() == 0 || maxDate.getTime() == 0) {
      throw new IllegalArgumentException(
          "All dates must be non-zero.  " + dbg(selectedDate, minDate, maxDate));
    }
    if (minDate.after(maxDate)) {<commit_msg>Doc tweaks.<commit_after>// Copyright 2012 Square, Inc.
package com.squareup.calendar;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.Toast;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import static java.util.Calendar.DATE;
import static java.util.Calendar.DAY_OF_MONTH;
import static java.util.Calendar.DAY_OF_WEEK;
import static java.util.Calendar.HOUR_OF_DAY;
import static java.util.Calendar.MILLISECOND;
import static java.util.Calendar.MINUTE;
import static java.util.Calendar.MONTH;
import static java.util.Calendar.SECOND;
import static java.util.Calendar.SUNDAY;
import static java.util.Calendar.YEAR;

/**
 * Android component to allow picking a date from a calendar view (a list of months).  Must be
 * initialized after inflation with {@link #init(java.util.Date, java.util.Date, java.util.Date)}.
 * The currently selected date can be retrieved with {@link #getSelectedDate()} or {@link
 * #getSelectedDateMillis()}.
 */
public class CalendarPickerView extends ListView {
  private final CalendarPickerView.MonthAdapter adapter;
  private final DateFormat monthNameFormat;
  private final DateFormat weekdayNameFormat;
  private final DateFormat fullDateFormat;
  final List<MonthDescriptor> months = new ArrayList<MonthDescriptor>();
  final List<List<List<MonthCellDescriptor>>> cells =
      new ArrayList<List<List<MonthCellDescriptor>>>();

  private MonthCellDescriptor selectedCell;
  final Calendar today = Calendar.getInstance();
  private final Calendar selectedCal = Calendar.getInstance();
  private final Calendar minCal = Calendar.getInstance();
  private final Calendar maxCal = Calendar.getInstance();
  private final Calendar monthCounter = Calendar.getInstance();

  private final MonthView.Listener listener = new CellClickedListener();

  public CalendarPickerView(Context context, AttributeSet attrs) {
    super(context, attrs);
    adapter = new MonthAdapter();
    setDivider(null);
    setDividerHeight(0);
    setAdapter(adapter);
    final int bg = getResources().getColor(R.color.calendar_bg);
    setBackgroundColor(bg);
    setCacheColorHint(bg);
    monthNameFormat = new SimpleDateFormat(context.getString(R.string.month_name_format));
    weekdayNameFormat = new SimpleDateFormat(context.getString(R.string.day_name_format));
    fullDateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
  }

  /**
   * All date parameters must be non-null and their {@link java.util.Date#getTime()} must not
   * return 0.  Time of day will be ignored.  For instance, if you pass in {@code minDate} as
   * 11/16/2012 5:15pm and {@code maxDate} as 11/16/2013 4:30am, 11/16/2012 will be the first
   * selectable date and 11/15/2013 will be the last selectable date ({@code maxDate} is exclusive).
   *
   * @param selectedDate Initially selected date.  Must be between {@code minDate} and
  *                      {@code maxDate}.
   * @param minDate Earliest selectable date, inclusive.  Must be earlier than {@code maxDate}.
   * @param maxDate Latest selectable date, exclusive.  Must be later than {@code minDate}.
   */
  public void init(Date selectedDate, Date minDate, Date maxDate) {
    if (selectedDate == null || minDate == null || maxDate == null) {
      throw new IllegalArgumentException(
          "All dates must be non-null.  " + dbg(selectedDate, minDate, maxDate));
    }
    if (selectedDate.getTime() == 0 || minDate.getTime() == 0 || maxDate.getTime() == 0) {
      throw new IllegalArgumentException(
          "All dates must be non-zero.  " + dbg(selectedDate, minDate, maxDate));
    }
    if (minDate.after(maxDate)) {
{'fraction_non_alphanumeric': 0.10002581311306144, 'fraction_numerical': 0.012132163138874549, 'mean_word_length': 4.535, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5625871', 'n_tokens_mistral': 2256, 'n_tokens_neox': 2151, 'n_words': 663}