package org.deke.risk.riskahead.helper;

import android.content.Context;
import android.content.res.Resources;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.TextView;

import org.deke.risk.riskahead.R;

import static android.provider.Settings.Global.getString;

/**
 * Created by Dennis on 17.11.2015.
 */
public abstract class TextValidator implements TextWatcher {
    private final TextView textView;

    public TextValidator(TextView textView, Context context) {
        this.textView = textView;
        //if(this.textView.getText().length() == 0) this.textView.setError(context.getResources().getString(R.string.error_enter_value));
    }

    public abstract void validate(TextView textView, String text);

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {
    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {

    }

    @Override
    public void afterTextChanged(Editable s) {
        String text = textView.getText().toString();
        validate(textView, text);
    }
}
