fixed bug with getScheme

This commit is contained in:
Chumva 2018-05-25 14:28:05 +03:00
parent 197d7d149d
commit 4f38e79ea5

View file

@ -172,7 +172,7 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv
Intent intent = getIntent(); Intent intent = getIntent();
if (intent != null) { if (intent != null) {
Uri data = intent.getData(); Uri data = intent.getData();
if (data != null) { if (data != null && ("http".equalsIgnoreCase(data.getScheme()) || "https".equalsIgnoreCase(data.getScheme()))) {
parseLaunchIntentLink(data); parseLaunchIntentLink(data);
} else { } else {
int currentItem = intent.getIntExtra(TAB_SELECTED, 0); int currentItem = intent.getIntExtra(TAB_SELECTED, 0);
@ -182,7 +182,6 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv
} }
long articleId = intent.getLongExtra(CITY_ID_KEY, -1); long articleId = intent.getLongExtra(CITY_ID_KEY, -1);
String selectedLang = intent.getStringExtra(SELECTED_LANG_KEY); String selectedLang = intent.getStringExtra(SELECTED_LANG_KEY);
if (articleId != -1) { if (articleId != -1) {
WikivoyageArticleDialogFragment.showInstance(app, getSupportFragmentManager(), articleId, selectedLang); WikivoyageArticleDialogFragment.showInstance(app, getSupportFragmentManager(), articleId, selectedLang);
} }
@ -193,14 +192,9 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv
} }
protected void parseLaunchIntentLink(Uri data) { protected void parseLaunchIntentLink(Uri data) {
String scheme = data.getScheme();
String host = data.getHost(); String host = data.getHost();
String path = data.getPath(); String path = data.getPath();
if (("http".equalsIgnoreCase(scheme) || "https".equalsIgnoreCase(scheme)) if (host != null && path != null && host.contains("osmand.net") && path.startsWith("/travel")) {
&& host != null
&& path != null
&& host.contains("osmand.net")
&& path.startsWith("/travel")) {
String title = WikiArticleHelper.decodeTitleFromTravelUrl(data.getQueryParameter("title")); String title = WikiArticleHelper.decodeTitleFromTravelUrl(data.getQueryParameter("title"));
String selectedLang = data.getQueryParameter("lang"); String selectedLang = data.getQueryParameter("lang");
if (!Algorithms.isEmpty(title) && !Algorithms.isEmpty(selectedLang)) { if (!Algorithms.isEmpty(title) && !Algorithms.isEmpty(selectedLang)) {