From 673b7ea7174848b96bce1ae82fa2118d1af9f128 Mon Sep 17 00:00:00 2001 From: Javier Solis Flores Date: Sun, 24 Sep 2017 15:47:15 -0500 Subject: [PATCH] Added support library to support support fagment too --- saripaar/build.gradle | 1 + .../src/main/java/com/mobsandgeeks/saripaar/Validator.java | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/saripaar/build.gradle b/saripaar/build.gradle index a0f07ab..3b91638 100644 --- a/saripaar/build.gradle +++ b/saripaar/build.gradle @@ -33,6 +33,7 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:support-annotations:23.1.1' + compile 'com.android.support:support-v4:23.1.1' } apply from: '../gradle-mvn-push.gradle' diff --git a/saripaar/src/main/java/com/mobsandgeeks/saripaar/Validator.java b/saripaar/src/main/java/com/mobsandgeeks/saripaar/Validator.java index 1e0aba2..1c00133 100644 --- a/saripaar/src/main/java/com/mobsandgeeks/saripaar/Validator.java +++ b/saripaar/src/main/java/com/mobsandgeeks/saripaar/Validator.java @@ -172,6 +172,11 @@ public Validator(final Object controller) { Activity activity = ((Fragment) controller).getActivity(); mValidationContext = new ValidationContext(activity); } + else if(controller instanceof android.support.v4.app.Fragment){ + Activity activity = (Activity) ((android.support.v4.app.Fragment) controller).getContext(); + mValidationContext = new ValidationContext(activity); + } + // Else, lazy init ValidationContext in #getRuleAdapterPair(Annotation, Field) // or void #put(VIEW, QuickRule) by obtaining a Context from one of the // View instances.