Skip to content

Commit

Permalink
Update README and prepare version 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wellingtoncosta committed Jan 23, 2018
1 parent fdab217 commit c460031
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
33 changes: 20 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,37 +39,44 @@ TextInputLayout passwordLayout;

@ConfirmPasswordValidation(R.string.passwords_not_match)
TextInputLayout confirmPasswordLayout;

@ValidateOnClick
Button validateButton;
```

__Step 2__ - Initialize Convalida:

```java
private ConvalidaValidator validator;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample);
validator = Convalida.init(this);
Convalida.init(this);
}
```

__Step 3__ - Run the validations and get the result:
__Step 3__ - Run the validations by clicking in the button mapped with ```@ValidateOnClick``` and handle success or error:

```java
public void validateFields() {
boolean isValid = validator.validateFields();
String message = isValid ? "Yay!" : "Something is wrong :(";
Snackbar.make(linearLayout, message, Snackbar.LENGTH_LONG).show();
@OnValidationSuccess
public void onValidationSuccess() {
Toast.makeText("Yay!", Toast.LENGTH_LONG).show();
}

@OnValidationError
public void onValidationError() {
Toast.makeText("Something is wrong :(", Toast.LENGTH_LONG).show();
}
```

*Note: Only the method annotated with ```@OnValidationSuccess``` is required.*

__Step 4__ - If you want to clear the validations:

```java
public void clearFields() {
validator.clearValidations();
}
@ClearValidationsOnClick
Button clearValidationsButton;
```

__Remember: You must initialize the views (e.g [ButterKnife][1]) before apply the validations.__
Expand All @@ -91,8 +98,8 @@ __Step 2__ - Add the dependencies:

```groovy
dependencies {
compile 'com.github.WellingtonCosta.convalida:convalida:1.0.7'
annotationProcessor 'com.github.WellingtonCosta.convalida:convalida-compiler:1.0.7'
compile 'com.github.WellingtonCosta.convalida:convalida:1.1.0'
annotationProcessor 'com.github.WellingtonCosta.convalida:convalida-compiler:1.1.0'
}
```

Expand All @@ -116,4 +123,4 @@ dependencies {
[1]: https://github.com/JakeWharton/butterknife
[2]: https://github.com/androidannotations/androidannotations
[3]: https://github.com/WellingtonCosta/convalida/tree/master/convalida-annotations/src/main/java/convalida/annotations
[4]: https://material.io/guidelines/patterns/errors.html
[4]: https://material.io/guidelines/patterns/errors.html
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = '1.0.7'
version = '1.1.0'

apply plugin: 'com.github.ben-manes.versions'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
import convalida.annotations.ValidateOnClick;
import convalida.library.Convalida;

/**
* @author Wellington Costa on 05/06/17.
*/
public class AnotherSampleActivity extends AppCompatActivity {

private static final String PHONE_PATTERN = "[\\+]\\d{2}[\\(]\\d{2}[\\)]\\d{4}[\\-]\\d{4}";
Expand Down Expand Up @@ -48,7 +51,7 @@ public class AnotherSampleActivity extends AppCompatActivity {

@ClearValidationsOnClick
@BindView(R.id.clear_button)
Button clearValidatinonsButton;
Button clearValidationsButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down
2 changes: 1 addition & 1 deletion sample/src/main/java/convalida/sample/SampleActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class SampleActivity extends AppCompatActivity {

@ClearValidationsOnClick
@BindView(R.id.clear_button)
Button clearValidatinonsButton;
Button clearValidationsButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down

0 comments on commit c460031

Please sign in to comment.