Fix back button at address search
This commit is contained in:
parent
8cd89bb95b
commit
0a8895cd9f
2 changed files with 27 additions and 6 deletions
|
@ -1481,10 +1481,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
QuickSearchDialogFragment fragment = getQuickSearchDialogFragment();
|
||||
if (fragment != null) {
|
||||
if (mode == ShowQuickSearchMode.NEW || (mode == ShowQuickSearchMode.NEW_IF_EXPIRED && fragment.isExpired())) {
|
||||
if (!fragment.onBackPressed()) {
|
||||
fragment.dismiss();
|
||||
QuickSearchDialogFragment.showInstance(this, "", null, showCategories, null);
|
||||
}
|
||||
fragment.dismiss();
|
||||
QuickSearchDialogFragment.showInstance(this, "", null, showCategories, null);
|
||||
} else {
|
||||
fragment.show();
|
||||
}
|
||||
|
|
|
@ -344,7 +344,9 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dismiss();
|
||||
if (!processBackAction()) {
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -551,6 +553,19 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
return new Dialog(getActivity(), getTheme()){
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (!processBackAction()) {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void saveCustomFilter() {
|
||||
final OsmandApplication app = getMyApplication();
|
||||
final PoiUIFilter filter = app.getPoiFilters().getCustomPOIFilter();
|
||||
|
@ -834,7 +849,11 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
super.onDismiss(dialog);
|
||||
}
|
||||
|
||||
public boolean onBackPressed() {
|
||||
private boolean processBackAction() {
|
||||
if (addressSearch && isSearchViewVisible()) {
|
||||
searchEditText.setText("");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -909,6 +928,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isSearchViewVisible() {
|
||||
return searchView.getVisibility() == View.VISIBLE;
|
||||
}
|
||||
|
||||
public void setResultCollection(SearchResultCollection resultCollection) {
|
||||
searchHelper.setResultCollection(resultCollection);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue