From ba96d999ff85ff4bf098d55274785a1bb8c62aff Mon Sep 17 00:00:00 2001 From: dtvv Date: Thu, 25 Oct 2018 02:13:11 -0500 Subject: [PATCH] Add listener to the class PatternRequestActivity to reuse the on success or fail password event --- .../activities/PatternRequestActivity.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/PatternRequestActivity.java b/app/src/main/java/cy/agorise/crystalwallet/activities/PatternRequestActivity.java index 56ec8b1..41b7b9a 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/PatternRequestActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/PatternRequestActivity.java @@ -39,6 +39,11 @@ public class PatternRequestActivity extends AppCompatActivity { @BindView(R.id.txtBadtry) TextView txtBadtry; + /* + * External listener for success or fail + * */ + private OnResponse onResponse; + /* * Contains the bad tries * */ @@ -100,11 +105,24 @@ public class PatternRequestActivity extends AppCompatActivity { if (CrystalSecurityMonitor.getInstance(null).is2ndFactorSet()) { //CrystalSecurityMonitor.getInstance(null).call2ndFactor(thisActivity); thisActivity.finish(); + + if(onResponse != null){ + onResponse.onSuccess(); + } + } else { thisActivity.finish(); + + if(onResponse != null){ + onResponse.onSuccess(); + } } } else { incorrect(); + + if(onResponse != null){ + onResponse.onFailed(); + } } } @@ -122,6 +140,10 @@ public class PatternRequestActivity extends AppCompatActivity { }); } + public void setOnResponse(OnResponse onResponse) { + this.onResponse = onResponse; + } + private void incorrect(){ /* @@ -224,6 +246,14 @@ public class PatternRequestActivity extends AppCompatActivity { return patternString; } + + /* + * Listener events for success and fail + * */ + public interface OnResponse{ + void onSuccess(); + void onFailed(); + } }