Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Commit

Permalink
Fix: add nullity check for address string
Browse files Browse the repository at this point in the history
  • Loading branch information
jawidMuhammadi committed Jun 18, 2020
1 parent 3e72a93 commit 6a3ad7a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 6a3ad7a

Please sign in to comment.