aboutsummaryrefslogtreecommitdiff
path: root/WordPress/src/main/java/org/wordpress/android/widgets/CheckedLinearLayout.java
diff options
context:
space:
mode:
Diffstat (limited to 'WordPress/src/main/java/org/wordpress/android/widgets/CheckedLinearLayout.java')
-rw-r--r--WordPress/src/main/java/org/wordpress/android/widgets/CheckedLinearLayout.java47
1 files changed, 47 insertions, 0 deletions
diff --git a/WordPress/src/main/java/org/wordpress/android/widgets/CheckedLinearLayout.java b/WordPress/src/main/java/org/wordpress/android/widgets/CheckedLinearLayout.java
new file mode 100644
index 000000000..990274379
--- /dev/null
+++ b/WordPress/src/main/java/org/wordpress/android/widgets/CheckedLinearLayout.java
@@ -0,0 +1,47 @@
+package org.wordpress.android.widgets;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.Checkable;
+import android.widget.CheckedTextView;
+import android.widget.LinearLayout;
+
+public class CheckedLinearLayout extends LinearLayout implements Checkable {
+ private CheckedTextView mCheckbox;
+
+ public CheckedLinearLayout(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ int childCount = getChildCount();
+ for (int i = 0; i < childCount; ++i) {
+ View v = getChildAt(i);
+ if (v instanceof CheckedTextView) {
+ mCheckbox = (CheckedTextView)v;
+ }
+ }
+ }
+
+ @Override
+ public boolean isChecked() {
+ return mCheckbox != null ? mCheckbox.isChecked() : false;
+ }
+
+ @Override
+ public void setChecked(boolean checked) {
+ if (mCheckbox != null) {
+ mCheckbox.setChecked(checked);
+ }
+ }
+
+ @Override
+ public void toggle() {
+ if (mCheckbox != null) {
+ mCheckbox.toggle();
+ }
+ }
+} \ No newline at end of file