|
|
@@ -1,9 +1,12 @@
|
|
|
package kr.co.zumo.app.lifeplus.view.custom.event;
|
|
|
|
|
|
+import android.annotation.SuppressLint;
|
|
|
import android.content.Context;
|
|
|
+import android.support.annotation.Nullable;
|
|
|
import android.support.constraint.ConstraintLayout;
|
|
|
import android.util.AttributeSet;
|
|
|
import android.view.LayoutInflater;
|
|
|
+import android.view.MotionEvent;
|
|
|
import android.widget.Checkable;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
@@ -21,53 +24,88 @@ import kr.co.zumo.app.R;
|
|
|
*/
|
|
|
public class EventCombinedTwoLineSelectView extends ConstraintLayout implements Checkable {
|
|
|
|
|
|
+ private Context context;
|
|
|
private ConstraintLayout layoutBackground;
|
|
|
private TextView textViewTitle;
|
|
|
private TextView textViewSubTitle;
|
|
|
+ private boolean isChecked;
|
|
|
private OnClickListener listener;
|
|
|
|
|
|
public EventCombinedTwoLineSelectView(Context context) {
|
|
|
super(context);
|
|
|
+ this.context = context;
|
|
|
+ init(context);
|
|
|
+ attachEvent();
|
|
|
}
|
|
|
|
|
|
public EventCombinedTwoLineSelectView(Context context, AttributeSet attrs) {
|
|
|
super(context, attrs);
|
|
|
+ this.context = context;
|
|
|
+ init(context);
|
|
|
+ attachEvent();
|
|
|
}
|
|
|
|
|
|
public EventCombinedTwoLineSelectView(Context context, AttributeSet attrs, int defStyleAttr) {
|
|
|
super(context, attrs, defStyleAttr);
|
|
|
+ this.context = context;
|
|
|
+ init(context);
|
|
|
+ attachEvent();
|
|
|
}
|
|
|
|
|
|
|
|
|
- public void init(Context context, String title, String subTitle) {
|
|
|
+ public void init(Context context) {
|
|
|
if (null != context) {
|
|
|
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
inflater.inflate(R.layout.event_combined_two_line_select_view, this);
|
|
|
layoutBackground = findViewById(R.id.layout_background);
|
|
|
- textViewTitle = findViewById(R.id.text_view_sub_title);
|
|
|
- textViewSubTitle = findViewById(R.id.check_box);
|
|
|
+ textViewTitle = findViewById(R.id.text_view_title);
|
|
|
+ textViewSubTitle = findViewById(R.id.text_view_sub_title);
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- layoutBackground.setOnClickListener(view -> {
|
|
|
- if (null != listener) {
|
|
|
- listener.onClick(this);
|
|
|
- }
|
|
|
- });
|
|
|
+ public void setContents(String title, @Nullable String subTitle) {
|
|
|
+ textViewTitle.setText(title);
|
|
|
+ if (null != subTitle) {
|
|
|
+ textViewSubTitle.setText(subTitle);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ textViewSubTitle.setVisibility(GONE);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void setChecked(boolean b) {
|
|
|
|
|
|
+ @SuppressLint("ClickableViewAccessibility")
|
|
|
+ public void attachEvent() {
|
|
|
+ this.setOnTouchListener((v, event) -> {
|
|
|
+ if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
|
|
+ setChecked(!isChecked);
|
|
|
+ upgradeView(isChecked());
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setChecked(boolean isChecked) {
|
|
|
+ this.isChecked = isChecked;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public boolean isChecked() {
|
|
|
- return false;
|
|
|
+ return isChecked;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void toggle() {
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ private void upgradeView(boolean isChecked) {
|
|
|
+ layoutBackground.setBackgroundResource(isChecked ? R.drawable.event_two_line_check_on : R.drawable.event_two_line_check_off);
|
|
|
+ textViewTitle.setTextColor(isChecked ? context.getResources().getColor(R.color.C333333) : context.getResources().getColor(R.color.CFFFFFF));
|
|
|
+ textViewSubTitle.setTextColor(isChecked ? context.getResources().getColor(R.color.C999999) : context.getResources().getColor(R.color.CC3C3C3));
|
|
|
+ }
|
|
|
}
|