Skip to content

Commit 53e4ffe

Browse files
Remove focus listener and update the scenario when the text changes
YM-18725
1 parent e597a65 commit 53e4ffe

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

sample-app-3/src/main/java/com/yoti/mobile/android/sdk/sampleapp/MainActivity.java

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ protected void onCreate(Bundle savedInstanceState) {
5050
mUseCaseEntry = findViewById(R.id.useCaseIdText);
5151
createScenario();
5252

53-
mSdkEntry.setOnFocusChangeListener(scenarioChangeListener);
54-
mScenarioEntry.setOnFocusChangeListener(scenarioChangeListener);
55-
mUseCaseEntry.setOnFocusChangeListener(scenarioChangeListener);
53+
mSdkEntry.addTextChangedListener(scenarioUpdateListener);
54+
mScenarioEntry.addTextChangedListener(scenarioUpdateListener);
55+
mUseCaseEntry.addTextChangedListener(scenarioUpdateListener);
5656
mButtonTextEntry.addTextChangedListener(buttonTextListener);
5757

5858
mYotiSDKButton.setOnYotiButtonClickListener(new YotiSDKButton.OnYotiButtonClickListener() {
@@ -118,16 +118,6 @@ private void processExtraData(Intent intent) {
118118
}
119119
}
120120

121-
private OnFocusChangeListener scenarioChangeListener = new OnFocusChangeListener() {
122-
123-
@Override
124-
public void onFocusChange(final View v, final boolean hasFocus) {
125-
if (!hasFocus) {
126-
createScenario();
127-
}
128-
}
129-
};
130-
131121
private void createScenario() {
132122
hideStatus();
133123
mYotiSDKButton.setVisibility(View.INVISIBLE);
@@ -176,6 +166,24 @@ private void hideStatus() {
176166
mStatusContainer.setVisibility(View.INVISIBLE);
177167
}
178168

169+
private TextWatcher scenarioUpdateListener = new TextWatcher() {
170+
171+
@Override
172+
public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {
173+
174+
}
175+
176+
@Override
177+
public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {
178+
179+
}
180+
181+
@Override
182+
public void afterTextChanged(final Editable s) {
183+
createScenario();
184+
}
185+
};
186+
179187
private TextWatcher buttonTextListener = new TextWatcher() {
180188

181189
@Override

0 commit comments

Comments
 (0)