From 6a3ad7afb99ba7d7c08c7c48184cfd73885c3c0a Mon Sep 17 00:00:00 2001 From: jawidMuhammadi Date: Thu, 18 Jun 2020 22:34:01 +0530 Subject: [PATCH] Fix: add nullity check for address string --- .../FormCustomerAddressFragment.java | 18 ++++++++++-------- .../CustomerDetailsFragment.java | 16 +++++++++++----- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/org/apache/fineract/ui/online/customers/createcustomer/formcustomeraddress/FormCustomerAddressFragment.java b/app/src/main/java/org/apache/fineract/ui/online/customers/createcustomer/formcustomeraddress/FormCustomerAddressFragment.java index f3ba64c7..b4c446fb 100644 --- a/app/src/main/java/org/apache/fineract/ui/online/customers/createcustomer/formcustomeraddress/FormCustomerAddressFragment.java +++ b/app/src/main/java/org/apache/fineract/ui/online/customers/createcustomer/formcustomeraddress/FormCustomerAddressFragment.java @@ -134,16 +134,18 @@ public void showUserInterface() { public void showPreviousAddress() { Address address = customer.getAddress(); - etStreet.setText(address.getStreet()); - etCity.setText(address.getCity()); - if (address.getPostalCode() != null) { - etPostalCode.setText(address.getPostalCode()); + if (address != null) { + etStreet.setText(address.getStreet()); + etCity.setText(address.getCity()); + if (address.getPostalCode() != null) { + etPostalCode.setText(address.getPostalCode()); + } + etCountry.setText(address.getCountry()); + if (address.getRegion() != null) { + etRegion.setText(address.getRegion()); + } } - etCountry.setText(address.getCountry()); showTextInputLayoutError(tilCountry, null); - if (address.getRegion() != null) { - etRegion.setText(address.getRegion()); - } } @Override 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 b34f58e1..ab855fa6 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 @@ -2,12 +2,16 @@ import android.content.Intent; import android.os.Bundle; + import androidx.annotation.Nullable; + import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout; + import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; + import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -246,14 +250,16 @@ public void showCustomerDetails(Customer customer) { Address address = customer.getAddress(); StringBuilder addressBuilder = new StringBuilder(); - addressBuilder - .append(address.getStreet()).append(", ") - .append(address.getCity()).append(", "); - if (address.getPostalCode() != null) { + if (address != null) { + addressBuilder.append(address.getStreet()).append(", ") + .append(address.getCity()).append(", "); + addressBuilder.append(address.getPostalCode()); addressBuilder.append(", "); + + addressBuilder.append(address.getCountry()); } - addressBuilder.append(address.getCountry()); + tvAddress.setText(addressBuilder); if (customer.getContactDetails().size() == 0) {