From a1116dfe33f6c102d21d7be474c0d22a5179393c Mon Sep 17 00:00:00 2001 From: madwasp79 Date: Mon, 28 Jan 2019 10:59:39 +0200 Subject: [PATCH] Bugfix (Two AIDL items in the drawer) #6466 --- OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java | 32 ++++++++++++------- .../net/osmand/plus/OsmandApplication.java | 2 +- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index 5f833bd475..e5133f6070 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -1707,6 +1707,7 @@ public class OsmandAidlApi { String appPackage = entry.getKey(); for (NavDrawerItem item : entry.getValue()) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(item.uri)); + boolean isCopy = false; if (intent.resolveActivity(pm) == null) { intent = pm.getLaunchIntentForPackage(appPackage); } @@ -1715,18 +1716,25 @@ public class OsmandAidlApi { intent.addFlags(item.flags); } final Intent finalIntent = intent; - adapter.addItem(new ContextMenuItem.ItemBuilder() - .setId(item.getId()) - .setTitle(item.name) - .setIcon(getIconId(item.iconName)) - .setListener(new ContextMenuAdapter.ItemClickListener() { - @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int position, boolean isChecked, int[] viewCoordinates) { - activity.startActivity(finalIntent); - return true; - } - }) - .createItem()); + for (String s : adapter.getItemNames()) { + if (item.name.equals(s)) { + isCopy = true; + } + } + if (!isCopy) { + adapter.addItem(new ContextMenuItem.ItemBuilder() + .setId(item.getId()) + .setTitle(item.name) + .setIcon(getIconId(item.iconName)) + .setListener(new ContextMenuAdapter.ItemClickListener() { + @Override + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int position, boolean isChecked, int[] viewCoordinates) { + activity.startActivity(finalIntent); + return true; + } + }) + .createItem()); + } } } } diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index 4be50587b7..7dcd5e9d00 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -647,7 +647,7 @@ public class OsmandApplication extends MultiDexApplication { defaultHandler.uncaughtException(thread, ex); } catch (Exception e) { // swallow all exceptions - android.util.Log.e(PlatformUtil.TAG, "Exception while handle other exception", e); //$NON-NLS-1$ + LOG.error("Exception while handle other exception" + e.getMessage(), e); //$NON-NLS-1$ } }