<commit_before>/*
 * Copyright 2016-2019 <NAME>
 *
 * 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 com.apps.adrcotfas.goodtime.Util;

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DatePickerDialog;
import android.os.Build;
import android.os.Bundle;
import com.apps.adrcotfas.goodtime.R;

import java.util.Calendar;

import androidx.annotation.NonNull;
import androidx.fragment.app.DialogFragment;

public class DatePickerFragment extends DialogFragment {

    private DatePickerDialog.OnDateSetListener listener;
    private Calendar calendar;

    public DatePickerFragment() {
    }

    public static DatePickerFragment newInstance(DatePickerDialog.OnDateSetListener listener, Calendar calendar) {
        DatePickerFragment dialog = new DatePickerFragment();
        dialog.listener = listener;
        dialog.calendar = calendar;
        return dialog;
    }

    @NonNull
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        if (calendar == null) {
            calendar = Calendar.getInstance();
        }
        int year = calendar.get(Calendar.YEAR);
        int month = calendar.get(Calendar.MONTH);
        int day = calendar.get(Calendar.DAY_OF_MONTH);

        return new DatePickerDialog(
                getActivity(),
                (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                        ? R.style.DialogTheme : AlertDialog.THEME_HOLO_DARK,
                listener, year, month, day);
    }
}<commit_msg>limit DatePicker to "today"<commit_after>/*
 * Copyright 2016-2019 <NAME>
 *
 * 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 com.apps.adrcotfas.goodtime.Util;

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DatePickerDialog;
import android.os.Build;
import android.os.Bundle;
import com.apps.adrcotfas.goodtime.R;

import org.joda.time.LocalDate;

import java.util.Calendar;

import androidx.annotation.NonNull;
import androidx.fragment.app.DialogFragment;

public class DatePickerFragment extends DialogFragment {

    private DatePickerDialog.OnDateSetListener listener;
    private Calendar calendar;

    public DatePickerFragment() {
    }

    public static DatePickerFragment newInstance(DatePickerDialog.OnDateSetListener listener, Calendar calendar) {
        DatePickerFragment dialog = new DatePickerFragment();
        dialog.listener = listener;
        dialog.calendar = calendar;
        return dialog;
    }

    @NonNull
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        if (calendar == null) {
            calendar = Calendar.getInstance();
        }
        int year = calendar.get(Calendar.YEAR);
        int month = calendar.get(Calendar.MONTH);
        int day = calendar.get(Calendar.DAY_OF_MONTH);

        DatePickerDialog d =  new DatePickerDialog(
                getActivity(),
                (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                        ? R.style.DialogTheme : AlertDialog.THEME_HOLO_DARK,
                listener, year, month, day);
        d.getDatePicker().setMaxDate(new LocalDate().toDateTimeAtStartOfDay().getMillis());

        return  d;
    }
}
{'fraction_non_alphanumeric': 0.08281917418130043, 'fraction_numerical': 0.005695301376364499, 'mean_word_length': 3.2107892107892106, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7061518', 'n_tokens_mistral': 1133, 'n_tokens_neox': 1094, 'n_words': 338}