diff --git a/app/src/main/java/be/mathsaey/stoofnogaan/ui/MainActivity.java b/app/src/main/java/be/mathsaey/stoofnogaan/ui/MainActivity.java index abeabc0..7c3637a 100644 --- a/app/src/main/java/be/mathsaey/stoofnogaan/ui/MainActivity.java +++ b/app/src/main/java/be/mathsaey/stoofnogaan/ui/MainActivity.java @@ -74,4 +74,12 @@ public class MainActivity extends Activity { taskView.removeView(v); list.remove(v.getTask()); } + + public void onStatusChanged() { + if (list.isFinished()) { + // Alle taken zijn complete + } else { + // Rani haar huis staat in brand + } + } } \ No newline at end of file diff --git a/app/src/main/java/be/mathsaey/stoofnogaan/ui/TaskView.java b/app/src/main/java/be/mathsaey/stoofnogaan/ui/TaskView.java index 87d92a1..ecf721f 100644 --- a/app/src/main/java/be/mathsaey/stoofnogaan/ui/TaskView.java +++ b/app/src/main/java/be/mathsaey/stoofnogaan/ui/TaskView.java @@ -4,6 +4,7 @@ import android.text.Editable; import android.text.TextWatcher; import android.view.LayoutInflater; import android.widget.CheckBox; +import android.widget.CompoundButton; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.Toast; @@ -33,6 +34,7 @@ public class TaskView extends LinearLayout { textView.setText(t.getText()); addTextListeners(); + addCheckListeners(); } public void updateTask() { @@ -49,6 +51,15 @@ public class TaskView extends LinearLayout { return this.task; } + private void addCheckListeners() { + checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean b) { + TaskView.this.parent.onStatusChanged(); + } + }); + } + // Android is horrible, this code tries to figure out when the user finished editing. // When this is the case, check if the text field is empty, delete the taskview if this is // the case.