Skip to content

Commit

Permalink
fix: Empty Snackbar is displyed on tapping "Submit" button in the Dis…
Browse files Browse the repository at this point in the history
…burse Loan Dialog fragment in the absence of Internet connection
  • Loading branch information
AbhilashG97 committed Apr 26, 2017
1 parent 88282c1 commit ce4a123
Showing 1 changed file with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.mifos.utils.Constants;
import com.mifos.utils.DateHelper;
import com.mifos.utils.FragmentConstants;
import com.mifos.utils.Network;
import com.mifos.utils.Utils;

import java.util.ArrayList;
Expand Down Expand Up @@ -119,19 +120,23 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle

@OnClick(R.id.btn_disburse_loan)
void onSubmitDisburse() {
// Notify the user if Amount field is blank
if (etDisbursedAmount.getEditableText().toString().isEmpty()) {
new RequiredFieldException(getString(R.string.amount), getString(R.string
.message_field_required)).notifyUserWithToast(getActivity());
return;
if (Network.isOnline(getContext())) {
// Notify the user if Amount field is blank
if (etDisbursedAmount.getEditableText().toString().isEmpty()) {
new RequiredFieldException(getString(R.string.amount), getString(R.string
.message_field_required)).notifyUserWithToast(getActivity());
return;
}
LoanDisbursement loanDisbursement = new LoanDisbursement();
loanDisbursement.setNote(etDisbursementNote.getEditableText().toString());
loanDisbursement.setActualDisbursementDate(disbursementDates);
loanDisbursement.setTransactionAmount(
Double.valueOf(etDisbursedAmount.getEditableText().toString()));
loanDisbursement.setPaymentId(paymentTypeId);
loanAccountDisbursementPresenter.disburseLoan(loanAccountNumber, loanDisbursement);
} else {
Toaster.show(rootView, R.string.error_network_not_available, Toaster.LONG);
}
LoanDisbursement loanDisbursement = new LoanDisbursement();
loanDisbursement.setNote(etDisbursementNote.getEditableText().toString());
loanDisbursement.setActualDisbursementDate(disbursementDates);
loanDisbursement.setTransactionAmount(
Double.valueOf(etDisbursedAmount.getEditableText().toString()));
loanDisbursement.setPaymentId(paymentTypeId);
loanAccountDisbursementPresenter.disburseLoan(loanAccountNumber, loanDisbursement);
}

@Override
Expand Down

0 comments on commit ce4a123

Please sign in to comment.