package br.com.bloder.blorm;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Toast;

import br.com.bloder.blormlib.Blorm;
import br.com.bloder.blormlib.validation.Action;

import static br.com.bloder.blormlib.validation.Validations.*;

public class MainActivity extends AppCompatActivity {

  private EditText editTextFilled;
  private EditText editTextFilled2;
  private EditText editTextFilled3;
  private Button submit;
  private CheckBox checkBox;
  private CheckBox checkBox2;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    editTextFilled = (EditText) findViewById(R.id.edit_text_filled);
    editTextFilled2 = (EditText) findViewById(R.id.edit_text_filled_2);
    editTextFilled3 = (EditText) findViewById(R.id.edit_text_filled_3);
    checkBox = (CheckBox) findViewById(R.id.check_box);
    checkBox2 = (CheckBox) findViewById(R.id.check_box2);
    submit = (Button) findViewById(R.id.submit);

      new Blorm.Builder()
              .field(editTextFilled).is(email)
              .andField(editTextFilled2).is(number.withMaxSize(3))
              .andField(editTextFilled3).is(filled)
              .andField(checkBox).is(checked)
              .andField(checkBox2).is("test3", checked)
              .onSuccess(new Action() {
                  @Override
                  public void call() {
                      onSuccess();
                  }
              })
              .onError(new Action() {
                @Override
                public void call() {
                  onError();
                }
              })
              .submitOn(submit);
  }

  private void onSuccess() {
    editTextFilled.setError(null);
    checkBox.setError(null);
    Toast.makeText(this, "Success", Toast.LENGTH_SHORT).show();
  }

  private void onError() {
    Toast.makeText(this, "Error", Toast.LENGTH_SHORT).show();
  }
}

@@ -1153,18 +1153,16 @@
 );%0A%0A    
-  
 new Blor
@@ -1172,21 +1172,109 @@
 uilder()
-%0A    
+.field(editTextFilled).is(email).whenChangeFocusOn(editTextFilled);%0A%0A    new Blorm.Builder()%0A
         
@@ -1275,16 +1275,18 @@
         
+  
 .field(e
@@ -1310,18 +1310,16 @@
 (email)%0A
-  
         
@@ -1375,18 +1375,16 @@
 ize(3))%0A
-  
         
@@ -1429,34 +1429,32 @@
 ed)%0A            
-  
 .andField(checkB
@@ -1461,34 +1461,32 @@
 ox).is(checked)%0A
-  
             .and
@@ -1515,34 +1515,32 @@
 est3%22, checked)%0A
-  
             .onS
@@ -1692,34 +1692,32 @@
              %7D)%0A
-  
             .onE
@@ -1728,32 +1728,32 @@
 (new Action() %7B%0A
+
                 
@@ -1879,19 +1879,17 @@
     
-  .s
+.onS
 ubmit
-On
 (sub

Add on change field focus feature example