diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-09-04 20:31:52 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-09-04 20:31:52 +0200 |
commit | c8571284457136d9221e5f7a652780f6f7fd10f9 (patch) | |
tree | 22f299d4bdf0e21b8fb4775748f8bb22c2e7984f /src/main/java/de/pixart | |
parent | ce5f6bdb6fedac05b76c8bc0660bde24d0fe3b72 (diff) |
fix crash in location activities
Diffstat (limited to 'src/main/java/de/pixart')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java | 17 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java | 11 |
2 files changed, 14 insertions, 14 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java b/src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java index e742b6590..842fcb7dd 100644 --- a/src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java @@ -236,15 +236,14 @@ public class ShareLocationActivity extends Activity implements OnMapReadyCallbac e.printStackTrace(); } - if (addresses != null) { + if (addresses != null && addresses.size() > 0) { Address Address = addresses.get(0); StringBuilder strAddress = new StringBuilder(""); - for (int i = 0; i < Address.getMaxAddressLineIndex(); i++) { - strAddress.append(Address.getAddressLine(i)).append("\n"); + if (Address.getAddressLine(0).length() > 0) { + strAddress.append(Address.getAddressLine(0)); } - address = strAddress.toString(); - address = address.substring(0, address.length() - 1); //trim last \n + address = strAddress.toString().replace(", ", "\n"); } return address; @@ -254,9 +253,11 @@ public class ShareLocationActivity extends Activity implements OnMapReadyCallbac @Override protected void onPostExecute(String address) { // Setting address of the touched Position - mLocationInfo.setVisibility(View.VISIBLE); - mSnackbarLocation.setText(address); - Log.d(Config.LOGTAG, "Location: Address = " + address); + if (address.length() > 0) { + mLocationInfo.setVisibility(View.VISIBLE); + mSnackbarLocation.setText(address); + Log.d(Config.LOGTAG, "Location: Address = " + address); + } } } } diff --git a/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java b/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java index bb950a21e..f6c174a2f 100644 --- a/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java @@ -155,15 +155,14 @@ public class ShowLocationActivity extends Activity implements OnMapReadyCallback Geocoder geoCoder = new Geocoder(context, Locale.getDefault()); try { List<Address> addresses = geoCoder.getFromLocation(latitude, longitude, 1); - if (addresses != null) { + if (addresses != null && addresses.size() > 0) { Address Address = addresses.get(0); StringBuilder strAddress = new StringBuilder(""); - for (int i = 0; i < Address.getMaxAddressLineIndex(); i++) { - strAddress.append(Address.getAddressLine(i)).append("\n"); - } - address = strAddress.toString(); - address = address.substring(0, address.length() - 1); //trim last \n + if (Address.getAddressLine(0).length() > 0) { + strAddress.append(Address.getAddressLine(0)); + } + address = strAddress.toString().replace(", ", "\n"); } } catch (Exception e) { e.printStackTrace(); |