Show correct info box for search result.

This commit is contained in:
Dmitry Kunin 2014-02-24 14:26:40 +03:00 committed by Alex Zolotarev
parent 73fd1307c2
commit 2628098fca
4 changed files with 38 additions and 6 deletions

View file

@ -910,8 +910,11 @@ extern "C"
JNIEXPORT void Java_com_mapswithme_maps_Framework_injectData(JNIEnv * env, jclass clazz, jobject jsearchResult, jlong index)
{
const size_t nIndex = static_cast<size_t>(index);
ASSERT_LESS(nIndex , g_framework->NativeFramework()->AdditionalLayerNumberOfPoi(), ("Invalid index", nIndex));
Bookmark * b = g_framework->NativeFramework()->
GetBookmarkManager().AdditionalPoiLayerGetBookmark(static_cast<size_t>(index));
GetBookmarkManager().AdditionalPoiLayerGetBookmark(nIndex);
static jclass javaClazz = env->GetObjectClass(jsearchResult);

View file

@ -784,10 +784,23 @@ public class MWMActivity extends NvEventQueueActivity
protected void onNewIntent(Intent intent)
{
super.onNewIntent(intent);
addTask(intent);
if (intent != null)
{
if (intent.hasExtra(EXTRA_TASK))
addTask(intent);
else if (intent.hasExtra(EXTRA_SEARCH_RES_SINGLE))
{
final boolean singleResult = intent.getBooleanExtra(EXTRA_SEARCH_RES_SINGLE, false);
if (singleResult)
onAdditionalLayerActivated(0);
else
onDismiss();
}
}
}
private final static String EXTRA_CONSUMED = "mwm.extra.intent.processed";
private void addTask(Intent intent)
{
if (intent != null
@ -807,6 +820,7 @@ public class MWMActivity extends NvEventQueueActivity
}
}
@Override
protected void onStop()
{
@ -1483,4 +1497,16 @@ public class MWMActivity extends NvEventQueueActivity
{
UiUtils.hideIf(isVisible, findViewById(R.id.map_buttons_bottom_ref));
}
// Need it for search
private static final String EXTRA_SEARCH_RES_SINGLE = "search_res_index";
public static void startWithSearchResult(Context context, boolean single)
{
final Intent mapIntent = new Intent(context, MWMActivity.class);
mapIntent.putExtra(EXTRA_SEARCH_RES_SINGLE, single);
context.startActivity(mapIntent);
// Next we need to handle intent
}
}

View file

@ -634,7 +634,7 @@ public class SearchActivity extends MapsWithMeBaseListActivity implements Locati
final String suggestion = getSA().onItemClick(position);
if (suggestion == null)
{
presentResult(v);
presentResult(v, position);
}
else
{
@ -643,18 +643,20 @@ public class SearchActivity extends MapsWithMeBaseListActivity implements Locati
}
}
private void presentResult(View v)
private void presentResult(View v, int position)
{
if (MWMApplication.get().isProVersion())
{
finish();
// TODO why does not getResult always return correct value?
// GetResult not always returns correct values?
final SearchAdapter.ViewHolder vh = (SearchAdapter.ViewHolder) v.getTag();
SearchController.get().setQuery(vh.m_name.getText().toString());
MWMActivity.startWithSearchResult(this, position != 0);
}
else
{
// TODO ask to buy pro
// Should we add something more attractive?
Utils.toastShortcut(this, R.string.search_available_in_pro_version);
}
}

View file

@ -1286,6 +1286,7 @@ void Framework::ShowAllSearchResults()
for (size_t i = 0; i < searchRes.GetCount(); ++i)
{
// @todo add type for each search result pin
search::Result const & tmpRes = searchRes.GetResult(i);
m_bmManager.AdditionalPoiLayerAddPoi(Bookmark(tmpRes.GetFeatureCenter(), tmpRes.GetString(), "api_pin"));