therajanmaurya closed pull request #22: Fix customerDetails and Account Section crash URL: https://github.com/apache/fineract-cn-mobile/pull/22
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/app/src/main/java/org/apache/fineract/ui/online/DashboardActivity.java b/app/src/main/java/org/apache/fineract/ui/online/DashboardActivity.java index c3c401e..6c00694 100644 --- a/app/src/main/java/org/apache/fineract/ui/online/DashboardActivity.java +++ b/app/src/main/java/org/apache/fineract/ui/online/DashboardActivity.java @@ -121,6 +121,7 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) { break; case R.id.item_accounts: replaceFragment(AccountsFragment.Companion.newInstance(), true, R.id.container); + break; case R.id.item_teller: replaceFragment(TellerFragment.Companion.newInstance(), true, R.id.container); break; diff --git a/app/src/main/java/org/apache/fineract/ui/online/accounting/accounts/AccountsPresenter.kt b/app/src/main/java/org/apache/fineract/ui/online/accounting/accounts/AccountsPresenter.kt index 870335d..295f2dd 100644 --- a/app/src/main/java/org/apache/fineract/ui/online/accounting/accounts/AccountsPresenter.kt +++ b/app/src/main/java/org/apache/fineract/ui/online/accounting/accounts/AccountsPresenter.kt @@ -19,6 +19,10 @@ class AccountsPresenter @Inject constructor(@ApplicationContext context: Context val compositeDisposable: CompositeDisposable = CompositeDisposable() + override fun attachView(mvpView: AccountContract.View?) { + super.attachView(mvpView) + } + override fun getAccountsPage() { checkViewAttached() mvpView.showProgressbar() @@ -78,5 +82,8 @@ class AccountsPresenter @Inject constructor(@ApplicationContext context: Context })) } - + override fun detachView() { + super.detachView() + compositeDisposable.clear() + } } \ No newline at end of file diff --git a/app/src/main/java/org/apache/fineract/ui/online/customers/customerdetails/CustomerDetailsContract.java b/app/src/main/java/org/apache/fineract/ui/online/customers/customerdetails/CustomerDetailsContract.java index 43076ee..7da80c0 100644 --- a/app/src/main/java/org/apache/fineract/ui/online/customers/customerdetails/CustomerDetailsContract.java +++ b/app/src/main/java/org/apache/fineract/ui/online/customers/customerdetails/CustomerDetailsContract.java @@ -14,7 +14,7 @@ void showUserInterface(); - void savedCustomerDataForSyncing(); + void showCustomerDetails(Customer customer); void showContactDetails(ContactDetail contactDetail); diff --git a/app/src/main/java/org/apache/fineract/ui/online/customers/customerdetails/CustomerDetailsFragment.java b/app/src/main/java/org/apache/fineract/ui/online/customers/customerdetails/CustomerDetailsFragment.java index ce85e2e..9336e5f 100644 --- a/app/src/main/java/org/apache/fineract/ui/online/customers/customerdetails/CustomerDetailsFragment.java +++ b/app/src/main/java/org/apache/fineract/ui/online/customers/customerdetails/CustomerDetailsFragment.java @@ -16,6 +16,7 @@ import android.widget.TextView; import org.apache.fineract.R; +import org.apache.fineract.data.models.customer.Address; import org.apache.fineract.data.models.customer.ContactDetail; import org.apache.fineract.data.models.customer.Customer; import org.apache.fineract.ui.base.FineractBaseActivity; @@ -223,8 +224,52 @@ public void showUserInterface() { } @Override - public void savedCustomerDataForSyncing() { - getActivity().finish(); + public void showCustomerDetails(Customer customer) { + this.customer = customer; + clCustomerDetails.setVisibility(View.VISIBLE); + layoutError.setVisibility(View.GONE); + + loadCustomerPortrait(); + + tvCurrentStatus.setText(customer.getCurrentState().name()); + StatusUtils.setCustomerStatusIcon(customer.getCurrentState(), + ivCurrentStatus, getActivity()); + + Address address = customer.getAddress(); + StringBuilder addressBuilder = new StringBuilder(); + addressBuilder + .append(address.getStreet()).append(", ") + .append(address.getCity()).append(", "); + if (address.getPostalCode() != null) { + addressBuilder.append(address.getPostalCode()); + addressBuilder.append(", "); + } + addressBuilder.append(address.getCountry()); + tvAddress.setText(addressBuilder); + + if (customer.getContactDetails().size() == 0) { + tvNoContactDetailsAvailable.setVisibility(View.VISIBLE); + tvEmail.setVisibility(View.GONE); + tvPhoneNo.setVisibility(View.GONE); + tvMobileNo.setVisibility(View.GONE); + } else { + for (ContactDetail contactDetail : customer.getContactDetails()) { + showContactDetails(contactDetail); + } + } + + tvBirthDay.setText(customer.getDateOfBirth().getYear() + "-" + + customer.getDateOfBirth().getMonth() + "-" + customer.getDateOfBirth().getDay()); + + String title = customer.getGivenName() + " " + customer.getSurname(); + String subtitle; + if (customer.getAssignedEmployee() == null) { + subtitle = getString(R.string.assigned_employee) + " " + + getString(R.string.not_assigned); + } else { + subtitle = getString(R.string.assigned_employee) + " " + customer.getAssignedEmployee(); + } + showToolbarTitleSubtitle(title, subtitle); } @Override diff --git a/app/src/main/java/org/apache/fineract/ui/online/customers/customerdetails/CustomerDetailsPresenter.java b/app/src/main/java/org/apache/fineract/ui/online/customers/customerdetails/CustomerDetailsPresenter.java index 82c95b1..97072ae 100644 --- a/app/src/main/java/org/apache/fineract/ui/online/customers/customerdetails/CustomerDetailsPresenter.java +++ b/app/src/main/java/org/apache/fineract/ui/online/customers/customerdetails/CustomerDetailsPresenter.java @@ -58,7 +58,7 @@ public void loanCustomerDetails(String identifier) { @Override public void onNext(Customer customer) { getMvpView().hideProgressbar(); - getMvpView().savedCustomerDataForSyncing(); + getMvpView().showCustomerDetails(customer); } @Override ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services