Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 37e0f7d8 authored by Hai Zhang's avatar Hai Zhang
Browse files

Fix skipping the last address line and avoid appending nulls.

getMaxAddressLineIndex() returns the largest index instead of the
number of lines, so a less-than-or-equal check is the correct
condition here, or we'll lose the last line. Address lines may also be
null, and in case of null having an empty line is still better than
having a line saying "null".

Fixes: 155585322
Test: presubmit
Change-Id: I150db3ced2fbcdf73faf0cc6adf618b13d5acfca
parent ef21ed35
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -238,9 +238,12 @@ public class MediaView extends TableView implements MediaDisplay {
                        String formattedAddress;
                        StringBuilder addressBuilder = new StringBuilder("");
                        addressBuilder.append(address.getAddressLine(0));
                        for (int i = 1; i < address.getMaxAddressLineIndex(); i++) {
                        for (int i = 1; i <= address.getMaxAddressLineIndex(); i++) {
                            addressBuilder.append("\n");
                            addressBuilder.append(address.getAddressLine(i));
                            String addressLine = address.getAddressLine(i);
                            if (addressLine != null) {
                                addressBuilder.append(addressLine);
                            }
                        }
                        formattedAddress = addressBuilder.toString();
                        table.put(R.string.metadata_address, formattedAddress);