added touch delegate to checkbox on daily/todo items.

This commit is contained in:
Darron Lumley 2015-12-18 17:36:29 +11:00 committed by Phillip Thelen
parent 20e8af1c97
commit de9432404e
3 changed files with 17 additions and 0 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

@ -4,10 +4,12 @@ import android.app.Activity;
import android.content.Context;
import android.databinding.DataBindingUtil;
import android.databinding.ObservableArrayList;
import android.graphics.Rect;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.TouchDelegate;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
@ -362,6 +364,8 @@ public class HabitItemRecyclerViewAdapter<THabitItem extends Task>
super(itemView);
checklistIndicatorWrapper.setOnClickListener(this);
checkbox.setOnCheckedChangeListener(this);
expandCheckboxTouchArea(checkboxHolder, checkbox);
}
@Override
@ -446,6 +450,17 @@ public class HabitItemRecyclerViewAdapter<THabitItem extends Task>
}
}
}
public void expandCheckboxTouchArea(final View expandedView, final View checkboxView){
expandedView.post(new Runnable() {
@Override
public void run() {
Rect rect = new Rect();
expandedView.getHitRect(rect);
expandedView.setTouchDelegate(new TouchDelegate(rect, checkboxView));
}
});
}
}
public class DailyViewHolder extends ChecklistedViewHolder {