// Path: library/src/main/java/com/wada811/android/dialogfragments/interfaces/DialogFragmentInterface.java
// public interface DialogFragmentInterface {
// 
//     String getTag();
// 
//     void show(FragmentManager manager, String tag);
// 
//     int show(FragmentTransaction transaction, String tag);
// 
//     void dismiss();
// 
//     void dismissAllowingStateLoss();
// 
//     Dialog getDialog();
// 
//     DialogFragmentInterface setExtra(Bundle extra);
// 
//     Bundle getExtra();
// 
// }
// 
// Path: library/src/main/java/com/wada811/android/dialogfragments/interfaces/SimpleDialogFragmentCallback.java
// public class SimpleDialogFragmentCallback implements DialogFragmentCallback {
// 
//     @Override
//     public void onShow(DialogFragmentInterface dialog){
//         throw new RuntimeException("#setOnShowListener called, but #onShow has not implemented.");
//     }
// 
//     @Override
//     public void onCancel(DialogFragmentInterface dialog){
//         throw new RuntimeException("#setOnCancelListener called, but #onCancel has not implemented.");
//     }
// 
//     @Override
//     public void onDismiss(DialogFragmentInterface dialog){
//         throw new RuntimeException("#setOnDismissListener called, but #onDismiss has not implemented.");
//     }
// 
//     @Override
//     public void onClickPositive(DialogFragmentInterface dialog){
//         throw new RuntimeException("#setPositiveButton called, but #onClickPositive has not implemented.");
//     }
// 
//     @Override
//     public void onClickNegative(DialogFragmentInterface dialog){
//         throw new RuntimeException("#setNegativeButton called, but #onClickNegative has not implemented.");
//     }
// 
//     @Override
//     public void onClickNeutral(DialogFragmentInterface dialog){
//         throw new RuntimeException("#setNeutralButton called, but #onClickNeutral has not implemented.");
//     }
// 
//     @Override
//     public void onItemClick(DialogFragmentInterface dialog, int position){
//         throw new RuntimeException("#setItems or #setAdapter called, but #onItemClick has not implemented.");
//     }
// 
//     @Override
//     public void onSingleChoiceClick(DialogFragmentInterface dialog, int position){
//         throw new RuntimeException("#setSingleChoiceItems called, but #onSingleChoiceClick has not implemented.");
//     }
// 
//     @Override
//     public void onMultiChoiceClick(DialogFragmentInterface dialog, int position, boolean isChecked){
//         throw new RuntimeException("#setMultiChoiceItems called, but #onMultiChoiceClick has not implemented.");
//     }
// 
//     @Override
//     public boolean onKey(DialogFragmentInterface dialog, int keyCode, KeyEvent event){
//         throw new RuntimeException("#setOnKeyListener called, but #onKey has not implemented.");
//     }
// 
//     @Override
//     public View getCustomTitle(DialogFragmentInterface dialog){
//         throw new RuntimeException("#setCustomTitle called, but #getCustomTitle has not implemented.");
//     }
// 
//     @Override
//     public View getView(DialogFragmentInterface dialog){
//         throw new RuntimeException("#setView called, but #getView has not implemented.");
//     }
// 
//     @Override
//     public ListAdapter getAdapter(DialogFragmentInterface dialog){
//         throw new RuntimeException("#setAdapter called, but #getAdapter has not implemented.");
//     }
// 
//     @Override
//     public void onDateSet(DialogFragmentInterface dialog, DatePicker datePicker, int year, int month, int day){
//         throw new RuntimeException("DatePickerDialogFragment has instantiated, but #onDateSet has not implemented.");
//     }
// 
//     @Override
//     public void onTimeSet(DialogFragmentInterface dialog, TimePicker timePicker, int hour, int minute){
//         throw new RuntimeException("TimePickerDialogFragment has instantiated, but #onTimeSet has not implemented.");
//     }
// 
//     @Override
//     public void onNumberSet(DialogFragmentInterface dialog, NumberPicker numberPicker, int value){
//         throw new RuntimeException("NumberPickerDialogFragment has instantiated, but #onNumberSet has not implemented.");
//     }
// 
//     @Override
//     public void onStringSet(DialogFragmentInterface dialog, StringPicker stringPicker, String value){
//         throw new RuntimeException("StringPickerDialogFragment has instantiated, but #onStringSet has not implemented.");
//     }
// }


