package com.yyrh.ui.widget;


import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;

import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.yyrh.utils.ResourceUtil;

public class EditView extends RelativeLayout {

    private Button btn_right_view;
    private ImageView iv_left_view;
    private EditText et_input;
    public EditView(Context context) {
        super(context);
        initView(context);
    }

    public EditView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }

    public EditView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context);
    }


    private void initView(Context context){
            LayoutInflater.from(context).inflate(ResourceUtil.getLayoutId(context,"hnyy_edittext_style"),this);
            btn_right_view = findViewById(ResourceUtil.getId(context,"btn_right_view"));
            iv_left_view = findViewById(ResourceUtil.getId(context,"iv_left_view"));
            et_input = findViewById(ResourceUtil.getId(context,"et_input"));
    }
    public void setRightViewListener(OnClickListener listener){
        btn_right_view.setOnClickListener(listener);
    }

    public void  setHint(String hint){
        et_input.setHint(hint);
    }
    public void  setLeftImageView(int resId){
        iv_left_view.setBackgroundResource(resId);
    }
    public void  setRightImageView(int resId){
        btn_right_view.setBackgroundResource(resId);
    }

    public void hideLeftView(){
        iv_left_view.setVisibility(View.GONE);
    }
    public void hideRightView(){
        btn_right_view.setVisibility(View.GONE);
    }
    public String getEdittext(){
       return et_input.getText().toString();
    }
    public void clearEdittext(){
        et_input.setText("");
    }

}
