package com.example.todocloud.fragment;

import android.app.DatePickerDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatDialogFragment;
import android.widget.DatePicker;

import com.example.todocloud.R;

import java.util.Calendar;
import java.util.Date;

public class ReminderDatePickerDialogFragment extends AppCompatDialogFragment implements
    DatePickerDialog.OnDateSetListener {

  private int year;
  private int month;
  private int day;
  private Date date;
  private Calendar calendar = Calendar.getInstance();
  private IReminderDatePickerDialogFragment listener;

  @Override
  public void onAttach(Context context) {
    super.onAttach(context);
    listener = (IReminderDatePickerDialogFragment) getTargetFragment();
  }

  /**
   * Létrehoz egy dátumválasztó dialógust az átadott dátum alapján.
   */
  @NonNull
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    date = (Date) getArguments().get("reminderDate");
    calendar.setTime(date);
    year = calendar.get(Calendar.YEAR);
    month = calendar.get(Calendar.MONTH);
    day = calendar.get(Calendar.DAY_OF_MONTH);
    DatePickerDialog datePickerDialog = new DatePickerDialog(
        getActivity(), R.style.MyPickerDialogTheme, this, year, month, day);
    datePickerDialog.setButton(DialogInterface.BUTTON_POSITIVE,
        getString(R.string.btnTime), datePickerDialog);
    datePickerDialog.setButton(DialogInterface.BUTTON_NEGATIVE,
        getString(R.string.btnDeleteReminder), new DialogInterface.OnClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int which) {
        listener.onDeleteReminder();
      }
    });
    return datePickerDialog;
  }

  @Override
  public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
    calendar.set(year, monthOfYear, dayOfMonth);
    date.setTime(calendar.getTimeInMillis());
    listener.onSelectReminderDate(date);
    dismiss();
  }

  public interface IReminderDatePickerDialogFragment {
    void onSelectReminderDate(Date date);
    void onDeleteReminder();
  }

}

@@ -898,88 +898,8 @@
  %7D%0A%0A
-  /**%0A   * L%C3%A9trehoz egy d%C3%A1tumv%C3%A1laszt%C3%B3 dial%C3%B3gust az %C3%A1tadott d%C3%A1tum alapj%C3%A1n.%0A   */%0A
   @N
@@ -905,16 +905,16 @@
 NonNull%0A
+
   @Overr
@@ -1324,19 +1324,195 @@
 nth, day
+%0A    
 );%0A
+    prepareDatePickerDialogButtons(datePickerDialog);%0A    return datePickerDialog;%0A  %7D%0A%0A  private void prepareDatePickerDialogButtons(DatePickerDialog datePickerDialog) %7B%0A
     date
@@ -1526,32 +1526,41 @@
 ialog.setButton(
+%0A        
 DialogInterface.
@@ -1612,16 +1612,24 @@
 tnTime),
+%0A       
  datePic
@@ -1633,24 +1633,29 @@
 PickerDialog
+%0A    
 );%0A    dateP
@@ -1676,16 +1676,25 @@
 tButton(
+%0A        
 DialogIn
@@ -1764,16 +1764,24 @@
 minder),
+%0A       
  new Dia
@@ -1809,24 +1809,29 @@
 istener() %7B%0A
+%0A    
       @Overr
@@ -1834,16 +1834,20 @@
 verride%0A
+    
       pu
@@ -1905,24 +1905,28 @@
 ) %7B%0A        
+    
 listener.onD
@@ -1952,45 +1952,30 @@
     
+   
+ 
 %7D%0A
+%0A  
     
-%7D);
+  %7D
 %0A    
-return datePickerDialog
+)
 ;%0A  

Simplify ReminderDatePickerDialogFragment class