import java.util.ArrayList;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.DatePicker;
import android.widget.ListView;
import android.widget.Toast;
import com.wada811.android.dialogfragments.interfaces.DialogFragmentCallback;
import com.wada811.android.dialogfragments.interfaces.DialogFragmentCallbackProvider;
import com.wada811.android.dialogfragments.interfaces.DialogFragmentInterface;
import com.wada811.android.dialogfragments.interfaces.SimpleDialogFragmentCallback;
import com.wada811.android.dialogfragments.sample.Const;
import com.wada811.android.dialogfragments.sample.Example;
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        initExample();
        initListFragment();
    }

    private void initExample(){
        items = new ArrayList<>();
        items.add(new com.wada811.android.dialogfragments.sample.datepickerdialogfragment.examples.traditional.BasicDatePickerDialogExample());
        items.add(new com.wada811.android.dialogfragments.sample.datepickerdialogfragment.examples.material.BasicDatePickerDialogExample());
    }

    private void initListFragment(){
        setListAdapter(new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, items));
    }

    @Override
    public void onListItemClick(ListView l, View v, int position, long id){
        super.onListItemClick(l, v, position, id);
        Example item = items.get(position);
        boolean isInActivity = getArguments().getBoolean(Const.KEY_IS_IN_ACTIVITY);
        item.showDialog(this, isInActivity ? getFragmentManager() : getChildFragmentManager());
    }

    @Override
    public DialogFragmentCallback getDialogFragmentCallback(){
        return new SimpleDialogFragmentCallback() {
            @Override
            public void onDateSet(DialogFragmentInterface dialog, DatePicker datePicker, int year, int month, int day){
                String text = "onDateSet[year: " + year + ", month: " + month + ", day: " + day + "]";
// Path: library/src/main/java/com/wada811/android/dialogfragments/interfaces/DialogFragmentInterface.java
// public interface DialogFragmentInterface {
// 
//     String getTag();
// 
//     void show(FragmentManager manager, String tag);
// 
//     int show(FragmentTransaction transaction, String tag);
// 
//     void dismiss();
// 
//     void dismissAllowingStateLoss();
// 
//     Dialog getDialog();
// 
//     DialogFragmentInterface setExtra(Bundle extra);
// 
//     Bundle getExtra();
// 
// }
// 
// Path: library/src/main/java/com/wada811/android/dialogfragments/interfaces/SimpleDialogFragmentCallback.java
// public class SimpleDialogFragmentCallback implements DialogFragmentCallback {
// 
//     @Override
//     public void onShow(DialogFragmentInterface dialog){
//         throw new RuntimeException("#setOnShowListener called, but #onShow has not implemented.");
//     }
// 
//     @Override
//     public void onCancel(DialogFragmentInterface dialog){
//         throw new RuntimeException("#setOnCancelListener called, but #onCancel has not implemented.");
//     }
// 
//     @Override
//     public void onDismiss(DialogFragmentInterface dialog){
//         throw new RuntimeException("#setOnDismissListener called, but #onDismiss has not implemented.");
//     }
// 
//     @Override
//     public void onClickPositive(DialogFragmentInterface dialog){
//         throw new RuntimeException("#setPositiveButton called, but #onClickPositive has not implemented.");
//     }
// 
//     @Override
//     public void onClickNegative(DialogFragmentInterface dialog){
//         throw new RuntimeException("#setNegativeButton called, but #onClickNegative has not implemented.");
//     }
// 
//     @Override
//     public void onClickNeutral(DialogFragmentInterface dialog){
//         throw new RuntimeException("#setNeutralButton called, but #onClickNeutral has not implemented.");
//     }
// 
//     @Override
//     public void onItemClick(DialogFragmentInterface dialog, int position){
//         throw new RuntimeException("#setItems or #setAdapter called, but #onItemClick has not implemented.");
//     }
// 
//     @Override
//     public void onSingleChoiceClick(DialogFragmentInterface dialog, int position){
//         throw new RuntimeException("#setSingleChoiceItems called, but #onSingleChoiceClick has not implemented.");
//     }
// 
//     @Override
//     public void onMultiChoiceClick(DialogFragmentInterface dialog, int position, boolean isChecked){
//         throw new RuntimeException("#setMultiChoiceItems called, but #onMultiChoiceClick has not implemented.");
//     }
// 
//     @Override
//     public boolean onKey(DialogFragmentInterface dialog, int keyCode, KeyEvent event){
//         throw new RuntimeException("#setOnKeyListener called, but #onKey has not implemented.");
//     }
// 
//     @Override
//     public View getCustomTitle(DialogFragmentInterface dialog){
//         throw new RuntimeException("#setCustomTitle called, but #getCustomTitle has not implemented.");
//     }
// 
//     @Override
//     public View getView(DialogFragmentInterface dialog){
//         throw new RuntimeException("#setView called, but #getView has not implemented.");
//     }
// 
//     @Override
//     public ListAdapter getAdapter(DialogFragmentInterface dialog){
//         throw new RuntimeException("#setAdapter called, but #getAdapter has not implemented.");
//     }
// 
//     @Override
//     public void onDateSet(DialogFragmentInterface dialog, DatePicker datePicker, int year, int month, int day){
//         throw new RuntimeException("DatePickerDialogFragment has instantiated, but #onDateSet has not implemented.");
//     }
// 
//     @Override
//     public void onTimeSet(DialogFragmentInterface dialog, TimePicker timePicker, int hour, int minute){
//         throw new RuntimeException("TimePickerDialogFragment has instantiated, but #onTimeSet has not implemented.");
//     }
// 
//     @Override
//     public void onNumberSet(DialogFragmentInterface dialog, NumberPicker numberPicker, int value){
//         throw new RuntimeException("NumberPickerDialogFragment has instantiated, but #onNumberSet has not implemented.");
//     }
// 
//     @Override
//     public void onStringSet(DialogFragmentInterface dialog, StringPicker stringPicker, String value){
//         throw new RuntimeException("StringPickerDialogFragment has instantiated, but #onStringSet has not implemented.");
//     }
// }


// Path: sample/src/main/java/com/wada811/android/dialogfragments/sample/datepickerdialogfragment/DatePickerDialogFragmentExamplesFragment.java
import java.util.ArrayList;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.DatePicker;
import android.widget.ListView;
import android.widget.Toast;
import com.wada811.android.dialogfragments.interfaces.DialogFragmentCallback;
import com.wada811.android.dialogfragments.interfaces.DialogFragmentCallbackProvider;
import com.wada811.android.dialogfragments.interfaces.DialogFragmentInterface;
import com.wada811.android.dialogfragments.interfaces.SimpleDialogFragmentCallback;
import com.wada811.android.dialogfragments.sample.Const;
import com.wada811.android.dialogfragments.sample.Example;

    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        initExample();
        initListFragment();
    }

    private void initExample(){
        items = new ArrayList<>();
        items.add(new com.wada811.android.dialogfragments.sample.datepickerdialogfragment.examples.traditional.BasicDatePickerDialogExample());
        items.add(new com.wada811.android.dialogfragments.sample.datepickerdialogfragment.examples.material.BasicDatePickerDialogExample());
    }

    private void initListFragment(){
        setListAdapter(new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, items));
    }

    @Override
    public void onListItemClick(ListView l, View v, int position, long id){
        super.onListItemClick(l, v, position, id);
        Example item = items.get(position);
        boolean isInActivity = getArguments().getBoolean(Const.KEY_IS_IN_ACTIVITY);
        item.showDialog(this, isInActivity ? getFragmentManager() : getChildFragmentManager());
    }

    @Override
    public DialogFragmentCallback getDialogFragmentCallback(){
        return new SimpleDialogFragmentCallback() {
            @Override
            public void onDateSet(DialogFragmentInterface dialog, DatePicker datePicker, int year, int month, int day){
                String text = "onDateSet[year: " + year + ", month: " + month + ", day: " + day + "]";
                Log.v(dialog.getTag(), text);