diff options
Diffstat (limited to 'src')
-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(); |