Made the relativelayout holder of the task checkbox react to click events

This commit is contained in:
Darron Lumley 2015-12-17 21:52:05 +11:00 committed by Phillip Thelen
parent 433bebf109
commit b5165752df
3 changed files with 17 additions and 2 deletions

View file

@ -26,6 +26,7 @@
android:layout_height="match_parent"
android:orientation="horizontal">
<RelativeLayout
android:id="@+id/checkBoxHolder"
android:layout_width="@dimen/button_width"
android:layout_height="match_parent"
app:backgroundColor="@{daily.isDisplayedActive(offset) ? daily.getLightTaskColor : @color/task_gray}">

View file

@ -24,6 +24,7 @@
android:layout_height="match_parent"
android:orientation="horizontal">
<RelativeLayout
android:id="@+id/checkBoxHolder"
android:layout_width="@dimen/button_width"
android:layout_height="match_parent"
app:backgroundColor="@{todo.completed ? @color/task_gray : todo.getLightTaskColor}">

View file

@ -344,6 +344,9 @@ public class HabitItemRecyclerViewAdapter<THabitItem extends Task>
public class ChecklistedViewHolder extends ViewHolder<Task> implements CompoundButton.OnCheckedChangeListener {
@Bind(R.id.checkBoxHolder)
RelativeLayout checkboxHolder;
@Bind(R.id.checkBox)
CheckBox checkbox;
@ -443,6 +446,16 @@ public class HabitItemRecyclerViewAdapter<THabitItem extends Task>
}
}
}
@NonNull
protected View.OnClickListener checkboxHolderClickListener() {
return new View.OnClickListener() {
@Override
public void onClick(View v) {
checkbox.setChecked(!checkbox.isChecked());
}
};
}
}
public class DailyViewHolder extends ChecklistedViewHolder {
@ -453,12 +466,11 @@ public class HabitItemRecyclerViewAdapter<THabitItem extends Task>
super(itemView);
binding = DataBindingUtil.bind(itemView);
checkboxHolder.setOnClickListener(checkboxHolderClickListener());
checkbox.setOnCheckedChangeListener(this);
binding.setOffset(dailyResetOffset);
}
@Override
public void bindHolder(Task habitItem, int position) {
super.bindHolder(habitItem, position);
@ -481,6 +493,7 @@ public class HabitItemRecyclerViewAdapter<THabitItem extends Task>
public TodoViewHolder(View itemView) {
super(itemView);
checkboxHolder.setOnClickListener(checkboxHolderClickListener());
binding = DataBindingUtil.bind(itemView);
}