package com.app.simplitend.apputils;

import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;

import java.util.ArrayList;
import java.util.Arrays;

public class EditTextErrorRemover implements TextWatcher {

    private final ArrayList<EditText> editTexts;

    public EditTextErrorRemover(EditText... editText){
        this.editTexts = new ArrayList<>();

        editTexts.addAll(Arrays.asList(editText));

        for (EditText e: editText){
            e.addTextChangedListener(this);
        }

    }

    @Override
    public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

    }

    @Override
    public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

    }

    @Override
    public void afterTextChanged(Editable editable) {
        for (EditText editText: editTexts){
            editText.setError(null);
        }
    }
}
