// Path: chapter6-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/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: chapter6-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/event/DataEventListener.java
// public interface DataEventListener<T> {
//     void onDispatch(T data);
// }
// 
// Path: chapter6-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/event/Event.java
// public class Event {
//     private List<EventListener> listeners = new ArrayList<>();
// 
//     public void addListener(EventListener listener) {
//         listeners.add(listener);
//     }
// 
//     public void dispatch() {
//         for (EventListener listener : listeners) {
//             listener.onDispatch();
//         }
//     }
// }
// 
// Path: chapter6-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/event/EventListener.java
// public interface EventListener {
//     void onDispatch();
// }
// 
// Path: chapter2-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/question/QuestionView.java
// public interface QuestionView {
//     void setQuestionText(String question);
//     void showCorrectAnswerMessage();
//     void showIncorrectAnswerMessage();
// 
//     void whenAnswerGiven(DataEventListener<Boolean> listener);
//     void whenNextQuestionRequested(EventListener listener);
//     void whenPreviousQuestionRequested(EventListener listener);
// }


import android.app.Activity;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;
import com.olerass.pfexample.android.geoquiz.R;
import com.olerass.pfexample.android.geoquiz.domain.event.DataEvent;
import com.olerass.pfexample.android.geoquiz.domain.event.DataEventListener;
import com.olerass.pfexample.android.geoquiz.domain.event.Event;
import com.olerass.pfexample.android.geoquiz.domain.event.EventListener;
import com.olerass.pfexample.android.geoquiz.domain.question.QuestionView;
package com.olerass.pfexample.android.geoquiz.platform;



public class AndroidQuestionView implements QuestionView {
    private Activity base;
    private TextView questionTextView;
    private Button trueButton;
    private Button falseButton;
    private ImageButton nextButton;
    private ImageButton previousButton;
    private DataEvent<Boolean> answerEvent = new DataEvent<>();
    private Event nextQuestionEvent = new Event();
    private Event previousQuestionEvent = new Event();

    public AndroidQuestionView(Activity base) {
        this.base = base;
        questionTextView = (TextView)base.findViewById(R.id.question_text_view);
        questionTextView.setOnClickListener(v -> nextQuestionEvent.dispatch());

        trueButton = (Button)base.findViewById(R.id.true_button);
        trueButton.setOnClickListener(v -> answerEvent.dispatch(true));

        falseButton = (Button)base.findViewById(R.id.false_button);
        falseButton.setOnClickListener(v -> answerEvent.dispatch(false));

        nextButton = (ImageButton)base.findViewById(R.id.next_button);
        nextButton.setOnClickListener(v -> nextQuestionEvent.dispatch());

        previousButton = (ImageButton)base.findViewById(R.id.previous_button);
        previousButton.setOnClickListener(v -> previousQuestionEvent.dispatch());
    }

    @Override
    public void whenAnswerGiven(DataEventListener<Boolean> listener) {
        answerEvent.addListener(listener);
    }

// Path: chapter6-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/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: chapter6-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/event/DataEventListener.java
// public interface DataEventListener<T> {
//     void onDispatch(T data);
// }
// 
// Path: chapter6-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/event/Event.java
// public class Event {
//     private List<EventListener> listeners = new ArrayList<>();
// 
//     public void addListener(EventListener listener) {
//         listeners.add(listener);
//     }
// 
//     public void dispatch() {
//         for (EventListener listener : listeners) {
//             listener.onDispatch();
//         }
//     }
// }
// 
// Path: chapter6-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/event/EventListener.java
// public interface EventListener {
//     void onDispatch();
// }
// 
// Path: chapter2-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/question/QuestionView.java
// public interface QuestionView {
//     void setQuestionText(String question);
//     void showCorrectAnswerMessage();
//     void showIncorrectAnswerMessage();
// 
//     void whenAnswerGiven(DataEventListener<Boolean> listener);
//     void whenNextQuestionRequested(EventListener listener);
//     void whenPreviousQuestionRequested(EventListener listener);
// }


// Path: chapter2-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/platform/AndroidQuestionView.java
import android.app.Activity;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;
import com.olerass.pfexample.android.geoquiz.R;
import com.olerass.pfexample.android.geoquiz.domain.event.DataEvent;
import com.olerass.pfexample.android.geoquiz.domain.event.DataEventListener;
import com.olerass.pfexample.android.geoquiz.domain.event.Event;
import com.olerass.pfexample.android.geoquiz.domain.event.EventListener;
import com.olerass.pfexample.android.geoquiz.domain.question.QuestionView;

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



public class AndroidQuestionView implements QuestionView {
    private Activity base;
    private TextView questionTextView;
    private Button trueButton;
    private Button falseButton;
    private ImageButton nextButton;
    private ImageButton previousButton;
    private DataEvent<Boolean> answerEvent = new DataEvent<>();
    private Event nextQuestionEvent = new Event();
    private Event previousQuestionEvent = new Event();

    public AndroidQuestionView(Activity base) {
        this.base = base;
        questionTextView = (TextView)base.findViewById(R.id.question_text_view);
        questionTextView.setOnClickListener(v -> nextQuestionEvent.dispatch());

        trueButton = (Button)base.findViewById(R.id.true_button);
        trueButton.setOnClickListener(v -> answerEvent.dispatch(true));

        falseButton = (Button)base.findViewById(R.id.false_button);
        falseButton.setOnClickListener(v -> answerEvent.dispatch(false));

        nextButton = (ImageButton)base.findViewById(R.id.next_button);
        nextButton.setOnClickListener(v -> nextQuestionEvent.dispatch());

        previousButton = (ImageButton)base.findViewById(R.id.previous_button);
        previousButton.setOnClickListener(v -> previousQuestionEvent.dispatch());
    }

    @Override
    public void whenAnswerGiven(DataEventListener<Boolean> listener) {
        answerEvent.addListener(listener);
    }

    @Override