Added Android code
[wl-app.git] / Android / app / src / main / java / com / moiseum / wolnelektury / components / CheckableRelativeLayout.java
diff --git a/Android/app/src/main/java/com/moiseum/wolnelektury/components/CheckableRelativeLayout.java b/Android/app/src/main/java/com/moiseum/wolnelektury/components/CheckableRelativeLayout.java
new file mode 100644 (file)
index 0000000..5a19829
--- /dev/null
@@ -0,0 +1,40 @@
+package com.moiseum.wolnelektury.components;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.Checkable;
+import android.widget.RelativeLayout;
+
+/**
+ * Relative layout for handling checking/selecting action.
+ */
+public class CheckableRelativeLayout extends RelativeLayout implements Checkable {
+
+       public CheckableRelativeLayout(Context context) {
+               super(context);
+       }
+
+       public CheckableRelativeLayout(Context context, AttributeSet attrs) {
+               super(context, attrs);
+       }
+
+       public CheckableRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) {
+               super(context, attrs, defStyleAttr);
+       }
+
+       @Override
+       public void setChecked(boolean checked) {
+               super.setSelected(checked);
+       }
+
+       @Override
+       public boolean isChecked() {
+               return super.isSelected();
+       }
+
+       @Override
+       public void toggle() {
+               super.setSelected(!isSelected());
+       }
+}
+