<commit_before>package com.vikashkothary.life.ui.creation;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;

import com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment;
import com.codetroopers.betterpickers.radialtimepicker.RadialTimePickerDialogFragment;
import com.vikashkothary.life.R;
import com.vikashkothary.life.data.model.Reminder;
import com.vikashkothary.life.ui.base.BaseActivity;
import com.vikashkothary.life.ui.base.BaseFragment;

import java.util.Calendar;

import butterknife.BindView;
import butterknife.ButterKnife;


/**
 * A placeholder fragment containing a simple view.
 */
public class NewReminderFragment extends BaseFragment implements CalendarDatePickerDialogFragment.OnDateSetListener, View.OnClickListener, RadialTimePickerDialogFragment.OnTimeSetListener {

    private static final String FRAG_TAG_DATE_PICKER = "date_picker_dialog_fragment";
    private static final String FRAG_TAG_TIME_PICKER = "time_picker_dialog_fragment";

    private Calendar mCalendar = Calendar.getInstance();

    @BindView(R.id.edit_text_message)
    EditText mMessageEditText;
    @BindView(R.id.button_date)
    Button mDateButton;
    @BindView(R.id.button_time)
    Button mTimeButton;

    public static void attachFragment(BaseActivity activity) {
        NewReminderFragment fragment = new NewReminderFragment();
        activity.setFragment(fragment);
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ((BaseActivity) getActivity()).activityComponent().inject(this);
        setHasOptionsMenu(true);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View fragmentView = inflater.inflate(R.layout.fragment_new_reminder, container, false);
        ButterKnife.bind(this, fragmentView);

        getActivity().setTitle(R.string.title_fragment_new_reminder);

        mDateButton.setOnClickListener(this);
        mTimeButton.setOnClickListener(this);

        return fragmentView;
    }

    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        super.onCreateOptionsMenu(menu, inflater);
        inflater.inflate(R.menu.options_creation, menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.action_save:
                Reminder r = Reminder.builder()
                        .setMessage(mMessageEditText.getText().toString())
                        .setDatetime(mCalendar.getTime())
                        .build();
                return false;
            default:
                return super.onOptionsItemSelected(item);
        }
    }

    public void onClick(View v) {
        Calendar today = Calendar.getInstance();
        switch (v.getId()) {
            case R.id.button_date:
                CalendarDatePickerDialogFragment cdp = new CalendarDatePickerDialogFragment()
                        .setOnDateSetListener(NewReminderFragment.this)
                        .setFirstDayOfWeek(Calendar.SUNDAY)
                        .setPreselectedDate(today.get(Calendar.YEAR), today.get(Calendar.MONTH), today.get(Calendar.DAY_OF_MONTH))
                        .setDoneText("Yay")
                        .setCancelText("Nope")
                        .setThemeDark();
                cdp.show(getFragmentManager(), FRAG_TAG_DATE_PICKER);<commit_msg>Use butterknife onclick listener<commit_after>package com.vikashkothary.life.ui.creation;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;

import com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment;
import com.codetroopers.betterpickers.radialtimepicker.RadialTimePickerDialogFragment;
import com.vikashkothary.life.R;
import com.vikashkothary.life.data.model.Reminder;
import com.vikashkothary.life.ui.base.BaseActivity;
import com.vikashkothary.life.ui.base.BaseFragment;

import java.util.Calendar;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;


/**
 * A placeholder fragment containing a simple view.
 */
public class NewReminderFragment extends BaseFragment implements CalendarDatePickerDialogFragment.OnDateSetListener, View.OnClickListener, RadialTimePickerDialogFragment.OnTimeSetListener {

    private static final String FRAG_TAG_DATE_PICKER = "date_picker_dialog_fragment";
    private static final String FRAG_TAG_TIME_PICKER = "time_picker_dialog_fragment";

    private Calendar mCalendar = Calendar.getInstance();

    @BindView(R.id.edit_text_message)
    EditText mMessageEditText;
    @BindView(R.id.button_date)
    Button mDateButton;
    @BindView(R.id.button_time)
    Button mTimeButton;

    public static void attachFragment(BaseActivity activity) {
        NewReminderFragment fragment = new NewReminderFragment();
        activity.setFragment(fragment);
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ((BaseActivity) getActivity()).activityComponent().inject(this);
        setHasOptionsMenu(true);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View fragmentView = inflater.inflate(R.layout.fragment_new_reminder, container, false);
        ButterKnife.bind(this, fragmentView);

        getActivity().setTitle(R.string.title_fragment_new_reminder);

        return fragmentView;
    }

    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        super.onCreateOptionsMenu(menu, inflater);
        inflater.inflate(R.menu.options_creation, menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.action_save:
                Reminder r = Reminder.builder()
                        .setMessage(mMessageEditText.getText().toString())
                        .setDatetime(mCalendar.getTime())
                        .build();
                return false;
            default:
                return super.onOptionsItemSelected(item);
        }
    }

    @OnClick({R.id.button_date, R.id.button_time})
    public void onClick(View v) {
        Calendar today = Calendar.getInstance();
        switch (v.getId()) {
            case R.id.button_date:
                CalendarDatePickerDialogFragment cdp = new CalendarDatePickerDialogFragment()
                        .setOnDateSetListener(NewReminderFragment.this)
                        .setFirstDayOfWeek(Calendar.SUNDAY)
                        .setPreselectedDate(today.get(Calendar.YEAR), today.get(Calendar.MONTH), today.get(Calendar.DAY_OF_MONTH))
                        .setDoneText("Yay")
                        .setCancelText("Nope")
                        .setThemeDark();
                cdp.show(getFragmentManager(), FRAG_TAG_DATE_PICKER);
{'fraction_non_alphanumeric': 0.08614481930924123, 'fraction_numerical': 0.0, 'mean_word_length': 3.0628385698808236, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4233771', 'n_tokens_mistral': 2108, 'n_tokens_neox': 2002, 'n_words': 354}