package julianfalcionelli.magicform.helper;

import android.support.design.widget.TextInputLayout;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class ValidationHelper
{
	public static final String TAG = ValidationHelper.class.getSimpleName();

	public static void cleanError(View view)
	{
		if (view instanceof EditText)
		{
			cleanError((EditText) view);
			return;
		}

		if (view instanceof TextView)
		{
			((TextView) view).setError(null);
			return;
		}

	}

	private static void cleanError(EditText editText)
	{
		try
		{
			((TextInputLayout) editText.getParent()).setErrorEnabled(false);
		} catch (ClassCastException e)
		{
			editText.setError(null);
		}
	}

	public static void setError(View view, String error)
	{
		if (view instanceof EditText)
		{
			setError((EditText) view, error);
			return;
		}

		if (view instanceof TextView)
		{
			((TextView) view).setError(error);
			return;
		}
	}

	private static void setError(EditText editText, String error)
	{
		try
		{
			((TextInputLayout) editText.getParent()).setError(error);
		} catch (ClassCastException e)
		{
			editText.setError(error);
		}
	}
}

@@ -568,32 +568,92 @@
 t)%0A%09%7B%0A%09%09try%0A%09%09%7B%0A
+%09%09%09((TextInputLayout) editText.getParent()).setError(null);%0A
 %09%09%09((TextInputLa
@@ -1084,32 +1084,99 @@
 r)%0A%09%7B%0A%09%09try%0A%09%09%7B%0A
+%09%09%09((TextInputLayout) editText.getParent()).setErrorEnabled(true);%0A
 %09%09%09((TextInputLa

Fix error null