diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-05-14 21:47:49 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-05-14 21:47:49 +0200 |
commit | 5fe9daca6323da4c6f1a4a94cb8682355830d8e2 (patch) | |
tree | 7dd4febf825319fe1e917af877e2deeb037a962b /src | |
parent | 81509da8e679e88bb2205ce106370ca574aa3bf1 (diff) |
fix some location crashes
Diffstat (limited to 'src')
-rw-r--r-- | src/main/AndroidManifest.xml | 9 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java | 22 |
2 files changed, 16 insertions, 15 deletions
diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index ec13ba1ad..e7f731fc1 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -233,15 +233,6 @@ <activity android:name=".ui.ShowLocationActivity" android:label="@string/show_location"> - <intent-filter> - <action android:name="de.pixart.messenger.location.show" /> - <category android:name="android.intent.category.DEFAULT" /> - </intent-filter> - <intent-filter> - <action android:name="android.intent.action.VIEW" /> - <data android:scheme="geo" /> - <category android:name="android.intent.category.DEFAULT" /> - </intent-filter> </activity> <activity android:name=".ui.SearchActivity" diff --git a/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java b/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java index be2c98de5..b3ff43d3d 100644 --- a/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java @@ -13,6 +13,7 @@ import android.os.Bundle; import android.preference.PreferenceManager; import android.support.design.widget.FloatingActionButton; import android.text.TextUtils; +import android.util.Log; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; @@ -25,6 +26,7 @@ import java.lang.ref.WeakReference; import java.util.List; import java.util.Locale; +import de.pixart.messenger.Config; import de.pixart.messenger.R; import de.pixart.messenger.services.EmojiService; import de.pixart.messenger.utils.MenuDoubleTabUtil; @@ -80,16 +82,20 @@ public class ShowLocationActivity extends XmppActivity { this.location = new Location(""); this.location.setLatitude(latitude); this.location.setLongitude(longitude); + Log.d(Config.LOGTAG, "Location: lat: " + latitude + " long: " + longitude); + markAndCenterOnLocation(this.location); + fab = findViewById(R.id.fab); + fab.setOnClickListener(v -> { + navigate(this.location); + }); } - markAndCenterOnLocation(location); - - fab = findViewById(R.id.fab); - fab.setOnClickListener(v -> { - navigate(location); - }); } private void markAndCenterOnLocation(final Location location) { + if (location == null) { + Log.d(Config.LOGTAG, "No location given"); + return; + } double longitude = location.getLongitude(); double latitude = location.getLatitude(); if (latitude != 0 && longitude != 0) { @@ -182,6 +188,10 @@ public class ShowLocationActivity extends XmppActivity { } private void navigate (Location location) { + if (location == null) { + Log.d(Config.LOGTAG, "No location given"); + return; + } double longitude = location.getLongitude(); double latitude = location.getLatitude(); try { |