// Path: chapter9-criminalintent/app/src/main/java/com/olerass/pfexample/android/criminalintent/domain/crime/CrimeView.java
// public interface CrimeView {
//     void setDate(Date date);
//     void disableDateInteraction();
// 
//     void whenTitleChanged(DataEventListener<String> listener);
//     void whenSolvedChanged(DataEventListener<Boolean> listener);
// }
// 
// Path: chapter9-criminalintent/app/src/main/java/com/olerass/pfexample/android/criminalintent/domain/event/DataEvent.java
// public class DataEvent<T> {
//     private List<DataEventListener<T>> listeners = new ArrayList<>();
// 
//     public void addListener(DataEventListener<T> listener) {
//         listeners.add(listener);
//     }
// 
//     public void dispatch(T data) {
//         for (DataEventListener<T> listener : listeners) {
//             listener.onDispatch(data);
//         }
//     }
// }
// 
// Path: chapter9-criminalintent/app/src/main/java/com/olerass/pfexample/android/criminalintent/domain/event/DataEventListener.java
// public interface DataEventListener<T> {
//     void onDispatch(T data);
// }


import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import com.olerass.pfexample.android.criminalintent.R;
import com.olerass.pfexample.android.criminalintent.domain.crime.CrimeView;
import com.olerass.pfexample.android.criminalintent.domain.event.DataEvent;
import com.olerass.pfexample.android.criminalintent.domain.event.DataEventListener;
import java.util.Date;
package com.olerass.pfexample.android.criminalintent.platform;




public class FragmentCrimeView implements CrimeView {
    private View view;
    private EditText titleField;
    private Button dateButton;
    private CheckBox solvedCheckBox;
    private DataEvent<String> titleChanged = new DataEvent<>();
    private DataEvent<Boolean> solvedChanged = new DataEvent<>();

    public FragmentCrimeView(LayoutInflater inflater, ViewGroup container) {
        view = inflater.inflate(R.layout.fragment_crime, container, false);

        initializeTitleField();
        initializeSolvedCheckBox();
        initializeDateButton();
    }

    public View getView() {
        return view;
    }

    @Override
    public void setDate(Date date) {
        dateButton.setText(date.toString());
    }

    @Override
    public void disableDateInteraction() {
        dateButton.setEnabled(false);
    }

    @Override
    public void whenTitleChanged(DataEventListener<String> listener) {
        titleChanged.addListener(listener);
    }

// Path: chapter9-criminalintent/app/src/main/java/com/olerass/pfexample/android/criminalintent/domain/crime/CrimeView.java
// public interface CrimeView {
//     void setDate(Date date);
//     void disableDateInteraction();
// 
//     void whenTitleChanged(DataEventListener<String> listener);
//     void whenSolvedChanged(DataEventListener<Boolean> listener);
// }
// 
// Path: chapter9-criminalintent/app/src/main/java/com/olerass/pfexample/android/criminalintent/domain/event/DataEvent.java
// public class DataEvent<T> {
//     private List<DataEventListener<T>> listeners = new ArrayList<>();
// 
//     public void addListener(DataEventListener<T> listener) {
//         listeners.add(listener);
//     }
// 
//     public void dispatch(T data) {
//         for (DataEventListener<T> listener : listeners) {
//             listener.onDispatch(data);
//         }
//     }
// }
// 
// Path: chapter9-criminalintent/app/src/main/java/com/olerass/pfexample/android/criminalintent/domain/event/DataEventListener.java
// public interface DataEventListener<T> {
//     void onDispatch(T data);
// }


// Path: chapter8-criminalintent/app/src/main/java/com/olerass/pfexample/android/criminalintent/platform/FragmentCrimeView.java
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import com.olerass.pfexample.android.criminalintent.R;
import com.olerass.pfexample.android.criminalintent.domain.crime.CrimeView;
import com.olerass.pfexample.android.criminalintent.domain.event.DataEvent;
import com.olerass.pfexample.android.criminalintent.domain.event.DataEventListener;
import java.util.Date;

package com.olerass.pfexample.android.criminalintent.platform;




public class FragmentCrimeView implements CrimeView {
    private View view;
    private EditText titleField;
    private Button dateButton;
    private CheckBox solvedCheckBox;
    private DataEvent<String> titleChanged = new DataEvent<>();
    private DataEvent<Boolean> solvedChanged = new DataEvent<>();

    public FragmentCrimeView(LayoutInflater inflater, ViewGroup container) {
        view = inflater.inflate(R.layout.fragment_crime, container, false);

        initializeTitleField();
        initializeSolvedCheckBox();
        initializeDateButton();
    }

    public View getView() {
        return view;
    }

    @Override
    public void setDate(Date date) {
        dateButton.setText(date.toString());
    }

    @Override
    public void disableDateInteraction() {
        dateButton.setEnabled(false);
    }

    @Override
    public void whenTitleChanged(DataEventListener<String> listener) {
        titleChanged.addListener(listener);
    }

    @Override