From 51de6682fda1dc73a90adea0a659f6813f16c5f2 Mon Sep 17 00:00:00 2001 From: Bars107 Date: Tue, 13 Jan 2015 13:22:16 +0200 Subject: [PATCH] Fixed bug with address search adapter cast --- .../net/osmand/plus/activities/OsmandListActivity.java | 8 +++++++- .../activities/search/SearchByNameAbstractActivity.java | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/OsmandListActivity.java b/OsmAnd/src/net/osmand/plus/activities/OsmandListActivity.java index 122abf0e4b..feac1f389c 100644 --- a/OsmAnd/src/net/osmand/plus/activities/OsmandListActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/OsmandListActivity.java @@ -5,6 +5,7 @@ import android.support.v7.app.ActionBarActivity; import android.view.Menu; import android.view.MenuItem; import android.widget.AdapterView; +import android.widget.HeaderViewListAdapter; import android.widget.ListAdapter; import android.widget.ListView; import net.osmand.plus.OsmandApplication; @@ -82,7 +83,12 @@ public abstract class OsmandListActivity extends } public ListAdapter getListAdapter() { - return ((ListView)findViewById(android.R.id.list)).getAdapter(); + ListAdapter adapter = getListView().getAdapter(); + if (adapter instanceof HeaderViewListAdapter) { + return ((HeaderViewListAdapter)adapter).getWrappedAdapter(); + } else { + return adapter; + } } public void setOnItemClickListener(AdapterView.OnItemClickListener childClickListener){ diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java index ea46904edb..1540100650 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java @@ -335,7 +335,6 @@ public abstract class SearchByNameAbstractActivity extends OsmandListActivity } } - @SuppressWarnings("unchecked") @Override public NamesAdapter getListAdapter() { return (NamesAdapter) super.getListAdapter();