forked from organicmaps/organicmaps
[android] Changed up navigation logic in search fragment.
This commit is contained in:
parent
c22a1dfa11
commit
7b73fa0e3a
3 changed files with 21 additions and 3 deletions
|
@ -191,7 +191,7 @@ public class SearchAdapter extends RecyclerView.Adapter<SearchAdapter.ViewHolder
|
|||
if (result != null)
|
||||
{
|
||||
if (result.mType == SearchResult.TYPE_FEATURE)
|
||||
mSearchFragment.showSearchResultOnMap(resIndex);
|
||||
mSearchFragment.showSingleResultOnMap(resIndex);
|
||||
else
|
||||
mSearchFragment.setSearchQuery(result.mSuggestion);
|
||||
}
|
||||
|
|
|
@ -78,6 +78,23 @@ public class SearchFragment extends BaseMwmRecyclerFragment implements View.OnCl
|
|||
refreshContent();
|
||||
nativeConnectSearchListener();
|
||||
readArguments(getArguments());
|
||||
if (getToolbar() != null)
|
||||
getToolbar().setNavigationOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
if (getSearchQuery().isEmpty())
|
||||
{
|
||||
navigateUpToParent();
|
||||
return;
|
||||
}
|
||||
|
||||
setSearchQuery("");
|
||||
SearchToolbarController.cancelSearch();
|
||||
refreshContent();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -300,11 +317,11 @@ public class SearchFragment extends BaseMwmRecyclerFragment implements View.OnCl
|
|||
}
|
||||
// FIXME: This code only for demonstration purposes and will be removed soon
|
||||
|
||||
protected void showSearchResultOnMap(int resIndex)
|
||||
protected void showSingleResultOnMap(int resultIndex)
|
||||
{
|
||||
SearchToolbarController.cancelApiCall();
|
||||
SearchToolbarController.setQuery("");
|
||||
nativeShowItem(resIndex);
|
||||
nativeShowItem(resultIndex);
|
||||
InputUtils.hideKeyboard(mEtSearchQuery);
|
||||
navigateUpToParent();
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ public class SearchToolbarController implements OnClickListener
|
|||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
MWMActivity.startSearch(mActivity, mSearchQuery.getText().toString());
|
||||
cancelSearchApiAndHide();
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue