|
|
@ -1,12 +1,12 @@ |
|
|
|
package com.swifttech.remit.jmecustomer.features.changetxnpin.view; |
|
|
|
|
|
|
|
import androidx.lifecycle.ViewModelProvider; |
|
|
|
|
|
|
|
import android.os.Bundle; |
|
|
|
import android.view.View; |
|
|
|
import android.widget.Button; |
|
|
|
import android.widget.TextView; |
|
|
|
|
|
|
|
import androidx.lifecycle.ViewModelProvider; |
|
|
|
|
|
|
|
import com.google.android.material.textfield.TextInputEditText; |
|
|
|
import com.google.android.material.textfield.TextInputLayout; |
|
|
|
import com.jakewharton.rxbinding3.widget.RxTextView; |
|
|
@ -66,9 +66,8 @@ public class ChangeTxnPinActivity extends BaseActivity implements ChangePinV2Pre |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initialize() { |
|
|
|
this.viewModel=new ViewModelProvider(this,new ChangePinViewModelFactory(this)).get(ChangePinV2Presenter.class); |
|
|
|
this.viewModel = new ViewModelProvider(this, new ChangePinViewModelFactory(this)).get(ChangePinV2Presenter.class); |
|
|
|
|
|
|
|
ChangePinLiveData changePinLiveData = viewModel.getChangePasswordRelatedViewEvents(new ChangePinLiveData.ChangePinViewBindings( |
|
|
|
RxTextView.textChanges(currentPin_edTxt).skipInitialValue(), |
|
|
@ -76,39 +75,35 @@ public class ChangeTxnPinActivity extends BaseActivity implements ChangePinV2Pre |
|
|
|
RxTextView.textChanges(confirmPin_edTxt).skipInitialValue() |
|
|
|
)); |
|
|
|
|
|
|
|
changePinLiveData.getCurrentPinInputLiveData().observe(this,this::onCurrentPasswordStateChanged); |
|
|
|
changePinLiveData.getNewPinInputLiveData().observe(this,this::onNewPasswordStateChanged); |
|
|
|
changePinLiveData.getConfirmPinInputLiveData().observe(this,this::onConfirmPasswordStateChanged); |
|
|
|
changePinLiveData.getAllFormValidLiveData().observe(this, result->btn_submit.setEnabled(result.isValid())); |
|
|
|
changePinLiveData.getCurrentPinInputLiveData().observe(this, this::onCurrentPasswordStateChanged); |
|
|
|
changePinLiveData.getNewPinInputLiveData().observe(this, this::onNewPasswordStateChanged); |
|
|
|
changePinLiveData.getConfirmPinInputLiveData().observe(this, this::onConfirmPasswordStateChanged); |
|
|
|
changePinLiveData.getAllFormValidLiveData().observe(this, result -> { |
|
|
|
// btn_submit.setEnabled(result.isValid()); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
private void onConfirmPasswordStateChanged(FormInputStateDTO<String> state) { |
|
|
|
if(state.isValid()) |
|
|
|
{ |
|
|
|
if (state.isValid()) { |
|
|
|
confirmPin_TxtInputLayout.setError(null); |
|
|
|
confirmPin_TxtInputLayout.setErrorEnabled(false); |
|
|
|
if(state.hasData()) |
|
|
|
{ |
|
|
|
if (state.hasData()) { |
|
|
|
confirmPin_edTxt.setText(state.getData()); |
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
} else { |
|
|
|
confirmPin_TxtInputLayout.setErrorEnabled(true); |
|
|
|
confirmPin_TxtInputLayout.setError(state.getErrorMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void onNewPasswordStateChanged(FormInputStateDTO<String> state) { |
|
|
|
if(state.isValid()) |
|
|
|
{ |
|
|
|
if (state.isValid()) { |
|
|
|
newPin_TxtInputLayout.setError(null); |
|
|
|
newPin_TxtInputLayout.setErrorEnabled(false); |
|
|
|
if(state.hasData()) |
|
|
|
{ |
|
|
|
if (state.hasData()) { |
|
|
|
newPin_edTxt.setText(state.getData()); |
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
} else { |
|
|
|
newPin_TxtInputLayout.setErrorEnabled(true); |
|
|
|
newPin_TxtInputLayout.setError(state.getErrorMessage()); |
|
|
|
} |
|
|
@ -116,41 +111,38 @@ public class ChangeTxnPinActivity extends BaseActivity implements ChangePinV2Pre |
|
|
|
} |
|
|
|
|
|
|
|
private void onCurrentPasswordStateChanged(FormInputStateDTO<String> state) { |
|
|
|
if(state.isValid()) |
|
|
|
{ |
|
|
|
if (state.isValid()) { |
|
|
|
currentPin_TxtInputLayout.setError(null); |
|
|
|
currentPin_TxtInputLayout.setErrorEnabled(false); |
|
|
|
if(state.hasData()) |
|
|
|
{ |
|
|
|
if (state.hasData()) { |
|
|
|
currentPin_edTxt.setText(state.getData()); |
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
} else { |
|
|
|
currentPin_TxtInputLayout.setErrorEnabled(true); |
|
|
|
currentPin_TxtInputLayout.setError(state.getErrorMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void performDefaultAction(Bundle savedInstanceState) { |
|
|
|
if(savedInstanceState==null) |
|
|
|
{ |
|
|
|
if (savedInstanceState == null) { |
|
|
|
toolbarTitle.setText(getResources().getString(R.string.changepin_text)); |
|
|
|
iv_cancel.setVisibility(View.INVISIBLE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@OnClick(R.id.iv_back) |
|
|
|
public void onBackButtonClicked(View v) |
|
|
|
{ |
|
|
|
public void onBackButtonClicked(View v) { |
|
|
|
onBackPressed(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@OnClick(R.id.btn_submit) |
|
|
|
public void onBtnSubmitClicked() |
|
|
|
{ |
|
|
|
viewModel.changePin(); |
|
|
|
public void onBtnSubmitClicked() { |
|
|
|
if (viewModel.validateAllChangePinForm()) { |
|
|
|
hideKeyBoard(); |
|
|
|
viewModel.changePin(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |